@circle-fin/daa-react-native-sdk 0.0.0-stage → 0.5.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/DaaReactNativeSdk.podspec +69 -0
- package/LICENSE +176 -0
- package/README.md +691 -2
- package/android/build.gradle +102 -0
- package/android/src/main/AndroidManifest.xml +1 -0
- package/android/src/main/java/com/circle/daa/reactnative/DaaRegistrationExceptions.kt +47 -0
- package/android/src/main/java/com/circle/daa/reactnative/DaaRegistrationModule.kt +104 -0
- package/android/src/main/java/com/circle/daa/reactnative/DaaScaExceptions.kt +60 -0
- package/android/src/main/java/com/circle/daa/reactnative/DaaScaModule.kt +179 -0
- package/android/src/main/java/com/circle/daa/reactnative/DaaSecureKeyExceptions.kt +107 -0
- package/android/src/main/java/com/circle/daa/reactnative/DaaSecureKeyModule.kt +318 -0
- package/android/src/main/java/com/circle/daa/reactnative/InstallationIdentityStore.kt +122 -0
- package/android/src/main/java/com/circle/daa/reactnative/UnpaddedBase64Url.kt +45 -0
- package/build/DaaClient.d.ts +237 -0
- package/build/DaaClient.js +442 -0
- package/build/api/AccountLimitsClient.d.ts +79 -0
- package/build/api/AccountLimitsClient.js +142 -0
- package/build/api/AccountsClient.d.ts +98 -0
- package/build/api/AccountsClient.js +279 -0
- package/build/api/AchFiatAccountsClient.d.ts +92 -0
- package/build/api/AchFiatAccountsClient.js +142 -0
- package/build/api/AuthClient.d.ts +95 -0
- package/build/api/AuthClient.js +221 -0
- package/build/api/ContractExecutionsClient.d.ts +114 -0
- package/build/api/ContractExecutionsClient.js +462 -0
- package/build/api/DaaUserClient.d.ts +187 -0
- package/build/api/DaaUserClient.js +312 -0
- package/build/api/DepositAddressesClient.d.ts +112 -0
- package/build/api/DepositAddressesClient.js +222 -0
- package/build/api/DepositsClient.d.ts +106 -0
- package/build/api/DepositsClient.js +183 -0
- package/build/api/FiatAccountsClient.d.ts +43 -0
- package/build/api/FiatAccountsClient.js +46 -0
- package/build/api/TransactionsClient.d.ts +64 -0
- package/build/api/TransactionsClient.js +121 -0
- package/build/api/TransfersClient.d.ts +107 -0
- package/build/api/TransfersClient.js +324 -0
- package/build/api/WireFiatAccountsClient.d.ts +99 -0
- package/build/api/WireFiatAccountsClient.js +156 -0
- package/build/api/WithdrawalsClient.d.ts +97 -0
- package/build/api/WithdrawalsClient.js +308 -0
- package/build/api/deviceApproval.d.ts +48 -0
- package/build/api/deviceApproval.js +247 -0
- package/build/api/deviceStatus.d.ts +61 -0
- package/build/api/deviceStatus.js +216 -0
- package/build/api/loginFailure.d.ts +51 -0
- package/build/api/loginFailure.js +95 -0
- package/build/api/pagination.d.ts +29 -0
- package/build/api/pagination.js +50 -0
- package/build/api/queryParameters.d.ts +23 -0
- package/build/api/queryParameters.js +77 -0
- package/build/api/resourceRequest.d.ts +60 -0
- package/build/api/resourceRequest.js +79 -0
- package/build/api/signedResource.d.ts +124 -0
- package/build/api/signedResource.js +267 -0
- package/build/auth/RegistrationFlowKey.d.ts +93 -0
- package/build/auth/RegistrationFlowKey.js +203 -0
- package/build/auth/daaRegistrationNative.d.ts +58 -0
- package/build/auth/daaRegistrationNative.js +158 -0
- package/build/auth/deviceAuthorization.d.ts +87 -0
- package/build/auth/deviceAuthorization.js +295 -0
- package/build/auth/ownerGrant.d.ts +29 -0
- package/build/auth/ownerGrant.js +90 -0
- package/build/auth/registrationAuthorization.d.ts +48 -0
- package/build/auth/registrationAuthorization.js +246 -0
- package/build/auth/registrationCodeVerifier.d.ts +31 -0
- package/build/auth/registrationCodeVerifier.js +75 -0
- package/build/config.d.ts +106 -0
- package/build/config.js +131 -0
- package/build/crypto/base64url.d.ts +26 -0
- package/build/crypto/base64url.js +87 -0
- package/build/crypto/bytes.d.ts +27 -0
- package/build/crypto/bytes.js +32 -0
- package/build/crypto/jwkThumbprint.d.ts +32 -0
- package/build/crypto/jwkThumbprint.js +49 -0
- package/build/crypto/matchingCode.d.ts +47 -0
- package/build/crypto/matchingCode.js +93 -0
- package/build/crypto/random.d.ts +35 -0
- package/build/crypto/random.js +106 -0
- package/build/crypto/serialization.d.ts +26 -0
- package/build/crypto/serialization.js +43 -0
- package/build/crypto/sha256.d.ts +18 -0
- package/build/crypto/sha256.js +100 -0
- package/build/errors.d.ts +307 -0
- package/build/errors.js +413 -0
- package/build/index.d.ts +69 -0
- package/build/index.js +67 -0
- package/build/models/Account.d.ts +201 -0
- package/build/models/Account.js +147 -0
- package/build/models/AccountLimitsUsage.d.ts +169 -0
- package/build/models/AccountLimitsUsage.js +86 -0
- package/build/models/Ach.d.ts +135 -0
- package/build/models/Ach.js +184 -0
- package/build/models/AddressObject.d.ts +128 -0
- package/build/models/AddressObject.js +141 -0
- package/build/models/BusinessPii.d.ts +84 -0
- package/build/models/BusinessPii.js +142 -0
- package/build/models/ContractExecution.d.ts +197 -0
- package/build/models/ContractExecution.js +130 -0
- package/build/models/CreateAccountRequest.d.ts +74 -0
- package/build/models/CreateAccountRequest.js +19 -0
- package/build/models/CreateContractExecutionRequest.d.ts +81 -0
- package/build/models/CreateContractExecutionRequest.js +19 -0
- package/build/models/CreateTransferRequest.d.ts +91 -0
- package/build/models/CreateTransferRequest.js +19 -0
- package/build/models/CreateWithdrawalRequest.d.ts +99 -0
- package/build/models/CreateWithdrawalRequest.js +19 -0
- package/build/models/DaaUserContext.d.ts +146 -0
- package/build/models/DaaUserContext.js +164 -0
- package/build/models/Deposit.d.ts +241 -0
- package/build/models/Deposit.js +149 -0
- package/build/models/DepositSummary.d.ts +91 -0
- package/build/models/DepositSummary.js +114 -0
- package/build/models/DeviceStatus.d.ts +69 -0
- package/build/models/DeviceStatus.js +19 -0
- package/build/models/FiatAccount.d.ts +99 -0
- package/build/models/FiatAccount.js +151 -0
- package/build/models/GenerateAddressRequest.d.ts +67 -0
- package/build/models/GenerateAddressRequest.js +68 -0
- package/build/models/Money.d.ts +76 -0
- package/build/models/Money.js +99 -0
- package/build/models/Page.d.ts +33 -0
- package/build/models/Page.js +57 -0
- package/build/models/PendingDeviceApproval.d.ts +121 -0
- package/build/models/PendingDeviceApproval.js +208 -0
- package/build/models/PendingDeviceRegistration.d.ts +229 -0
- package/build/models/PendingDeviceRegistration.js +636 -0
- package/build/models/PreparedContractExecution.d.ts +70 -0
- package/build/models/PreparedContractExecution.js +77 -0
- package/build/models/PreparedSocialLogin.d.ts +148 -0
- package/build/models/PreparedSocialLogin.js +252 -0
- package/build/models/Transaction.d.ts +233 -0
- package/build/models/Transaction.js +182 -0
- package/build/models/Transfer.d.ts +335 -0
- package/build/models/Transfer.js +240 -0
- package/build/models/Wire.d.ts +213 -0
- package/build/models/Wire.js +264 -0
- package/build/models/Withdrawal.d.ts +201 -0
- package/build/models/Withdrawal.js +156 -0
- package/build/models/codeSecrets.d.ts +100 -0
- package/build/models/codeSecrets.js +321 -0
- package/build/models/redaction.d.ts +18 -0
- package/build/models/redaction.js +23 -0
- package/build/sca/ScaClient.d.ts +105 -0
- package/build/sca/ScaClient.js +193 -0
- package/build/securekey/InMemorySecureKey.d.ts +25 -0
- package/build/securekey/InMemorySecureKey.js +168 -0
- package/build/securekey/NativeSecureKey.d.ts +26 -0
- package/build/securekey/NativeSecureKey.js +355 -0
- package/build/securekey/NativeSecureKeyBridge.d.ts +151 -0
- package/build/securekey/NativeSecureKeyBridge.js +19 -0
- package/build/securekey/SecureKey.d.ts +257 -0
- package/build/securekey/SecureKey.js +19 -0
- package/build/securekey/alias.d.ts +97 -0
- package/build/securekey/alias.js +184 -0
- package/build/securekey/ownerAuthKeyResolver.d.ts +73 -0
- package/build/securekey/ownerAuthKeyResolver.js +78 -0
- package/build/securekey/registration.d.ts +19 -0
- package/build/securekey/registration.js +38 -0
- package/build/securekey/resolveNativeBridge.d.ts +33 -0
- package/build/securekey/resolveNativeBridge.js +201 -0
- package/build/testing.d.ts +18 -0
- package/build/testing.js +34 -0
- package/build/transport/DaaTransport.d.ts +35 -0
- package/build/transport/DaaTransport.js +19 -0
- package/build/transport/headers.d.ts +41 -0
- package/build/transport/headers.js +81 -0
- package/build/validation/requestBody.d.ts +27 -0
- package/build/validation/requestBody.js +56 -0
- package/build/validation/uuid.d.ts +25 -0
- package/build/validation/uuid.js +33 -0
- package/build/wire/accountLimitsUsagePayload.d.ts +30 -0
- package/build/wire/accountLimitsUsagePayload.js +130 -0
- package/build/wire/accountPayload.d.ts +36 -0
- package/build/wire/accountPayload.js +100 -0
- package/build/wire/achPayload.d.ts +24 -0
- package/build/wire/achPayload.js +82 -0
- package/build/wire/addressObjectPayload.d.ts +44 -0
- package/build/wire/addressObjectPayload.js +64 -0
- package/build/wire/contractExecutionPayload.d.ts +24 -0
- package/build/wire/contractExecutionPayload.js +130 -0
- package/build/wire/daaStatusCodes.d.ts +81 -0
- package/build/wire/daaStatusCodes.js +86 -0
- package/build/wire/dataEnvelope.d.ts +40 -0
- package/build/wire/dataEnvelope.js +79 -0
- package/build/wire/depositPayload.d.ts +42 -0
- package/build/wire/depositPayload.js +159 -0
- package/build/wire/deviceContextPayload.d.ts +35 -0
- package/build/wire/deviceContextPayload.js +59 -0
- package/build/wire/deviceRegistrationResultPayload.d.ts +77 -0
- package/build/wire/deviceRegistrationResultPayload.js +162 -0
- package/build/wire/deviceStatusPayload.d.ts +20 -0
- package/build/wire/deviceStatusPayload.js +66 -0
- package/build/wire/errorEnvelope.d.ts +43 -0
- package/build/wire/errorEnvelope.js +85 -0
- package/build/wire/fiatAccountPayload.d.ts +37 -0
- package/build/wire/fiatAccountPayload.js +93 -0
- package/build/wire/instant.d.ts +27 -0
- package/build/wire/instant.js +94 -0
- package/build/wire/jsonNumber.d.ts +30 -0
- package/build/wire/jsonNumber.js +34 -0
- package/build/wire/moneyPayload.d.ts +30 -0
- package/build/wire/moneyPayload.js +56 -0
- package/build/wire/paginationLinks.d.ts +28 -0
- package/build/wire/paginationLinks.js +167 -0
- package/build/wire/payload.d.ts +60 -0
- package/build/wire/payload.js +121 -0
- package/build/wire/pendingRegistrationPayload.d.ts +48 -0
- package/build/wire/pendingRegistrationPayload.js +72 -0
- package/build/wire/socialLoginRequestPayload.d.ts +26 -0
- package/build/wire/socialLoginRequestPayload.js +55 -0
- package/build/wire/transactionPayload.d.ts +31 -0
- package/build/wire/transactionPayload.js +149 -0
- package/build/wire/transferPayload.d.ts +43 -0
- package/build/wire/transferPayload.js +218 -0
- package/build/wire/wireEnums.d.ts +22 -0
- package/build/wire/wireEnums.js +69 -0
- package/build/wire/wirePayload.d.ts +29 -0
- package/build/wire/wirePayload.js +138 -0
- package/build/wire/withdrawalPayload.d.ts +27 -0
- package/build/wire/withdrawalPayload.js +179 -0
- package/expo-module.config.json +14 -0
- package/ios/DaaRegistrationExceptions.swift +58 -0
- package/ios/DaaRegistrationModule.swift +125 -0
- package/ios/DaaScaExceptions.swift +96 -0
- package/ios/DaaScaModule.swift +125 -0
- package/ios/DaaSecureKeyExceptions.swift +125 -0
- package/ios/DaaSecureKeyModule.swift +306 -0
- package/ios/InstallationIdentityStore.swift +162 -0
- package/ios/UnpaddedBase64URL.swift +42 -0
- package/package.json +114 -4
- package/src/DaaClient.ts +509 -0
- package/src/api/AccountLimitsClient.ts +146 -0
- package/src/api/AccountsClient.ts +308 -0
- package/src/api/AchFiatAccountsClient.ts +147 -0
- package/src/api/AuthClient.ts +266 -0
- package/src/api/ContractExecutionsClient.ts +527 -0
- package/src/api/DaaUserClient.ts +345 -0
- package/src/api/DepositAddressesClient.ts +239 -0
- package/src/api/DepositsClient.ts +208 -0
- package/src/api/FiatAccountsClient.ts +50 -0
- package/src/api/TransactionsClient.ts +138 -0
- package/src/api/TransfersClient.ts +364 -0
- package/src/api/WireFiatAccountsClient.ts +172 -0
- package/src/api/WithdrawalsClient.ts +342 -0
- package/src/api/deviceApproval.ts +306 -0
- package/src/api/deviceStatus.ts +238 -0
- package/src/api/loginFailure.ts +112 -0
- package/src/api/pagination.ts +63 -0
- package/src/api/queryParameters.ts +82 -0
- package/src/api/resourceRequest.ts +135 -0
- package/src/api/signedResource.ts +427 -0
- package/src/auth/RegistrationFlowKey.ts +274 -0
- package/src/auth/daaRegistrationNative.ts +191 -0
- package/src/auth/deviceAuthorization.ts +365 -0
- package/src/auth/ownerGrant.ts +102 -0
- package/src/auth/registrationAuthorization.ts +309 -0
- package/src/auth/registrationCodeVerifier.ts +76 -0
- package/src/config.ts +192 -0
- package/src/crypto/base64url.ts +88 -0
- package/src/crypto/bytes.ts +30 -0
- package/src/crypto/jwkThumbprint.ts +65 -0
- package/src/crypto/matchingCode.ts +100 -0
- package/src/crypto/random.ts +113 -0
- package/src/crypto/serialization.ts +42 -0
- package/src/crypto/sha256.ts +105 -0
- package/src/errors.ts +576 -0
- package/src/index.ts +258 -0
- package/src/models/Account.ts +264 -0
- package/src/models/AccountLimitsUsage.ts +192 -0
- package/src/models/Ach.ts +269 -0
- package/src/models/AddressObject.ts +169 -0
- package/src/models/BusinessPii.ts +154 -0
- package/src/models/ContractExecution.ts +250 -0
- package/src/models/CreateAccountRequest.ts +109 -0
- package/src/models/CreateContractExecutionRequest.ts +100 -0
- package/src/models/CreateTransferRequest.ts +114 -0
- package/src/models/CreateWithdrawalRequest.ts +120 -0
- package/src/models/DaaUserContext.ts +228 -0
- package/src/models/Deposit.ts +307 -0
- package/src/models/DepositSummary.ts +142 -0
- package/src/models/DeviceStatus.ts +50 -0
- package/src/models/FiatAccount.ts +195 -0
- package/src/models/GenerateAddressRequest.ts +101 -0
- package/src/models/Money.ts +91 -0
- package/src/models/Page.ts +48 -0
- package/src/models/PendingDeviceApproval.ts +229 -0
- package/src/models/PendingDeviceRegistration.ts +791 -0
- package/src/models/PreparedContractExecution.ts +128 -0
- package/src/models/PreparedSocialLogin.ts +297 -0
- package/src/models/Transaction.ts +322 -0
- package/src/models/Transfer.ts +459 -0
- package/src/models/Wire.ts +405 -0
- package/src/models/Withdrawal.ts +283 -0
- package/src/models/codeSecrets.ts +360 -0
- package/src/models/redaction.ts +22 -0
- package/src/sca/ScaClient.ts +289 -0
- package/src/securekey/InMemorySecureKey.ts +192 -0
- package/src/securekey/NativeSecureKey.ts +388 -0
- package/src/securekey/NativeSecureKeyBridge.ts +189 -0
- package/src/securekey/SecureKey.ts +279 -0
- package/src/securekey/alias.ts +212 -0
- package/src/securekey/ownerAuthKeyResolver.ts +135 -0
- package/src/securekey/registration.ts +40 -0
- package/src/securekey/resolveNativeBridge.ts +343 -0
- package/src/testing.ts +32 -0
- package/src/transport/DaaTransport.ts +42 -0
- package/src/transport/headers.ts +93 -0
- package/src/validation/requestBody.ts +60 -0
- package/src/validation/uuid.ts +31 -0
- package/src/wire/accountLimitsUsagePayload.ts +182 -0
- package/src/wire/accountPayload.ts +108 -0
- package/src/wire/achPayload.ts +98 -0
- package/src/wire/addressObjectPayload.ts +64 -0
- package/src/wire/contractExecutionPayload.ts +152 -0
- package/src/wire/daaStatusCodes.ts +86 -0
- package/src/wire/dataEnvelope.ts +80 -0
- package/src/wire/depositPayload.ts +186 -0
- package/src/wire/deviceContextPayload.ts +60 -0
- package/src/wire/deviceRegistrationResultPayload.ts +211 -0
- package/src/wire/deviceStatusPayload.ts +68 -0
- package/src/wire/errorEnvelope.ts +87 -0
- package/src/wire/fiatAccountPayload.ts +112 -0
- package/src/wire/instant.ts +96 -0
- package/src/wire/jsonNumber.ts +33 -0
- package/src/wire/moneyPayload.ts +55 -0
- package/src/wire/paginationLinks.ts +204 -0
- package/src/wire/payload.ts +146 -0
- package/src/wire/pendingRegistrationPayload.ts +118 -0
- package/src/wire/socialLoginRequestPayload.ts +66 -0
- package/src/wire/transactionPayload.ts +181 -0
- package/src/wire/transferPayload.ts +249 -0
- package/src/wire/wireEnums.ts +74 -0
- package/src/wire/wirePayload.ts +160 -0
- package/src/wire/withdrawalPayload.ts +219 -0
- package/testing.d.ts +19 -0
- package/testing.js +25 -0
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
// Copyright (c) 2026, Circle Internet Group, Inc. 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
|
+
|
|
17
|
+
apply plugin: 'com.android.library'
|
|
18
|
+
|
|
19
|
+
import groovy.json.JsonSlurper
|
|
20
|
+
|
|
21
|
+
def getPackageJsonVersion() {
|
|
22
|
+
def packageJsonFile = file("${projectDir}/../package.json")
|
|
23
|
+
def packageJson = new JsonSlurper().parseText(packageJsonFile.text)
|
|
24
|
+
return packageJson.version
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
group = 'com.circle.daa.reactnative'
|
|
28
|
+
version = getPackageJsonVersion()
|
|
29
|
+
|
|
30
|
+
def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
|
|
31
|
+
if (expoModulesCorePlugin.exists()) {
|
|
32
|
+
apply from: expoModulesCorePlugin
|
|
33
|
+
applyKotlinExpoModulesCorePlugin()
|
|
34
|
+
useCoreDependencies()
|
|
35
|
+
useExpoPublishing()
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
def useManagedAndroidSdkVersions = false
|
|
39
|
+
if (useManagedAndroidSdkVersions) {
|
|
40
|
+
useDefaultAndroidSdkVersions()
|
|
41
|
+
} else {
|
|
42
|
+
buildscript {
|
|
43
|
+
ext.safeExtGet = { prop, fallback ->
|
|
44
|
+
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
project.android {
|
|
48
|
+
compileSdkVersion safeExtGet("compileSdkVersion", 36)
|
|
49
|
+
defaultConfig {
|
|
50
|
+
minSdkVersion safeExtGet("minSdkVersion", 23)
|
|
51
|
+
targetSdkVersion safeExtGet("targetSdkVersion", 36)
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
android {
|
|
57
|
+
namespace "com.circle.daa.reactnative"
|
|
58
|
+
defaultConfig {
|
|
59
|
+
versionCode 1
|
|
60
|
+
versionName getPackageJsonVersion()
|
|
61
|
+
}
|
|
62
|
+
compileOptions {
|
|
63
|
+
sourceCompatibility JavaVersion.VERSION_17
|
|
64
|
+
targetCompatibility JavaVersion.VERSION_17
|
|
65
|
+
}
|
|
66
|
+
lintOptions {
|
|
67
|
+
abortOnError false
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// com.circle.daa:daa-android-sdk is a published Maven coordinate (GitHub
|
|
72
|
+
// Packages). This module declares no `repositories {}` block; the host
|
|
73
|
+
// application supplies the credentialed repository. See README.md for the
|
|
74
|
+
// Podfile-equivalent Gradle setup (DAA_ANDROID_MAVEN_URL / _USERNAME /
|
|
75
|
+
// _PASSWORD).
|
|
76
|
+
|
|
77
|
+
dependencies {
|
|
78
|
+
// Pin the native SDK so dependency resolution is reproducible and updates
|
|
79
|
+
// are deliberate. 0.8.0 provides the APIs and behaviour this module relies
|
|
80
|
+
// on: it has resolveExisting() and acknowledgeRegistration(authKeyId,
|
|
81
|
+
// ownerBindingId), which NativeSecureKeyStore.resolveExisting and the
|
|
82
|
+
// acknowledgement call through DaaSecureKeyModule.kt; it sets all of the
|
|
83
|
+
// BiometricPrompt text itself from the validated operation, so signDeviceAuthorization and
|
|
84
|
+
// signRegistrationDeviceAuthorization take the FragmentActivity directly
|
|
85
|
+
// and DaaSecureKeyModule.kt passes no prompt text; its registration signer
|
|
86
|
+
// accepts the minimal device-proof claim set this package sends and allows
|
|
87
|
+
// `register_device_key` version 3 on `/v1/accounts/auth/keys` (first
|
|
88
|
+
// released in 0.8.0; 0.7.0 and earlier refuse to sign Device Registration
|
|
89
|
+
// Complete); it has
|
|
90
|
+
// the native SCA ceremony (DaaScaApproveContract / DaaScaEnrollContract)
|
|
91
|
+
// with strict callback parsing, which DaaScaModule.kt bridges, and runs a
|
|
92
|
+
// custom-scheme enrollment redirect only in an Auth Tab (with no allowed
|
|
93
|
+
// Auth Tab browser the ceremony fails Unsupported(InsecureRedirect)); and
|
|
94
|
+
// it has DaaSecureRandom and DaaRegistrationFlowKey, which
|
|
95
|
+
// DaaRegistrationModule.kt calls. The SCA
|
|
96
|
+
// ceremony requires compileSdk 36 and AGP 8.9.1+ of every consumer
|
|
97
|
+
// (androidx.browser 1.9.0), hence the 36 defaults above.
|
|
98
|
+
api("com.circle.daa:daa-android-sdk:0.8.0")
|
|
99
|
+
// This module calls runBlocking. daa-android-sdk scopes coroutines as
|
|
100
|
+
// implementation, so it is not on this compile classpath transitively.
|
|
101
|
+
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.2")
|
|
102
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android" />
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// Copyright (c) 2026, Circle Internet Group, Inc. 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
|
+
|
|
17
|
+
package com.circle.daa.reactnative
|
|
18
|
+
|
|
19
|
+
import com.circle.daa.sdk.DaaRegistrationFlowKeyError
|
|
20
|
+
import com.circle.daa.sdk.DaaRegistrationFlowKeyException
|
|
21
|
+
import expo.modules.kotlin.exception.CodedException
|
|
22
|
+
|
|
23
|
+
internal class RegistrationContractViolationException :
|
|
24
|
+
CodedException("CONTRACT_VIOLATION", "Native registration operation failed", null)
|
|
25
|
+
|
|
26
|
+
// No DaaSecureRandomError branch here, unlike the Swift mapper. That is a real
|
|
27
|
+
// platform divergence, not an omission: `SecRandomCopyBytes` returns a failable
|
|
28
|
+
// OSStatus, so daa-ios-sdk needs a DaaSecureRandomError type, while Kotlin's
|
|
29
|
+
// `SecureRandom.nextBytes` cannot fail and daa-android-sdk therefore declares no
|
|
30
|
+
// such type — there is nothing to match on. An invalid byte count arrives as
|
|
31
|
+
// IllegalArgumentException and is caught by the fallthrough below, which maps it
|
|
32
|
+
// to the same CONTRACT_VIOLATION the Swift side would produce. The JS-visible
|
|
33
|
+
// behaviour is identical; only the shape of the mapper differs.
|
|
34
|
+
internal fun mappedRegistrationException(error: Throwable): CodedException {
|
|
35
|
+
if (error is CodedException) {
|
|
36
|
+
return error
|
|
37
|
+
}
|
|
38
|
+
if (error is DaaRegistrationFlowKeyException) {
|
|
39
|
+
return when (error.error) {
|
|
40
|
+
DaaRegistrationFlowKeyError.KeyGenerationFailed,
|
|
41
|
+
DaaRegistrationFlowKeyError.PublicKeyUnavailable,
|
|
42
|
+
DaaRegistrationFlowKeyError.SigningFailed,
|
|
43
|
+
-> RegistrationContractViolationException()
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return RegistrationContractViolationException()
|
|
47
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
// Copyright (c) 2026, Circle Internet Group, Inc. 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
|
+
|
|
17
|
+
package com.circle.daa.reactnative
|
|
18
|
+
|
|
19
|
+
import com.circle.daa.sdk.DaaRegistrationAuthorizationSigningInput
|
|
20
|
+
import com.circle.daa.sdk.DaaRegistrationFlowKey
|
|
21
|
+
import com.circle.daa.sdk.DaaSecureRandom
|
|
22
|
+
import expo.modules.kotlin.modules.Module
|
|
23
|
+
import expo.modules.kotlin.modules.ModuleDefinition
|
|
24
|
+
import java.util.UUID
|
|
25
|
+
import java.util.concurrent.ConcurrentHashMap
|
|
26
|
+
|
|
27
|
+
// Thin Expo bridge to the native registration primitives. THIS IS NOT
|
|
28
|
+
// DaaSecureKey. Verifier bytes come from DaaSecureRandom; the ephemeral
|
|
29
|
+
// flow key is DaaRegistrationFlowKey, cached here so the private key never
|
|
30
|
+
// crosses into JavaScript.
|
|
31
|
+
|
|
32
|
+
class DaaRegistrationModule : Module() {
|
|
33
|
+
private val flowKeys = ConcurrentHashMap<String, DaaRegistrationFlowKey>()
|
|
34
|
+
|
|
35
|
+
override fun definition() =
|
|
36
|
+
ModuleDefinition {
|
|
37
|
+
Name("DaaRegistration")
|
|
38
|
+
|
|
39
|
+
Function("randomBytes") { count: Int ->
|
|
40
|
+
runRegistration { unpaddedBase64Url(DaaSecureRandom.bytes(count)) }
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
Function("randomUuidV4") {
|
|
44
|
+
UUID.randomUUID().toString()
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
Function("generateRegistrationFlowKey") {
|
|
48
|
+
runRegistration {
|
|
49
|
+
val key = DaaRegistrationFlowKey.generate()
|
|
50
|
+
val id = UUID.randomUUID().toString()
|
|
51
|
+
flowKeys[id] = key
|
|
52
|
+
id
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
Function("registrationFlowPublicKeySpkiBase64Url") { id: String ->
|
|
57
|
+
runRegistration {
|
|
58
|
+
val key =
|
|
59
|
+
flowKeys[id]
|
|
60
|
+
?: throw RegistrationContractViolationException()
|
|
61
|
+
key.publicKeySpkiBase64Url()
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Drops the cached key so its private half is no longer reachable and
|
|
66
|
+
// becomes collectable. Without this the map grows by one P-256 private
|
|
67
|
+
// key per login attempt and never shrinks, which contradicts the point
|
|
68
|
+
// of generating the key natively: shortening how long key material is
|
|
69
|
+
// resident. Idempotent, and deliberately silent about an unknown id —
|
|
70
|
+
// release is cleanup, and a caller releasing twice (or in a `finally`
|
|
71
|
+
// after a failure) must not turn tidying up into an error.
|
|
72
|
+
Function("releaseRegistrationFlowKey") { id: String ->
|
|
73
|
+
flowKeys.remove(id)
|
|
74
|
+
Unit
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Typed native signRegistrationAuthorization — not a generic
|
|
78
|
+
// sign(bytes). The Base64URL payload is the exact Device
|
|
79
|
+
// Registration Complete flow-JWS signing input already built in
|
|
80
|
+
// TypeScript; native validates those bytes and signs that same
|
|
81
|
+
// slice. Synchronous and prompt-free: the flow key is in process
|
|
82
|
+
// memory, not the Keystore, so there is no biometric gate.
|
|
83
|
+
Function("signRegistrationAuthorization") { id: String, signingInputBase64Url: String ->
|
|
84
|
+
runRegistration {
|
|
85
|
+
val key = flowKeys[id] ?: throw RegistrationContractViolationException()
|
|
86
|
+
val signature =
|
|
87
|
+
key.signRegistrationAuthorization(
|
|
88
|
+
DaaRegistrationAuthorizationSigningInput(
|
|
89
|
+
decodeUnpaddedBase64Url(signingInputBase64Url),
|
|
90
|
+
),
|
|
91
|
+
)
|
|
92
|
+
unpaddedBase64Url(signature)
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
private fun <T> runRegistration(block: () -> T): T {
|
|
98
|
+
return try {
|
|
99
|
+
block()
|
|
100
|
+
} catch (error: Throwable) {
|
|
101
|
+
throw mappedRegistrationException(error)
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// Copyright (c) 2026, Circle Internet Group, Inc. 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
|
+
|
|
17
|
+
package com.circle.daa.reactnative
|
|
18
|
+
|
|
19
|
+
import com.circle.daa.sdk.sca.DaaScaError
|
|
20
|
+
import com.circle.daa.sdk.sca.DaaScaResult
|
|
21
|
+
import expo.modules.kotlin.exception.CodedException
|
|
22
|
+
|
|
23
|
+
// JS reads `error.code`. The codes match the iOS bridge exactly, so the
|
|
24
|
+
// TypeScript layer maps one vocabulary. A reason, where there is one, rides in
|
|
25
|
+
// the code as "<CODE>:<Reason>", which Expo passes through unchanged (the
|
|
26
|
+
// message may be wrapped). The message also starts with the code in brackets,
|
|
27
|
+
// matching iOS, where the rejection reaches JS without a code.
|
|
28
|
+
|
|
29
|
+
private fun tagged(code: String, message: String) = "[$code] $message"
|
|
30
|
+
|
|
31
|
+
internal class ScaCancelledException :
|
|
32
|
+
CodedException("SCA_CANCELLED", tagged("SCA_CANCELLED", "The ceremony was cancelled"), null)
|
|
33
|
+
|
|
34
|
+
internal class ScaFailedException(
|
|
35
|
+
code: String,
|
|
36
|
+
message: String,
|
|
37
|
+
) : CodedException(code, tagged(code, message), null)
|
|
38
|
+
|
|
39
|
+
internal class ScaInvalidConfigurationException(
|
|
40
|
+
message: String,
|
|
41
|
+
) : CodedException("SCA_INVALID_CONFIGURATION", tagged("SCA_INVALID_CONFIGURATION", message), null)
|
|
42
|
+
|
|
43
|
+
internal class ScaCeremonyInProgressException :
|
|
44
|
+
CodedException(
|
|
45
|
+
"SCA_CEREMONY_IN_PROGRESS",
|
|
46
|
+
tagged("SCA_CEREMONY_IN_PROGRESS", "Another SCA ceremony is still open"),
|
|
47
|
+
null,
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
internal fun mappedScaFailure(result: DaaScaResult.Failed): CodedException {
|
|
51
|
+
val message = result.message ?: result.error.name
|
|
52
|
+
return when (result.error) {
|
|
53
|
+
DaaScaError.Expired -> ScaFailedException("SCA_EXPIRED", message)
|
|
54
|
+
DaaScaError.Unsupported ->
|
|
55
|
+
ScaFailedException("SCA_UNSUPPORTED:${result.unsupportedReason?.name ?: "PasskeyUnavailable"}", message)
|
|
56
|
+
DaaScaError.AlreadyEnrolled -> ScaFailedException("SCA_ALREADY_ENROLLED", message)
|
|
57
|
+
DaaScaError.Protocol -> ScaFailedException("SCA_PROTOCOL", message)
|
|
58
|
+
DaaScaError.Transport -> ScaFailedException("SCA_TRANSPORT", message)
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
// Copyright (c) 2026, Circle Internet Group, Inc. 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
|
+
|
|
17
|
+
package com.circle.daa.reactnative
|
|
18
|
+
|
|
19
|
+
import androidx.activity.result.contract.ActivityResultContract
|
|
20
|
+
import com.circle.daa.sdk.DaaEnvironment
|
|
21
|
+
import com.circle.daa.sdk.sca.DaaSca
|
|
22
|
+
import com.circle.daa.sdk.sca.DaaScaApproveContract
|
|
23
|
+
import com.circle.daa.sdk.sca.DaaScaConfig
|
|
24
|
+
import com.circle.daa.sdk.sca.DaaScaEnrollContract
|
|
25
|
+
import com.circle.daa.sdk.sca.DaaScaResult
|
|
26
|
+
import expo.modules.kotlin.Promise
|
|
27
|
+
import expo.modules.kotlin.functions.Queues
|
|
28
|
+
import expo.modules.kotlin.modules.Module
|
|
29
|
+
import expo.modules.kotlin.modules.ModuleDefinition
|
|
30
|
+
import expo.modules.kotlin.records.Field
|
|
31
|
+
import expo.modules.kotlin.records.Record
|
|
32
|
+
|
|
33
|
+
// Thin bridge over daa-android-sdk's SCA contracts. No ceremony logic lives here:
|
|
34
|
+
// the native SDK opens the hosted page, validates the callback and returns the
|
|
35
|
+
// page's response text, which is passed to JS unchanged (the exact
|
|
36
|
+
// X-Sca-Assertion value for approve, the registration response JSON for enroll).
|
|
37
|
+
// The bridge only translates configuration, the activity result and errors.
|
|
38
|
+
|
|
39
|
+
internal class ScaConfigRecord : Record {
|
|
40
|
+
@Field val environment: String = ""
|
|
41
|
+
|
|
42
|
+
@Field val redirectUri: String = ""
|
|
43
|
+
|
|
44
|
+
@Field val circleOrigin: String? = null
|
|
45
|
+
|
|
46
|
+
@Field val approveTimeoutMs: Double? = null
|
|
47
|
+
|
|
48
|
+
@Field val enrollTimeoutMs: Double? = null
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
class DaaScaModule : Module() {
|
|
52
|
+
private class Pending(
|
|
53
|
+
val contract: ActivityResultContract<String, DaaScaResult>,
|
|
54
|
+
val promise: Promise,
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
// One ceremony at a time across the whole app. The native SDK ends an open
|
|
58
|
+
// ceremony when a second launch arrives; the bridge refuses the second call up
|
|
59
|
+
// front instead, so both platforms behave the same in JS. Main thread only.
|
|
60
|
+
private var pending: Pending? = null
|
|
61
|
+
|
|
62
|
+
override fun definition() =
|
|
63
|
+
ModuleDefinition {
|
|
64
|
+
Name("DaaSca")
|
|
65
|
+
|
|
66
|
+
AsyncFunction("capabilities") { config: ScaConfigRecord ->
|
|
67
|
+
val context = appContext.reactContext ?: throw ScaInvalidConfigurationException("No React context")
|
|
68
|
+
val capabilities = DaaSca.capabilities(context, scaConfig(config))
|
|
69
|
+
mapOf(
|
|
70
|
+
"protocolVersion" to capabilities.protocolVersion,
|
|
71
|
+
"surface" to capabilities.surface.name.replaceFirstChar { it.lowercase() },
|
|
72
|
+
"callbackReady" to capabilities.callbackRegistered,
|
|
73
|
+
"callbackVerified" to capabilities.callbackVerified,
|
|
74
|
+
"callbackTaskIsolated" to capabilities.callbackTaskIsolated,
|
|
75
|
+
"platformPasskeys" to capabilities.platformPasskeys,
|
|
76
|
+
)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
AsyncFunction("approve") { config: ScaConfigRecord, frameToken: String, promise: Promise ->
|
|
80
|
+
launch(promise, frameToken) { DaaScaApproveContract(scaConfig(config)) }
|
|
81
|
+
}.runOnQueue(Queues.MAIN)
|
|
82
|
+
|
|
83
|
+
AsyncFunction("enroll") { config: ScaConfigRecord, frameToken: String, promise: Promise ->
|
|
84
|
+
launch(promise, frameToken) { DaaScaEnrollContract(scaConfig(config)) }
|
|
85
|
+
}.runOnQueue(Queues.MAIN)
|
|
86
|
+
|
|
87
|
+
OnActivityResult { _, payload ->
|
|
88
|
+
if (payload.requestCode != REQUEST_CODE) return@OnActivityResult
|
|
89
|
+
val current = pending ?: return@OnActivityResult
|
|
90
|
+
pending = null
|
|
91
|
+
settle(current.promise, current.contract.parseResult(payload.resultCode, payload.data))
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
private fun launch(
|
|
96
|
+
promise: Promise,
|
|
97
|
+
frameToken: String,
|
|
98
|
+
contract: () -> ActivityResultContract<String, DaaScaResult>,
|
|
99
|
+
) {
|
|
100
|
+
if (pending != null) {
|
|
101
|
+
promise.reject(ScaCeremonyInProgressException())
|
|
102
|
+
return
|
|
103
|
+
}
|
|
104
|
+
val built =
|
|
105
|
+
try {
|
|
106
|
+
contract()
|
|
107
|
+
} catch (error: IllegalArgumentException) {
|
|
108
|
+
// A custom-scheme redirect URI for approve, or an invalid config.
|
|
109
|
+
promise.reject(ScaInvalidConfigurationException(error.message ?: "Invalid SCA configuration"))
|
|
110
|
+
return
|
|
111
|
+
} catch (error: ScaInvalidConfigurationException) {
|
|
112
|
+
promise.reject(error)
|
|
113
|
+
return
|
|
114
|
+
}
|
|
115
|
+
val activity = appContext.currentActivity
|
|
116
|
+
if (activity == null) {
|
|
117
|
+
promise.reject(ScaFailedException("SCA_UNSUPPORTED:SessionUnavailable", "No foreground activity"))
|
|
118
|
+
return
|
|
119
|
+
}
|
|
120
|
+
// Building the intent validates the frame token (blank or too long): a caller
|
|
121
|
+
// bug, reported like iOS, never as "unsupported".
|
|
122
|
+
val intent =
|
|
123
|
+
try {
|
|
124
|
+
built.createIntent(activity, frameToken)
|
|
125
|
+
} catch (error: IllegalArgumentException) {
|
|
126
|
+
val detail = error.message ?: "frameToken is invalid"
|
|
127
|
+
promise.reject(ScaFailedException("SCA_PROTOCOL:InvalidFrameToken", detail))
|
|
128
|
+
return
|
|
129
|
+
}
|
|
130
|
+
pending = Pending(built, promise)
|
|
131
|
+
try {
|
|
132
|
+
activity.startActivityForResult(intent, REQUEST_CODE)
|
|
133
|
+
} catch (error: RuntimeException) {
|
|
134
|
+
// OnActivityResult never fires for a ceremony that did not start, so the
|
|
135
|
+
// slot must be released here or every later call would be refused.
|
|
136
|
+
pending = null
|
|
137
|
+
val detail = error.message ?: "the ceremony could not start"
|
|
138
|
+
promise.reject(ScaFailedException("SCA_UNSUPPORTED:SessionUnavailable", detail))
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
private fun settle(
|
|
143
|
+
promise: Promise,
|
|
144
|
+
result: DaaScaResult,
|
|
145
|
+
) {
|
|
146
|
+
when (result) {
|
|
147
|
+
is DaaScaResult.Completed -> promise.resolve(result.response)
|
|
148
|
+
is DaaScaResult.Cancelled -> promise.reject(ScaCancelledException())
|
|
149
|
+
is DaaScaResult.Failed -> promise.reject(mappedScaFailure(result))
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
private companion object {
|
|
154
|
+
// Distinct from any request code the host app is likely to use.
|
|
155
|
+
const val REQUEST_CODE = 0x5CA1
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
private fun scaConfig(config: ScaConfigRecord): DaaScaConfig {
|
|
160
|
+
// Only the public environments; any other Circle host goes through
|
|
161
|
+
// `circleOrigin`, which the native configuration validates.
|
|
162
|
+
val environment =
|
|
163
|
+
when (config.environment) {
|
|
164
|
+
"sandbox" -> DaaEnvironment.Sandbox
|
|
165
|
+
"production" -> DaaEnvironment.Production
|
|
166
|
+
else -> throw ScaInvalidConfigurationException("environment must be 'sandbox' or 'production'")
|
|
167
|
+
}
|
|
168
|
+
return try {
|
|
169
|
+
DaaScaConfig(
|
|
170
|
+
environment = environment,
|
|
171
|
+
redirectUri = config.redirectUri,
|
|
172
|
+
circleOrigin = config.circleOrigin,
|
|
173
|
+
approveTimeoutMillis = config.approveTimeoutMs?.toLong() ?: DaaScaConfig.DEFAULT_APPROVE_TIMEOUT_MILLIS,
|
|
174
|
+
enrollTimeoutMillis = config.enrollTimeoutMs?.toLong() ?: DaaScaConfig.DEFAULT_ENROLL_TIMEOUT_MILLIS,
|
|
175
|
+
)
|
|
176
|
+
} catch (error: IllegalArgumentException) {
|
|
177
|
+
throw ScaInvalidConfigurationException(error.message ?: "Invalid SCA configuration")
|
|
178
|
+
}
|
|
179
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
// Copyright (c) 2026, Circle Internet Group, Inc. 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
|
+
|
|
17
|
+
package com.circle.daa.reactnative
|
|
18
|
+
|
|
19
|
+
import com.circle.daa.sdk.DaaSecureKeyError
|
|
20
|
+
import com.circle.daa.sdk.DaaSecureKeyException
|
|
21
|
+
import expo.modules.kotlin.exception.CodedException
|
|
22
|
+
|
|
23
|
+
internal class UserAuthRequiredException :
|
|
24
|
+
CodedException("USER_AUTH_REQUIRED", "User authentication is required", null)
|
|
25
|
+
|
|
26
|
+
// The user dismissed the BiometricPrompt. Kept distinct from
|
|
27
|
+
// USER_AUTH_REQUIRED: a cancel is the user's choice, not a credential problem,
|
|
28
|
+
// and the TypeScript side reports it as `user_cancelled`.
|
|
29
|
+
internal class UserCancelledException :
|
|
30
|
+
CodedException("USER_CANCELLED", "User authentication was cancelled", null)
|
|
31
|
+
|
|
32
|
+
internal class NotInitializedException :
|
|
33
|
+
CodedException("NOT_INITIALIZED", "Secure key is not initialized", null)
|
|
34
|
+
|
|
35
|
+
// No screen lock, or (StrongBiometricNotEnrolled) a screen lock but no
|
|
36
|
+
// fingerprint or face enrolled, so no device key can be created. The user
|
|
37
|
+
// fixes it in Settings; retrying does not help.
|
|
38
|
+
internal class DeviceLockNotSetException :
|
|
39
|
+
CodedException("DEVICE_LOCK_NOT_SET", "The device has no screen lock or biometric set up", null)
|
|
40
|
+
|
|
41
|
+
// Usually no hardware-backed keystore or biometric hardware, so this device can
|
|
42
|
+
// never hold a device key. daa-android-sdk 0.7.0 also reports
|
|
43
|
+
// SecureHardwareUnavailable for temporary failures (BIOMETRIC_ERROR_HW_UNAVAILABLE,
|
|
44
|
+
// a keystore ProviderException), so this is not always permanent.
|
|
45
|
+
internal class DeviceNotSupportedException :
|
|
46
|
+
CodedException("DEVICE_NOT_SUPPORTED", "Secure hardware is unavailable for this operation", null)
|
|
47
|
+
|
|
48
|
+
// Android invalidated the key, for example after a new fingerprint or face was
|
|
49
|
+
// enrolled, all were removed, or the screen lock was removed. The key cannot
|
|
50
|
+
// sign again. It stays in the keystore and nothing here can delete it, so a new
|
|
51
|
+
// key today needs a reinstall or cleared app data, then a new registration.
|
|
52
|
+
internal class KeyInvalidatedException :
|
|
53
|
+
CodedException("KEY_INVALIDATED", "The device key was invalidated and cannot be recovered", null)
|
|
54
|
+
|
|
55
|
+
// The typed matching code is not the code the approval body and code secret
|
|
56
|
+
// produce. Checked before the BiometricPrompt; the user can type it again.
|
|
57
|
+
internal class MatchingCodeMismatchException :
|
|
58
|
+
CodedException("MATCHING_CODE_MISMATCH", "The typed code is not the matching code", null)
|
|
59
|
+
|
|
60
|
+
internal class ContractViolationException(
|
|
61
|
+
message: String = "Native secure-key operation failed",
|
|
62
|
+
) : CodedException("CONTRACT_VIOLATION", message, null)
|
|
63
|
+
|
|
64
|
+
internal fun mappedSecureKeyException(error: Throwable): CodedException {
|
|
65
|
+
if (error is CodedException) {
|
|
66
|
+
return error
|
|
67
|
+
}
|
|
68
|
+
val keyError =
|
|
69
|
+
if (error is DaaSecureKeyException) {
|
|
70
|
+
error.error
|
|
71
|
+
} else {
|
|
72
|
+
return ContractViolationException()
|
|
73
|
+
}
|
|
74
|
+
return when (keyError) {
|
|
75
|
+
DaaSecureKeyError.UserCancelled -> UserCancelledException()
|
|
76
|
+
DaaSecureKeyError.AuthenticationFailed,
|
|
77
|
+
-> UserAuthRequiredException()
|
|
78
|
+
DaaSecureKeyError.DeviceCredentialNotSet,
|
|
79
|
+
DaaSecureKeyError.StrongBiometricNotEnrolled,
|
|
80
|
+
-> DeviceLockNotSetException()
|
|
81
|
+
DaaSecureKeyError.SecureHardwareUnavailable -> DeviceNotSupportedException()
|
|
82
|
+
DaaSecureKeyError.KeyInvalidated -> KeyInvalidatedException()
|
|
83
|
+
DaaSecureKeyError.KeyNotFound,
|
|
84
|
+
DaaSecureKeyError.ResolutionRequired,
|
|
85
|
+
-> NotInitializedException()
|
|
86
|
+
DaaSecureKeyError.MatchingCodeMismatch -> MatchingCodeMismatchException()
|
|
87
|
+
DaaSecureKeyError.InvalidAppId,
|
|
88
|
+
DaaSecureKeyError.InvalidSigningInput,
|
|
89
|
+
DaaSecureKeyError.AuthKeyRegistrationRequired,
|
|
90
|
+
DaaSecureKeyError.KeyCreationFailed,
|
|
91
|
+
DaaSecureKeyError.KeyAccessFailed,
|
|
92
|
+
DaaSecureKeyError.KeyMetadataUnavailable,
|
|
93
|
+
DaaSecureKeyError.KeyMetadataVersionUnsupported,
|
|
94
|
+
DaaSecureKeyError.ProtectionMismatch,
|
|
95
|
+
DaaSecureKeyError.ProtectionUnavailable,
|
|
96
|
+
DaaSecureKeyError.PublicKeyUnavailable,
|
|
97
|
+
DaaSecureKeyError.SigningAlgorithmUnavailable,
|
|
98
|
+
DaaSecureKeyError.SigningFailed,
|
|
99
|
+
DaaSecureKeyError.SigningInputExpired,
|
|
100
|
+
// Thrown when a registration device proof's header `jwk` is not the
|
|
101
|
+
// signing key's own (its RFC 7638 thumbprint differs). An upstream
|
|
102
|
+
// contract violation, not something to retry — the same mapping the
|
|
103
|
+
// Swift bridge gives `authKeyThumbprintMismatch`.
|
|
104
|
+
DaaSecureKeyError.AuthKeyThumbprintMismatch,
|
|
105
|
+
-> ContractViolationException()
|
|
106
|
+
}
|
|
107
|
+
}
|