@circle-fin/w3s-pw-react-native-sdk 1.0.6 → 1.1.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/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/lib/commonjs/NativeProgrammablewalletRnSdk.js.map +1 -1
- package/lib/commonjs/ProgrammablewalletRnSdkModule.js.map +1 -1
- package/lib/commonjs/WalletSdk.js +20 -8
- package/lib/commonjs/WalletSdk.js.map +1 -1
- package/lib/commonjs/types.js +60 -4
- package/lib/commonjs/types.js.map +1 -1
- package/lib/module/NativeProgrammablewalletRnSdk.js.map +1 -1
- package/lib/module/ProgrammablewalletRnSdkModule.js.map +1 -1
- package/lib/module/WalletSdk.js +19 -7
- package/lib/module/WalletSdk.js.map +1 -1
- package/lib/module/types.js +59 -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 +83 -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 +101 -13
|
@@ -21,7 +21,7 @@ extension RNWalletSdk {
|
|
|
21
21
|
|
|
22
22
|
func customizeAdapter(controller: UIViewController) {
|
|
23
23
|
|
|
24
|
-
// UI Flow - New PIN
|
|
24
|
+
// MARK: UI Flow - New PIN
|
|
25
25
|
|
|
26
26
|
if let controller = controller as? NewPINCodeViewController {
|
|
27
27
|
if let configs = sTextsMap[.newPinCodeHeadline] { // A1
|
|
@@ -197,7 +197,7 @@ extension RNWalletSdk {
|
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
199
|
|
|
200
|
-
// UI Flow - Enter PIN
|
|
200
|
+
// MARK: UI Flow - Enter PIN
|
|
201
201
|
|
|
202
202
|
if let controller = controller as? EnterPINCodeViewController {
|
|
203
203
|
if let configs = sTextsMap[.enterPinCodeHeadline] { // A2
|
|
@@ -223,7 +223,7 @@ extension RNWalletSdk {
|
|
|
223
223
|
}
|
|
224
224
|
}
|
|
225
225
|
|
|
226
|
-
// UI Flow - Recover PIN
|
|
226
|
+
// MARK: UI Flow - Recover PIN
|
|
227
227
|
|
|
228
228
|
if let controller = controller as? RecoverPINCodeViewController {
|
|
229
229
|
if let configs = sTextsMap[.recoverPinCodeHeadline] { // A7
|
|
@@ -237,7 +237,7 @@ extension RNWalletSdk {
|
|
|
237
237
|
}
|
|
238
238
|
|
|
239
239
|
if let textConfig = self.sTextMap[.circlepw_recover_pincode_error_config] { // C38
|
|
240
|
-
self.setText(label: controller.errorMessageLabel, textConfig: textConfig)
|
|
240
|
+
self.setText(label: controller.errorMessageLabel, textConfig: textConfig, shouldReplaceText: false)
|
|
241
241
|
}
|
|
242
242
|
|
|
243
243
|
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
|
|
@@ -276,7 +276,7 @@ extension RNWalletSdk {
|
|
|
276
276
|
}
|
|
277
277
|
}
|
|
278
278
|
|
|
279
|
-
// UI Flow - Biometrics
|
|
279
|
+
// MARK: UI Flow - Biometrics
|
|
280
280
|
|
|
281
281
|
if let controller = controller as? BiometricsPromptViewController {
|
|
282
282
|
if let textConfig = sTextMap[.circlepw_pin_biometrics_allow_title] { // C46
|
|
@@ -295,6 +295,177 @@ extension RNWalletSdk {
|
|
|
295
295
|
setText(button: controller.dontAskButton, textConfig: textConfig)
|
|
296
296
|
}
|
|
297
297
|
}
|
|
298
|
+
|
|
299
|
+
// MARK: UI Flow - Transaction Request
|
|
300
|
+
|
|
301
|
+
if let controller = controller as? BaseRequestViewController {
|
|
302
|
+
if let textConfig = sTextMap[.circlepw_transaction_request_title] { // C63
|
|
303
|
+
setText(label: controller.baseNaviTitleLabel, textConfig: textConfig)
|
|
304
|
+
}
|
|
305
|
+
if let textConfig = sTextMap[.circlepw_transaction_request_subtitle] { // C64
|
|
306
|
+
setText(label: controller.descriptionLabel, textConfig: textConfig)
|
|
307
|
+
}
|
|
308
|
+
if let textConfig = sTextMap[.circlepw_transaction_request_error_config] { // C79
|
|
309
|
+
setText(label: controller.errorLabel, textConfig: textConfig, shouldReplaceText: false)
|
|
310
|
+
}
|
|
311
|
+
if let textConfig = sTextMap[.circlepw_confirm] { // C45
|
|
312
|
+
setText(button: controller.confirmButton, textConfig: textConfig)
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
if let controller = controller as? TransactionRequestViewController {
|
|
317
|
+
if let textConfig = sTextMap[.circlepw_transaction_request_main_currency] { // C65
|
|
318
|
+
setText(label: controller.currencyLabel, textConfig: textConfig)
|
|
319
|
+
}
|
|
320
|
+
if let textConfig = sTextMap[.circlepw_transaction_request_exchange_value] { // C66
|
|
321
|
+
setText(label: controller.txFiatValueLabel, textConfig: textConfig, shouldReplaceText: false)
|
|
322
|
+
}
|
|
323
|
+
if let textConfig = sTextMap[.circlepw_transaction_request_from_label] { // C67
|
|
324
|
+
setText(label: controller.fromTitleLabel, textConfig: textConfig)
|
|
325
|
+
}
|
|
326
|
+
if let textConfig = sTextMap[.circlepw_transaction_request_from] { // C68
|
|
327
|
+
setText(label: controller.fromLabel, textConfig: textConfig, shouldReplaceText: false)
|
|
328
|
+
}
|
|
329
|
+
if let textConfig = sTextMap[.circlepw_transaction_request_to_label] { // C69
|
|
330
|
+
setText(label: controller.toTitleLabel, textConfig: textConfig)
|
|
331
|
+
}
|
|
332
|
+
if let textConfig = sTextMap[.circlepw_transaction_request_to_config] { // C70
|
|
333
|
+
setText(label: controller.toLabel, textConfig: textConfig, shouldReplaceText: false)
|
|
334
|
+
}
|
|
335
|
+
if let textConfig = sTextMap[.circlepw_transaction_request_to_contract_name] { // C71
|
|
336
|
+
setText(label: controller.toContractNameLabel, textConfig: textConfig, shouldReplaceText: false)
|
|
337
|
+
}
|
|
338
|
+
if let textConfig = sTextMap[.circlepw_transaction_request_to_contract_url] { // C72
|
|
339
|
+
setText(label: controller.toContractURLLabel, textConfig: textConfig, shouldReplaceText: false)
|
|
340
|
+
}
|
|
341
|
+
if let textConfig = sTextMap[.circlepw_transaction_request_network_fee_label] { // C73
|
|
342
|
+
setText(label: controller.feeTitleLabel, textConfig: textConfig)
|
|
343
|
+
}
|
|
344
|
+
if let textConfig = sTextMap[.circlepw_transaction_request_network_fee] { // C74
|
|
345
|
+
setText(label: controller.feeLabel, textConfig: textConfig, shouldReplaceText: false)
|
|
346
|
+
}
|
|
347
|
+
if let textConfig = sTextMap[.circlepw_transaction_request_exchange_network_fee] { // C75
|
|
348
|
+
setText(label: controller.feeFiatValueLabel, textConfig: textConfig, shouldReplaceText: false)
|
|
349
|
+
}
|
|
350
|
+
if let textConfig = sTextMap[.circlepw_transaction_request_total_label] { // C76
|
|
351
|
+
setText(label: controller.totalTitleLabel, textConfig: textConfig)
|
|
352
|
+
}
|
|
353
|
+
if let textConfig = sTextMap[.circlepw_transaction_request_total_config] { // C77
|
|
354
|
+
setText(label: controller.totalLabel, textConfig: textConfig, shouldReplaceText: false)
|
|
355
|
+
}
|
|
356
|
+
if let textConfig = sTextMap[.circlepw_transaction_request_exchange_total_value] { // C78
|
|
357
|
+
setText(label: controller.totalFiatValueLabel, textConfig: textConfig, shouldReplaceText: false)
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
if let controller = controller as? FeeTipViewController {
|
|
363
|
+
if let textConfig = sTextMap[.circlepw_transaction_request_fee_tip] { // C80
|
|
364
|
+
setText(label: controller.descriptionLabel, textConfig: textConfig)
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
// MARK: UI Flow - Raw Transaction Request
|
|
369
|
+
|
|
370
|
+
if let controller = controller as? RawTransactionRequestViewController {
|
|
371
|
+
if let textConfig = sTextMap[.circlepw_transaction_request_raw_tx_description] { // C89
|
|
372
|
+
setText(label: controller.rawTxTitleLabel, textConfig: textConfig)
|
|
373
|
+
}
|
|
374
|
+
if let textConfig = sTextMap[.circlepw_transaction_request_raw_tx_config] { // C90
|
|
375
|
+
setText(label: controller.rawTxLabel, textConfig: textConfig, shouldReplaceText: false)
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
// MARK: UI Flow - Contract Interaction Request
|
|
380
|
+
|
|
381
|
+
if let controller = controller as? ContractRequestViewController {
|
|
382
|
+
if let textConfig = sTextMap[.circlepw_contract_interaction_title] { // C?
|
|
383
|
+
setText(label: controller.baseNaviTitleLabel, textConfig: textConfig)
|
|
384
|
+
}
|
|
385
|
+
if let textConfig = sTextMap[.circlepw_contract_interaction_subtitle] { // C?
|
|
386
|
+
setText(label: controller.descriptionLabel, textConfig: textConfig)
|
|
387
|
+
}
|
|
388
|
+
if let textConfig = sTextMap[.circlepw_contract_interaction_contract_address_label] { // C81
|
|
389
|
+
setText(label: controller.contractAddressTitleLabel, textConfig: textConfig)
|
|
390
|
+
}
|
|
391
|
+
if let textConfig = sTextMap[.circlepw_contract_interaction_contract_address_config] { // C82
|
|
392
|
+
setText(label: controller.contractAddressLabel, textConfig: textConfig, shouldReplaceText: false)
|
|
393
|
+
}
|
|
394
|
+
if let textConfig = sTextMap[.circlepw_contract_interaction_data_details] { // C83
|
|
395
|
+
setText(label: controller.dataDetailsLabel, textConfig: textConfig)
|
|
396
|
+
}
|
|
397
|
+
if let textConfig = sTextMap[.circlepw_contract_interaction_abi_function_label] { // C84
|
|
398
|
+
setText(label: controller.abiFunctionTitleLabel, textConfig: textConfig)
|
|
399
|
+
}
|
|
400
|
+
if let textConfig = sTextMap[.circlepw_contract_interaction_abi_function_config] { // C85
|
|
401
|
+
setText(label: controller.abiFunctionLabel, textConfig: textConfig, shouldReplaceText: false)
|
|
402
|
+
}
|
|
403
|
+
if let textConfig = sTextMap[.circlepw_contract_interaction_abi_parameter_label] { // C86
|
|
404
|
+
setText(label: controller.abiParameterTitleLabel, textConfig: textConfig)
|
|
405
|
+
}
|
|
406
|
+
if let textConfig = sTextMap[.circlepw_contract_interaction_call_data_label] { // C87
|
|
407
|
+
setText(label: controller.callDataTitleLabel, textConfig: textConfig)
|
|
408
|
+
}
|
|
409
|
+
if let textConfig = sTextMap[.circlepw_contract_interaction_call_data_config] { // C88
|
|
410
|
+
setText(label: controller.abiParameterLabel, textConfig: textConfig, shouldReplaceText: false)
|
|
411
|
+
setText(label: controller.callDataLabel, textConfig: textConfig, shouldReplaceText: false)
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
// MARK: UI Flow - Signature Request
|
|
416
|
+
|
|
417
|
+
if let controller = controller as? SignatureRequestViewController {
|
|
418
|
+
if let textConfig = sTextMap[.circlepw_signature_request_title] { // C91
|
|
419
|
+
setText(label: controller.titleLabel, textConfig: textConfig)
|
|
420
|
+
}
|
|
421
|
+
if let textConfig = sTextMap[.circlepw_signature_request_contract_name] { // C92
|
|
422
|
+
setText(label: controller.contractNameLabel, textConfig: textConfig, shouldReplaceText: false)
|
|
423
|
+
}
|
|
424
|
+
if let textConfig = sTextMap[.circlepw_signature_request_contract_url] { // C93
|
|
425
|
+
setText(label: controller.contractURLLabel, textConfig: textConfig, shouldReplaceText: false)
|
|
426
|
+
}
|
|
427
|
+
if let textConfig = sTextMap[.circlepw_signature_request_subtitle] { // C94
|
|
428
|
+
setText(label: controller.subtitleLabel, textConfig: textConfig)
|
|
429
|
+
}
|
|
430
|
+
if let textConfig = sTextMap[.circlepw_signature_request_description] { // C95
|
|
431
|
+
setText(label: controller.descriptionLabel, textConfig: textConfig)
|
|
432
|
+
}
|
|
433
|
+
if let textConfig = sTextMap[.circlepw_signature_request_msg_config] { // C96
|
|
434
|
+
setText(label: controller.messageLabel, textConfig: textConfig, shouldReplaceText: false)
|
|
435
|
+
}
|
|
436
|
+
if let textConfig = sTextMap[.circlepw_confirm] { // C45
|
|
437
|
+
setText(button: controller.confirmButton, textConfig: textConfig)
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
// MARK: UI Flow - Email OTP
|
|
442
|
+
|
|
443
|
+
if let controller = controller as? EmailOTPViewController {
|
|
444
|
+
if let textConfig = sTextMap[.circlepw_email_otp_title] { // C99
|
|
445
|
+
setText(label: controller.baseNaviTitleLabel, textConfig: textConfig)
|
|
446
|
+
}
|
|
447
|
+
if let textConfig1 = sTextMap[.circlepw_email_otp_description],
|
|
448
|
+
let textConfig2 = sTextMap[.circlepw_email_otp_email] { // C100, C101
|
|
449
|
+
var textConfig = textConfig1
|
|
450
|
+
if let text2 = textConfig2.text {
|
|
451
|
+
textConfig.text?.append(" ")
|
|
452
|
+
textConfig.text?.append(text2)
|
|
453
|
+
}
|
|
454
|
+
setText(label: controller.descriptionLabel, textConfig: textConfig)
|
|
455
|
+
}
|
|
456
|
+
if let textConfig = sTextMap[.circlepw_email_otp_head_config] { // C102
|
|
457
|
+
setText(label: controller.otpHeadLabel, textConfig: textConfig, shouldReplaceText: false)
|
|
458
|
+
}
|
|
459
|
+
if let textConfig = sTextMap[.circlepw_email_otp_dash] { // C103
|
|
460
|
+
setText(label: controller.otpDashLabel, textConfig: textConfig)
|
|
461
|
+
}
|
|
462
|
+
if let textConfig = sTextMap[.circlepw_email_otp_send_again_hint] { // C104
|
|
463
|
+
setText(label: controller.sendAgainHintLabel, textConfig: textConfig)
|
|
464
|
+
}
|
|
465
|
+
if let textConfig = sTextMap[.circlepw_email_otp_send_again] { // C105
|
|
466
|
+
setText(button: controller.sendAgainButton, textConfig: textConfig)
|
|
467
|
+
}
|
|
468
|
+
}
|
|
298
469
|
}
|
|
299
470
|
}
|
|
300
471
|
|
package/ios/RnWalletSdk.swift
CHANGED
|
@@ -76,21 +76,21 @@ public class RNWalletSdk: NSObject {
|
|
|
76
76
|
DispatchQueue.main.async {
|
|
77
77
|
WalletSdk.shared.execute(userToken: userToken,
|
|
78
78
|
encryptionKey: encryptionKey,
|
|
79
|
-
challengeIds: challengeIdArr) {
|
|
80
|
-
switch
|
|
81
|
-
case .success(let
|
|
82
|
-
self.
|
|
83
|
-
onWarning:
|
|
84
|
-
controller:
|
|
79
|
+
challengeIds: challengeIdArr) { executeCompletion in
|
|
80
|
+
switch executeCompletion.result {
|
|
81
|
+
case .success(let executeResult):
|
|
82
|
+
self._handleExecuteResult(result: executeResult,
|
|
83
|
+
onWarning: executeCompletion.onWarning,
|
|
84
|
+
controller: executeCompletion.onErrorController,
|
|
85
85
|
resolve: resolve)
|
|
86
86
|
|
|
87
87
|
case .failure(let error):
|
|
88
88
|
self._handleErrorResult(error: error,
|
|
89
|
-
controller:
|
|
89
|
+
controller: executeCompletion.onErrorController,
|
|
90
90
|
reject: reject)
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
//
|
|
93
|
+
// Remove cache controller
|
|
94
94
|
self.sdkNavigationController = nil
|
|
95
95
|
}
|
|
96
96
|
}
|
|
@@ -102,32 +102,7 @@ public class RNWalletSdk: NSObject {
|
|
|
102
102
|
challengeIds: NSArray,
|
|
103
103
|
resolve: @escaping RCTPromiseResolveBlock,
|
|
104
104
|
reject: @escaping RCTPromiseRejectBlock) {
|
|
105
|
-
|
|
106
|
-
reject(nil, "[unknown format] challengeIds", nil)
|
|
107
|
-
return
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
DispatchQueue.main.async {
|
|
111
|
-
WalletSdk.shared.executeWithUserSecret(userToken: userToken,
|
|
112
|
-
encryptionKey: encryptionKey,
|
|
113
|
-
userSecret: userSecret,
|
|
114
|
-
challengeIds: challengeIdArr) { response in
|
|
115
|
-
switch response.result {
|
|
116
|
-
case .success(let result):
|
|
117
|
-
self._handleSuccessResult(result: result,
|
|
118
|
-
onWarning: response.onWarning,
|
|
119
|
-
controller: response.onErrorController,
|
|
120
|
-
resolve: resolve)
|
|
121
|
-
|
|
122
|
-
case .failure(let error):
|
|
123
|
-
self._handleErrorResult(error: error,
|
|
124
|
-
controller: response.onErrorController,
|
|
125
|
-
reject: reject)
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
self.sdkNavigationController = nil
|
|
129
|
-
}
|
|
130
|
-
}
|
|
105
|
+
reject(nil, "executeWithUserSecret func deprecated", nil)
|
|
131
106
|
}
|
|
132
107
|
|
|
133
108
|
@objc public func setBiometricsPin(_ userToken: String,
|
|
@@ -136,71 +111,81 @@ public class RNWalletSdk: NSObject {
|
|
|
136
111
|
reject: @escaping RCTPromiseRejectBlock) {
|
|
137
112
|
|
|
138
113
|
DispatchQueue.main.async {
|
|
139
|
-
WalletSdk.shared.setBiometricsPin(userToken: userToken, encryptionKey: encryptionKey) {
|
|
140
|
-
switch
|
|
141
|
-
case .success(let
|
|
142
|
-
self.
|
|
143
|
-
onWarning:
|
|
144
|
-
controller:
|
|
114
|
+
WalletSdk.shared.setBiometricsPin(userToken: userToken, encryptionKey: encryptionKey) { executeCompletion in
|
|
115
|
+
switch executeCompletion.result {
|
|
116
|
+
case .success(let executeResult):
|
|
117
|
+
self._handleExecuteResult(result: executeResult,
|
|
118
|
+
onWarning: executeCompletion.onWarning,
|
|
119
|
+
controller: executeCompletion.onErrorController,
|
|
145
120
|
resolve: resolve)
|
|
146
121
|
|
|
147
122
|
case .failure(let error):
|
|
148
123
|
self._handleErrorResult(error: error,
|
|
149
|
-
controller:
|
|
124
|
+
controller: executeCompletion.onErrorController,
|
|
150
125
|
reject: reject)
|
|
151
126
|
}
|
|
152
127
|
}
|
|
153
128
|
}
|
|
154
129
|
}
|
|
155
130
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
let
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
131
|
+
@objc public func performLogin(provider: String,
|
|
132
|
+
deviceToken: String,
|
|
133
|
+
encryptionKey: String,
|
|
134
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
135
|
+
reject: @escaping RCTPromiseRejectBlock) {
|
|
136
|
+
guard let socialProvider = SocialProvider(rawValue: provider) else {
|
|
137
|
+
reject(nil, "[unknown format] invalid provider string", nil)
|
|
138
|
+
return
|
|
139
|
+
}
|
|
140
|
+
DispatchQueue.main.async {
|
|
141
|
+
WalletSdk.shared.performLogin(provider: socialProvider,
|
|
142
|
+
deviceToken: deviceToken,
|
|
143
|
+
encryptionKey: encryptionKey) { loginCompletion in
|
|
144
|
+
switch loginCompletion.result {
|
|
145
|
+
case .success(let loginResult):
|
|
146
|
+
self._handleLoginResult(result: loginResult, resolve: resolve)
|
|
172
147
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
]
|
|
178
|
-
dismiss = self.sDismissOnCallbackMap[onWarning.warningType.rawValue] == true
|
|
148
|
+
case .failure(let error):
|
|
149
|
+
reject(String(error.errorCode.rawValue), error.displayString, error)
|
|
150
|
+
}
|
|
151
|
+
}
|
|
179
152
|
}
|
|
153
|
+
}
|
|
180
154
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
155
|
+
@objc public func verifyOTP(deviceToken: String,
|
|
156
|
+
encryptionKey: String,
|
|
157
|
+
otpToken: String,
|
|
158
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
159
|
+
reject: @escaping RCTPromiseRejectBlock) {
|
|
184
160
|
|
|
185
|
-
|
|
186
|
-
|
|
161
|
+
DispatchQueue.main.async {
|
|
162
|
+
WalletSdk.shared.verifyOTP(deviceToken: deviceToken,
|
|
163
|
+
encryptionKey: encryptionKey,
|
|
164
|
+
otpToken: otpToken) { loginCompletion in
|
|
165
|
+
switch loginCompletion.result {
|
|
166
|
+
case .success(let loginResult):
|
|
167
|
+
self._handleLoginResult(result: loginResult, resolve: resolve)
|
|
168
|
+
|
|
169
|
+
case .failure(let error):
|
|
170
|
+
self._handleErrorResult(error: error,
|
|
171
|
+
controller: loginCompletion.onErrorController,
|
|
172
|
+
reject: reject)
|
|
173
|
+
}
|
|
174
|
+
}
|
|
187
175
|
}
|
|
188
176
|
}
|
|
189
177
|
|
|
190
|
-
|
|
191
|
-
|
|
178
|
+
@objc public func performLogout(provider: String,
|
|
179
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
192
180
|
reject: @escaping RCTPromiseRejectBlock) {
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
"message": error.displayString
|
|
202
|
-
]
|
|
203
|
-
EventEmitter.sharedInstance.dispatch(name: "CirclePwOnError", body: dict)
|
|
181
|
+
guard let socialProvider = SocialProvider(rawValue: provider) else {
|
|
182
|
+
reject(nil, "[unknown format] invalid provider string", nil)
|
|
183
|
+
return
|
|
184
|
+
}
|
|
185
|
+
DispatchQueue.main.async {
|
|
186
|
+
WalletSdk.shared.performLogout(provider: socialProvider) { _ in
|
|
187
|
+
resolve(nil)
|
|
188
|
+
}
|
|
204
189
|
}
|
|
205
190
|
}
|
|
206
191
|
|
|
@@ -318,3 +303,83 @@ extension RNWalletSdk: WalletSdkLayoutProvider {
|
|
|
318
303
|
return ImageStore(local: sLocal, remote: sRemote)
|
|
319
304
|
}
|
|
320
305
|
}
|
|
306
|
+
|
|
307
|
+
private extension RNWalletSdk {
|
|
308
|
+
|
|
309
|
+
func _handleExecuteResult(result: ExecuteResult,
|
|
310
|
+
onWarning: ExecuteWarning?,
|
|
311
|
+
controller: UIViewController?,
|
|
312
|
+
resolve: @escaping RCTPromiseResolveBlock) {
|
|
313
|
+
let challengeStatus = result.status.rawValue
|
|
314
|
+
let challengeType = result.resultType.rawValue
|
|
315
|
+
var dismiss = false
|
|
316
|
+
var dict: [String: Any] = [
|
|
317
|
+
"result": [
|
|
318
|
+
"status": challengeStatus,
|
|
319
|
+
"resultType": challengeType,
|
|
320
|
+
"data": [
|
|
321
|
+
"signature": result.data?.signature
|
|
322
|
+
]
|
|
323
|
+
]
|
|
324
|
+
]
|
|
325
|
+
|
|
326
|
+
if let onWarning = onWarning {
|
|
327
|
+
dict["warning"] = [
|
|
328
|
+
"warningType": onWarning.warningType.rawValue,
|
|
329
|
+
"warningString": onWarning.warningString
|
|
330
|
+
]
|
|
331
|
+
dismiss = self.sDismissOnCallbackMap[onWarning.warningType.rawValue] == true
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
if dismiss {
|
|
335
|
+
controller?.dismiss(animated: true)
|
|
336
|
+
resolve(dict)
|
|
337
|
+
|
|
338
|
+
} else {
|
|
339
|
+
EventEmitter.sharedInstance.dispatch(name: "CirclePwOnSuccess", body: dict)
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
func _handleLoginResult(result: LoginResult,
|
|
344
|
+
resolve: @escaping RCTPromiseResolveBlock) {
|
|
345
|
+
|
|
346
|
+
var oauthInfoDict: [String: Any]?
|
|
347
|
+
if let oauthInfo = result.oauthInfo {
|
|
348
|
+
oauthInfoDict = [
|
|
349
|
+
"provider": oauthInfo.provider,
|
|
350
|
+
"scope": oauthInfo.scope as Any,
|
|
351
|
+
"socialUserUUID": oauthInfo.socialUserUUID,
|
|
352
|
+
"socialUserInfo": [
|
|
353
|
+
"name": oauthInfo.socialUserInfo?.name,
|
|
354
|
+
"email": oauthInfo.socialUserInfo?.email,
|
|
355
|
+
"phone": oauthInfo.socialUserInfo?.phone,
|
|
356
|
+
]
|
|
357
|
+
]
|
|
358
|
+
}
|
|
359
|
+
let dict: [String: Any] = [
|
|
360
|
+
"userToken": result.userToken,
|
|
361
|
+
"encryptionKey": result.encryptionKey,
|
|
362
|
+
"refreshToken": result.refreshToken,
|
|
363
|
+
"oauthInfo": oauthInfoDict as Any
|
|
364
|
+
]
|
|
365
|
+
|
|
366
|
+
resolve(dict)
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
func _handleErrorResult(error: ApiError,
|
|
370
|
+
controller: UIViewController?,
|
|
371
|
+
reject: @escaping RCTPromiseRejectBlock) {
|
|
372
|
+
|
|
373
|
+
if self.sDismissOnCallbackMap[error.errorCode.rawValue] == true {
|
|
374
|
+
controller?.dismiss(animated: true)
|
|
375
|
+
reject(String(error.errorCode.rawValue), error.displayString, error)
|
|
376
|
+
|
|
377
|
+
} else {
|
|
378
|
+
let dict: [String: Any] = [
|
|
379
|
+
"code": String(error.errorCode.rawValue),
|
|
380
|
+
"message": error.displayString
|
|
381
|
+
]
|
|
382
|
+
EventEmitter.sharedInstance.dispatch(name: "CirclePwOnError", body: dict)
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
}
|