@circle-fin/daa-react-native-sdk 0.0.0-stage → 0.4.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.
Files changed (304) hide show
  1. package/DaaReactNativeSdk.podspec +63 -0
  2. package/LICENSE +176 -0
  3. package/README.md +217 -2
  4. package/android/build.gradle +97 -0
  5. package/android/src/main/AndroidManifest.xml +1 -0
  6. package/android/src/main/java/com/circle/daa/reactnative/DaaRegistrationExceptions.kt +47 -0
  7. package/android/src/main/java/com/circle/daa/reactnative/DaaRegistrationModule.kt +121 -0
  8. package/android/src/main/java/com/circle/daa/reactnative/DaaScaExceptions.kt +60 -0
  9. package/android/src/main/java/com/circle/daa/reactnative/DaaScaModule.kt +179 -0
  10. package/android/src/main/java/com/circle/daa/reactnative/DaaSecureKeyExceptions.kt +73 -0
  11. package/android/src/main/java/com/circle/daa/reactnative/DaaSecureKeyModule.kt +185 -0
  12. package/android/src/main/java/com/circle/daa/reactnative/InstallationIdentityStore.kt +73 -0
  13. package/android/src/main/java/com/circle/daa/reactnative/UnpaddedBase64Url.kt +45 -0
  14. package/build/DaaClient.d.ts +57 -0
  15. package/build/DaaClient.js +158 -0
  16. package/build/api/AccountLimitsClient.d.ts +79 -0
  17. package/build/api/AccountLimitsClient.js +142 -0
  18. package/build/api/AccountsClient.d.ts +95 -0
  19. package/build/api/AccountsClient.js +276 -0
  20. package/build/api/AchFiatAccountsClient.d.ts +92 -0
  21. package/build/api/AchFiatAccountsClient.js +142 -0
  22. package/build/api/AuthClient.d.ts +120 -0
  23. package/build/api/AuthClient.js +257 -0
  24. package/build/api/DaaUserClient.d.ts +124 -0
  25. package/build/api/DaaUserClient.js +245 -0
  26. package/build/api/DepositAddressesClient.d.ts +112 -0
  27. package/build/api/DepositAddressesClient.js +222 -0
  28. package/build/api/DepositsClient.d.ts +106 -0
  29. package/build/api/DepositsClient.js +183 -0
  30. package/build/api/FiatAccountsClient.d.ts +43 -0
  31. package/build/api/FiatAccountsClient.js +46 -0
  32. package/build/api/TransactionsClient.d.ts +64 -0
  33. package/build/api/TransactionsClient.js +120 -0
  34. package/build/api/TransfersClient.d.ts +104 -0
  35. package/build/api/TransfersClient.js +321 -0
  36. package/build/api/WireFiatAccountsClient.d.ts +99 -0
  37. package/build/api/WireFiatAccountsClient.js +156 -0
  38. package/build/api/WithdrawalsClient.d.ts +94 -0
  39. package/build/api/WithdrawalsClient.js +305 -0
  40. package/build/api/loginFailure.d.ts +43 -0
  41. package/build/api/loginFailure.js +64 -0
  42. package/build/api/pagination.d.ts +29 -0
  43. package/build/api/pagination.js +50 -0
  44. package/build/api/queryParameters.d.ts +23 -0
  45. package/build/api/queryParameters.js +77 -0
  46. package/build/api/resourceRequest.d.ts +60 -0
  47. package/build/api/resourceRequest.js +79 -0
  48. package/build/api/signedResource.d.ts +77 -0
  49. package/build/api/signedResource.js +168 -0
  50. package/build/auth/RegistrationFlowKey.d.ts +93 -0
  51. package/build/auth/RegistrationFlowKey.js +203 -0
  52. package/build/auth/daaRegistrationNative.d.ts +80 -0
  53. package/build/auth/daaRegistrationNative.js +184 -0
  54. package/build/auth/deviceAuthorization.d.ts +73 -0
  55. package/build/auth/deviceAuthorization.js +243 -0
  56. package/build/auth/ownerGrant.d.ts +29 -0
  57. package/build/auth/ownerGrant.js +90 -0
  58. package/build/auth/prepareReceipt.d.ts +150 -0
  59. package/build/auth/prepareReceipt.js +357 -0
  60. package/build/auth/registrationAuthorization.d.ts +48 -0
  61. package/build/auth/registrationAuthorization.js +243 -0
  62. package/build/auth/registrationCodeVerifier.d.ts +31 -0
  63. package/build/auth/registrationCodeVerifier.js +75 -0
  64. package/build/config.d.ts +79 -0
  65. package/build/config.js +116 -0
  66. package/build/crypto/base64url.d.ts +26 -0
  67. package/build/crypto/base64url.js +87 -0
  68. package/build/crypto/bytes.d.ts +27 -0
  69. package/build/crypto/bytes.js +32 -0
  70. package/build/crypto/es256Jws.d.ts +56 -0
  71. package/build/crypto/es256Jws.js +196 -0
  72. package/build/crypto/jwkThumbprint.d.ts +32 -0
  73. package/build/crypto/jwkThumbprint.js +49 -0
  74. package/build/crypto/random.d.ts +35 -0
  75. package/build/crypto/random.js +106 -0
  76. package/build/crypto/serialization.d.ts +26 -0
  77. package/build/crypto/serialization.js +43 -0
  78. package/build/crypto/sha256.d.ts +18 -0
  79. package/build/crypto/sha256.js +100 -0
  80. package/build/errors.d.ts +190 -0
  81. package/build/errors.js +252 -0
  82. package/build/index.d.ts +61 -0
  83. package/build/index.js +67 -0
  84. package/build/models/Account.d.ts +201 -0
  85. package/build/models/Account.js +147 -0
  86. package/build/models/AccountLimitsUsage.d.ts +169 -0
  87. package/build/models/AccountLimitsUsage.js +86 -0
  88. package/build/models/Ach.d.ts +135 -0
  89. package/build/models/Ach.js +184 -0
  90. package/build/models/AddressObject.d.ts +128 -0
  91. package/build/models/AddressObject.js +141 -0
  92. package/build/models/BusinessPii.d.ts +84 -0
  93. package/build/models/BusinessPii.js +142 -0
  94. package/build/models/CreateAccountRequest.d.ts +74 -0
  95. package/build/models/CreateAccountRequest.js +19 -0
  96. package/build/models/CreateTransferRequest.d.ts +91 -0
  97. package/build/models/CreateTransferRequest.js +19 -0
  98. package/build/models/CreateWithdrawalRequest.d.ts +99 -0
  99. package/build/models/CreateWithdrawalRequest.js +19 -0
  100. package/build/models/DaaUserContext.d.ts +96 -0
  101. package/build/models/DaaUserContext.js +133 -0
  102. package/build/models/Deposit.d.ts +241 -0
  103. package/build/models/Deposit.js +149 -0
  104. package/build/models/DepositSummary.d.ts +91 -0
  105. package/build/models/DepositSummary.js +114 -0
  106. package/build/models/FiatAccount.d.ts +99 -0
  107. package/build/models/FiatAccount.js +151 -0
  108. package/build/models/GenerateAddressRequest.d.ts +67 -0
  109. package/build/models/GenerateAddressRequest.js +68 -0
  110. package/build/models/Money.d.ts +76 -0
  111. package/build/models/Money.js +99 -0
  112. package/build/models/Page.d.ts +33 -0
  113. package/build/models/Page.js +57 -0
  114. package/build/models/PendingDeviceRegistration.d.ts +90 -0
  115. package/build/models/PendingDeviceRegistration.js +180 -0
  116. package/build/models/PreparedSocialLogin.d.ts +155 -0
  117. package/build/models/PreparedSocialLogin.js +235 -0
  118. package/build/models/Transaction.d.ts +187 -0
  119. package/build/models/Transaction.js +134 -0
  120. package/build/models/Transfer.d.ts +335 -0
  121. package/build/models/Transfer.js +240 -0
  122. package/build/models/Wire.d.ts +213 -0
  123. package/build/models/Wire.js +264 -0
  124. package/build/models/Withdrawal.d.ts +201 -0
  125. package/build/models/Withdrawal.js +156 -0
  126. package/build/models/redaction.d.ts +18 -0
  127. package/build/models/redaction.js +23 -0
  128. package/build/sca/ScaClient.d.ts +105 -0
  129. package/build/sca/ScaClient.js +193 -0
  130. package/build/securekey/InMemorySecureKey.d.ts +23 -0
  131. package/build/securekey/InMemorySecureKey.js +127 -0
  132. package/build/securekey/NativeSecureKey.d.ts +24 -0
  133. package/build/securekey/NativeSecureKey.js +178 -0
  134. package/build/securekey/NativeSecureKeyBridge.d.ts +83 -0
  135. package/build/securekey/NativeSecureKeyBridge.js +19 -0
  136. package/build/securekey/SecureKey.d.ts +137 -0
  137. package/build/securekey/SecureKey.js +19 -0
  138. package/build/securekey/alias.d.ts +88 -0
  139. package/build/securekey/alias.js +175 -0
  140. package/build/securekey/ownerAuthKeyResolver.d.ts +56 -0
  141. package/build/securekey/ownerAuthKeyResolver.js +63 -0
  142. package/build/securekey/resolveNativeBridge.d.ts +30 -0
  143. package/build/securekey/resolveNativeBridge.js +120 -0
  144. package/build/testing.d.ts +18 -0
  145. package/build/testing.js +34 -0
  146. package/build/transport/DaaTransport.d.ts +35 -0
  147. package/build/transport/DaaTransport.js +19 -0
  148. package/build/transport/headers.d.ts +30 -0
  149. package/build/transport/headers.js +45 -0
  150. package/build/validation/requestBody.d.ts +27 -0
  151. package/build/validation/requestBody.js +56 -0
  152. package/build/validation/uuid.d.ts +25 -0
  153. package/build/validation/uuid.js +33 -0
  154. package/build/wire/accountLimitsUsagePayload.d.ts +30 -0
  155. package/build/wire/accountLimitsUsagePayload.js +130 -0
  156. package/build/wire/accountPayload.d.ts +36 -0
  157. package/build/wire/accountPayload.js +100 -0
  158. package/build/wire/achPayload.d.ts +24 -0
  159. package/build/wire/achPayload.js +82 -0
  160. package/build/wire/addressObjectPayload.d.ts +44 -0
  161. package/build/wire/addressObjectPayload.js +64 -0
  162. package/build/wire/daaStatusCodes.d.ts +64 -0
  163. package/build/wire/daaStatusCodes.js +69 -0
  164. package/build/wire/dataEnvelope.d.ts +40 -0
  165. package/build/wire/dataEnvelope.js +79 -0
  166. package/build/wire/depositPayload.d.ts +42 -0
  167. package/build/wire/depositPayload.js +159 -0
  168. package/build/wire/deviceContextPayload.d.ts +33 -0
  169. package/build/wire/deviceContextPayload.js +57 -0
  170. package/build/wire/deviceRegistrationResultPayload.d.ts +32 -0
  171. package/build/wire/deviceRegistrationResultPayload.js +128 -0
  172. package/build/wire/errorEnvelope.d.ts +43 -0
  173. package/build/wire/errorEnvelope.js +85 -0
  174. package/build/wire/fiatAccountPayload.d.ts +37 -0
  175. package/build/wire/fiatAccountPayload.js +93 -0
  176. package/build/wire/instant.d.ts +27 -0
  177. package/build/wire/instant.js +91 -0
  178. package/build/wire/jsonNumber.d.ts +30 -0
  179. package/build/wire/jsonNumber.js +34 -0
  180. package/build/wire/moneyPayload.d.ts +30 -0
  181. package/build/wire/moneyPayload.js +56 -0
  182. package/build/wire/paginationLinks.d.ts +28 -0
  183. package/build/wire/paginationLinks.js +167 -0
  184. package/build/wire/payload.d.ts +60 -0
  185. package/build/wire/payload.js +121 -0
  186. package/build/wire/pendingRegistrationPayload.d.ts +32 -0
  187. package/build/wire/pendingRegistrationPayload.js +54 -0
  188. package/build/wire/socialLoginRequestPayload.d.ts +31 -0
  189. package/build/wire/socialLoginRequestPayload.js +72 -0
  190. package/build/wire/transactionPayload.d.ts +31 -0
  191. package/build/wire/transactionPayload.js +126 -0
  192. package/build/wire/transferPayload.d.ts +43 -0
  193. package/build/wire/transferPayload.js +218 -0
  194. package/build/wire/wireEnums.d.ts +22 -0
  195. package/build/wire/wireEnums.js +69 -0
  196. package/build/wire/wirePayload.d.ts +29 -0
  197. package/build/wire/wirePayload.js +138 -0
  198. package/build/wire/withdrawalPayload.d.ts +27 -0
  199. package/build/wire/withdrawalPayload.js +179 -0
  200. package/expo-module.config.json +14 -0
  201. package/ios/DaaRegistrationExceptions.swift +58 -0
  202. package/ios/DaaRegistrationModule.swift +143 -0
  203. package/ios/DaaScaExceptions.swift +96 -0
  204. package/ios/DaaScaModule.swift +125 -0
  205. package/ios/DaaSecureKeyExceptions.swift +77 -0
  206. package/ios/DaaSecureKeyModule.swift +162 -0
  207. package/ios/InstallationIdentityStore.swift +126 -0
  208. package/ios/UnpaddedBase64URL.swift +42 -0
  209. package/package.json +114 -4
  210. package/src/DaaClient.ts +171 -0
  211. package/src/api/AccountLimitsClient.ts +146 -0
  212. package/src/api/AccountsClient.ts +305 -0
  213. package/src/api/AchFiatAccountsClient.ts +147 -0
  214. package/src/api/AuthClient.ts +331 -0
  215. package/src/api/DaaUserClient.ts +270 -0
  216. package/src/api/DepositAddressesClient.ts +239 -0
  217. package/src/api/DepositsClient.ts +208 -0
  218. package/src/api/FiatAccountsClient.ts +50 -0
  219. package/src/api/TransactionsClient.ts +137 -0
  220. package/src/api/TransfersClient.ts +361 -0
  221. package/src/api/WireFiatAccountsClient.ts +172 -0
  222. package/src/api/WithdrawalsClient.ts +339 -0
  223. package/src/api/loginFailure.ts +75 -0
  224. package/src/api/pagination.ts +63 -0
  225. package/src/api/queryParameters.ts +82 -0
  226. package/src/api/resourceRequest.ts +135 -0
  227. package/src/api/signedResource.ts +267 -0
  228. package/src/auth/RegistrationFlowKey.ts +274 -0
  229. package/src/auth/daaRegistrationNative.ts +236 -0
  230. package/src/auth/deviceAuthorization.ts +302 -0
  231. package/src/auth/ownerGrant.ts +102 -0
  232. package/src/auth/prepareReceipt.ts +522 -0
  233. package/src/auth/registrationAuthorization.ts +306 -0
  234. package/src/auth/registrationCodeVerifier.ts +76 -0
  235. package/src/config.ts +156 -0
  236. package/src/crypto/base64url.ts +88 -0
  237. package/src/crypto/bytes.ts +30 -0
  238. package/src/crypto/es256Jws.ts +240 -0
  239. package/src/crypto/jwkThumbprint.ts +65 -0
  240. package/src/crypto/random.ts +113 -0
  241. package/src/crypto/serialization.ts +42 -0
  242. package/src/crypto/sha256.ts +105 -0
  243. package/src/errors.ts +319 -0
  244. package/src/index.ts +223 -0
  245. package/src/models/Account.ts +264 -0
  246. package/src/models/AccountLimitsUsage.ts +192 -0
  247. package/src/models/Ach.ts +269 -0
  248. package/src/models/AddressObject.ts +169 -0
  249. package/src/models/BusinessPii.ts +154 -0
  250. package/src/models/CreateAccountRequest.ts +109 -0
  251. package/src/models/CreateTransferRequest.ts +114 -0
  252. package/src/models/CreateWithdrawalRequest.ts +120 -0
  253. package/src/models/DaaUserContext.ts +172 -0
  254. package/src/models/Deposit.ts +307 -0
  255. package/src/models/DepositSummary.ts +142 -0
  256. package/src/models/FiatAccount.ts +195 -0
  257. package/src/models/GenerateAddressRequest.ts +101 -0
  258. package/src/models/Money.ts +91 -0
  259. package/src/models/Page.ts +48 -0
  260. package/src/models/PendingDeviceRegistration.ts +197 -0
  261. package/src/models/PreparedSocialLogin.ts +287 -0
  262. package/src/models/Transaction.ts +247 -0
  263. package/src/models/Transfer.ts +459 -0
  264. package/src/models/Wire.ts +405 -0
  265. package/src/models/Withdrawal.ts +283 -0
  266. package/src/models/redaction.ts +22 -0
  267. package/src/sca/ScaClient.ts +289 -0
  268. package/src/securekey/InMemorySecureKey.ts +138 -0
  269. package/src/securekey/NativeSecureKey.ts +179 -0
  270. package/src/securekey/NativeSecureKeyBridge.ts +109 -0
  271. package/src/securekey/SecureKey.ts +149 -0
  272. package/src/securekey/alias.ts +204 -0
  273. package/src/securekey/ownerAuthKeyResolver.ts +96 -0
  274. package/src/securekey/resolveNativeBridge.ts +185 -0
  275. package/src/testing.ts +32 -0
  276. package/src/transport/DaaTransport.ts +42 -0
  277. package/src/transport/headers.ts +46 -0
  278. package/src/validation/requestBody.ts +60 -0
  279. package/src/validation/uuid.ts +31 -0
  280. package/src/wire/accountLimitsUsagePayload.ts +182 -0
  281. package/src/wire/accountPayload.ts +108 -0
  282. package/src/wire/achPayload.ts +98 -0
  283. package/src/wire/addressObjectPayload.ts +64 -0
  284. package/src/wire/daaStatusCodes.ts +69 -0
  285. package/src/wire/dataEnvelope.ts +80 -0
  286. package/src/wire/depositPayload.ts +186 -0
  287. package/src/wire/deviceContextPayload.ts +58 -0
  288. package/src/wire/deviceRegistrationResultPayload.ts +153 -0
  289. package/src/wire/errorEnvelope.ts +87 -0
  290. package/src/wire/fiatAccountPayload.ts +112 -0
  291. package/src/wire/instant.ts +93 -0
  292. package/src/wire/jsonNumber.ts +33 -0
  293. package/src/wire/moneyPayload.ts +55 -0
  294. package/src/wire/paginationLinks.ts +204 -0
  295. package/src/wire/payload.ts +146 -0
  296. package/src/wire/pendingRegistrationPayload.ts +75 -0
  297. package/src/wire/socialLoginRequestPayload.ts +89 -0
  298. package/src/wire/transactionPayload.ts +145 -0
  299. package/src/wire/transferPayload.ts +249 -0
  300. package/src/wire/wireEnums.ts +74 -0
  301. package/src/wire/wirePayload.ts +160 -0
  302. package/src/wire/withdrawalPayload.ts +219 -0
  303. package/testing.d.ts +19 -0
  304. package/testing.js +25 -0
@@ -0,0 +1,63 @@
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
+ require 'json'
18
+
19
+ package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
20
+
21
+ Pod::Spec.new do |s|
22
+ s.name = 'DaaReactNativeSdk'
23
+ s.version = package['version']
24
+ s.summary = package['description']
25
+ s.description = package['description']
26
+ s.license = package['license']
27
+ s.author = package['author']
28
+ s.homepage = package['homepage']
29
+ s.platforms = { :ios => '15.0' }
30
+ s.swift_version = '5.9'
31
+ s.source = { :git => 'https://github.com/circlefin/daa-react-native-sdk.git', :tag => "v#{s.version}" }
32
+ s.static_framework = true
33
+
34
+ s.dependency 'ExpoModulesCore'
35
+
36
+ # Expo module sources only. DaaSdk is the native iOS SDK (daa-ios-sdk),
37
+ # consumed as a published CocoaPods dependency rather than vendored at pack
38
+ # time. Integrators add the daa-ios-sdk spec-source repo to their Podfile
39
+ # `source` — see README.md.
40
+ # Pin the native SDK so dependency resolution is reproducible and updates are
41
+ # deliberate. 0.7.1 provides the APIs and behaviour this module relies on:
42
+ # it sets all of the Face ID / Touch ID prompt text itself from the validated
43
+ # operation, so signDeviceAuthorization and signRegistrationDeviceAuthorization
44
+ # take no caller prompt and DaaSecureKeyModule.swift passes none; it defaults
45
+ # the AuthKey Keychain group to the app's own application-identifier group
46
+ # (this module passes no keychainAccessGroup) and fails closed if that group
47
+ # cannot be resolved; its registration signer accepts the minimal
48
+ # device-proof claim set this package sends; it has the native SCA ceremony
49
+ # (`DaaSca`), which DaaScaModule.swift bridges and which also needs
50
+ # AuthenticationServices below; and it has DaaPrepareReceiptSignature,
51
+ # DaaSecureRandom, DaaRegistrationFlowKey, and
52
+ # DaaRegistrationFlowKeyError.invalidSigningInput, which
53
+ # DaaRegistrationModule.swift and DaaRegistrationExceptions.swift use.
54
+ s.source_files = 'ios/*.{h,m,mm,swift}'
55
+ s.dependency 'DaaSdk', '0.7.1'
56
+ s.frameworks = 'Security', 'LocalAuthentication', 'CryptoKit', 'AuthenticationServices'
57
+
58
+ s.pod_target_xcconfig = {
59
+ 'DEFINES_MODULE' => 'YES',
60
+ 'SWIFT_COMPILATION_MODE' => 'wholemodule',
61
+ 'OTHER_SWIFT_FLAGS' => '$(inherited) -enable-upcoming-feature StrictConcurrency'
62
+ }
63
+ end
package/LICENSE ADDED
@@ -0,0 +1,176 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
package/README.md CHANGED
@@ -1,3 +1,218 @@
1
- # Temporary Holding Version
1
+ # @circle-fin/daa-react-native-sdk
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ React Native SDK for **Digital Asset Accounts (DAA)** — attested authentication
4
+ and self-custody DAA API access.
5
+
6
+ Login is a three-call ceremony — Prepare, Social Session, Device Registration
7
+ Complete. Tests can finish the ceremony with `./testing`.
8
+
9
+ ## Features
10
+
11
+ - `DaaClient` + `DaaSdkConfiguration`, including the closed `keyPolicy`
12
+ (`DEVICE_KEY_POLICY`: hardware-backed, per-signature user verification).
13
+ - Injected `DaaTransport` boundary (`DaaHttpRequest` / `DaaHttpResponse`) — the
14
+ SDK never embeds a service credential.
15
+ - Deterministic **exact-byte** body serialization (serialize once, sign/send the
16
+ same immutable bytes).
17
+ - **Registered-device authorization**: compact ES256 JWS in
18
+ `X-Device-Authorization` (`authorizeExactRequest` / `postSignedResource`).
19
+ Not on the public `.` entry. Tests use the `./testing` in-memory store;
20
+ production `signExactBytes` reaches Expo `signDeviceAuthorization`. Account,
21
+ transfer, and withdrawal `create` are wired through it.
22
+ - The DAA **Owner-key** interfaces (P-256 / ES256) on the public entry. No
23
+ generic signing API. The concrete WebCrypto-backed in-memory **test double**
24
+ is exported only from the `./testing` subpath and fails closed in a React
25
+ Native release bundle.
26
+ - `DaaSdkError` model.
27
+ - Typed reads for accounts, account limits/usage, deposit addresses, deposits,
28
+ transfers, withdrawals, and wire/ACH fiat accounts (plus their receiving
29
+ instructions) behind `DaaUserClient`, plus unsigned deposit-address
30
+ create-or-resolve and the Owner-authorized `accounts.create` /
31
+ `transfers.create` / `withdrawals.create`.
32
+ All three signed creates take their request shape from the Owner-authorization
33
+ registry, reject a property it does not name before anything is signed, and
34
+ fail closed until the AuthKey carries Circle's registration acknowledgement.
35
+ Account, deposit-address, deposit, transfer, and withdrawal listings return
36
+ trusted pages: navigation accepts only same-origin links for the originating
37
+ collection and preserves the API's opaque query exactly.
38
+ `accountLimits.get(accountId, query?)` reads
39
+ `GET /v1/accounts/{accountId}/limits/usage`; the public API reference
40
+ ([list-account-limits-usage](https://developers.circle.com/api-reference/digital-asset-accounts/all/list-account-limits-usage))
41
+ is its contract. `usd_cents` and `count` values are returned
42
+ unconverted:
43
+
44
+ ```ts
45
+ const usage = await daaUserClient.accountLimits.get('1000662322', {
46
+ operation: 'withdrawal',
47
+ window: 'P30D',
48
+ })
49
+ for (const item of usage.items) {
50
+ console.log(item.operation.kind, item.effectiveThreshold, item.usagePercent)
51
+ }
52
+ ```
53
+
54
+ Response models are exported as **types only**: every instance a caller holds
55
+ came from a response the SDK decoded. Reached through `DaaClient.forUser(context)`,
56
+ which opens only for an `ACTIVE` `DaaUserContext` from Device Registration
57
+ Complete.
58
+
59
+ - `DaaUserClient.refreshContext()` and `.close()` — the lifecycle methods.
60
+ `refreshContext` is a signed `get_device_context` read
61
+ (`GET /v1/accounts/auth/context`), not an unsigned one: it carries a fresh
62
+ `X-Device-Authorization` over the empty body byte array and decodes the same
63
+ `DeviceContext` shape Device Registration Complete returns. This SDK holds
64
+ no retained context object and no cancellable in-flight work, so `close()`
65
+ refuses all further work through this instance: `refreshContext`,
66
+ every signed `create` on `accounts` / `transfers` / `withdrawals`, every
67
+ unsigned read, the unsigned `depositAddresses.create`, and `next()` /
68
+ `previous()` on a previously returned `Page` fail closed with
69
+ `contract_violation` afterward. A request already sent completes. The
70
+ registered AuthKey itself is untouched.
71
+ - `AuthClient.prepareSocialLogin` — the Prepare call. Mints a registration code
72
+ verifier and an ephemeral P-256 registration-flow key, then
73
+ `POST /v1/accounts/auth/loginRequests` with the S256 challenge and the flow
74
+ public key. It touches **no AuthKey**: AuthKey selection comes after the
75
+ Social Session response, so nothing at Prepare reads the secure-key store.
76
+ Returns a `PreparedSocialLogin` (`loginRequestId`, `oidcNonce`, `oidcState`,
77
+ `prepareReceiptJws`, `expiresAt`). No Prepare-receipt trust anchor is pinned
78
+ in this release, so the SDK ignores any receipt the service sends and login
79
+ proceeds as if none arrived (`prepareReceiptJws` is null). `oidcNonce` and
80
+ `oidcState` are therefore not authenticated by the SDK, and the receipt never
81
+ signs `oidcState`: bind the provider redirect with your app's own OAuth
82
+ `state`, and carry `oidcState` inside or next to it. `completeSocialSession` posts
83
+ `POST /v1/accounts/auth/sessions` and selects the AuthKey only after that
84
+ response. It takes the provider `idToken` **and** the `clientEntityId` of an
85
+ end user the application's own backend has already onboarded: the service
86
+ requires that field and Circle never creates the entity, so an application
87
+ onboards first and passes the id here.
88
+ `PendingDeviceRegistration.complete` sends Device Registration
89
+ Complete with `X-Registration-Flow-Authorization` and
90
+ `X-Device-Authorization` over the exact four-field body.
91
+
92
+ Prepare mints the verifier and flow key through the Expo `DaaRegistration`
93
+ module (`DaaSecureRandom` / `DaaRegistrationFlowKey` in the native SDKs), not
94
+ through `DaaSecureKey` and not through host WebCrypto. The same module checks
95
+ the receipt signature by delegating to the native SDKs'
96
+ `DaaPrepareReceiptSignature`. A React Native host missing that module fails
97
+ closed with `contract_violation` when minting, and a receipt it cannot verify
98
+ for want of the module is `prepare_receipt_invalid`.
99
+ Node tests inject a fake in `jest.setup.js`.
100
+
101
+ The Expo `DaaSecureKey` module (`ios/`, `android/`, `expo-module.config.json`)
102
+ delegates Owner AuthKey operations to the native SDKs, and
103
+ `resolveNativeBridge()` loads it via `requireOptionalNativeModule` — failing
104
+ closed in Node and Jest where no native module exists.
105
+ `X-Device-Authorization` is minted in TypeScript (`authorizeExactRequest`);
106
+ production `signExactBytes` reaches Expo `signDeviceAuthorization`.
107
+
108
+ ## Installing
109
+
110
+ ```
111
+ yarn add @circle-fin/daa-react-native-sdk
112
+ ```
113
+
114
+ ### The native SDKs are separate artifacts
115
+
116
+ This package bridges to two native SDKs published as coordinates rather than
117
+ vendoring them. The
118
+ tarball ships `DaaReactNativeSdk.podspec` and `android/build.gradle`, which only
119
+ _declare_ the native dependencies — installing from npm does not fetch them. The
120
+ host app's own CocoaPods and Gradle resolve them at build time.
121
+
122
+ **iOS.** `daa-ios-sdk` is a CocoaPods spec source, not published to the public
123
+ trunk. Add it alongside the CDN in your `Podfile`, then `pod install`:
124
+
125
+ ```ruby
126
+ source 'https://github.com/circlefin/daa-ios-sdk.git'
127
+ source 'https://cdn.cocoapods.org/'
128
+ ```
129
+
130
+ **Android.** `com.circle.daa:daa-android-sdk` is published to GitHub Packages,
131
+ which needs a GitHub token even for public packages. Add a `maven {}` block to
132
+ your app's root `build.gradle`, sourced from the environment so nothing is
133
+ committed:
134
+
135
+ ```gradle
136
+ allprojects {
137
+ repositories {
138
+ // ...your existing repositories
139
+ maven {
140
+ url System.getenv('DAA_ANDROID_MAVEN_URL')
141
+ credentials {
142
+ username System.getenv('DAA_ANDROID_MAVEN_USERNAME')
143
+ password System.getenv('DAA_ANDROID_MAVEN_PASSWORD')
144
+ }
145
+ }
146
+ }
147
+ }
148
+ ```
149
+
150
+ | Variable | Value |
151
+ | ---------------------------- | -------------------------------------------------------- |
152
+ | `DAA_ANDROID_MAVEN_URL` | `https://maven.pkg.github.com/circlefin/daa-android-sdk` |
153
+ | `DAA_ANDROID_MAVEN_USERNAME` | your GitHub username |
154
+ | `DAA_ANDROID_MAVEN_PASSWORD` | a GitHub PAT with `read:packages` scope |
155
+
156
+ ### Upgrading to `DaaSdk` 0.5.1 and `daa-android-sdk` 0.5.0
157
+
158
+ - **The biometric prompt text belongs to the native SDKs.** Face ID, Touch ID
159
+ and the Android BiometricPrompt show text that the native SDK sets from the
160
+ operation being signed, for example `Authorizing: transfer`. The text is
161
+ English only. Your app cannot set or change it.
162
+ - **iOS apps that share Keychain items may lose their AuthKey.** The AuthKey now
163
+ lives in your app's own application-identifier Keychain group
164
+ (`<App ID prefix>.<bundle identifier>`). Before, it lived in the first group
165
+ of your `keychain-access-groups` entitlement. If you use Keychain Sharing and
166
+ a shared group is first in that list, the SDK does not find the AuthKey that
167
+ an earlier version created. `resolveOrCreate` returns `"created"`, and the
168
+ device must register again. Apps without Keychain Sharing, and apps that list
169
+ their own group first, are not affected.
170
+ - **iOS fails closed when the AuthKey Keychain group cannot be resolved.** If
171
+ the SDK cannot resolve your app's own group, for example in a background
172
+ launch before the first unlock after boot, the call throws instead of running
173
+ an unscoped Keychain query. Nothing is cached, so a later call tries again.
174
+ - **Android needs an Auth Tab browser for a custom-scheme enrollment
175
+ redirect.** A custom-scheme `redirectUri` for `enroll` now runs only in an
176
+ Auth Tab. On a device with no allowed browser that offers one, `enroll`
177
+ rejects with a `ScaError` whose `code` is `Unsupported` and whose `reason` is
178
+ `InsecureRedirect`, and nothing opens. An `https` App Link is not affected,
179
+ and `approve` already refuses a custom scheme.
180
+
181
+ ## Layout
182
+
183
+ ```
184
+ src/
185
+ index.ts Public surface — `.` (types + client + serialization)
186
+ testing.ts `./testing` subpath — in-memory secure-key test double
187
+ DaaClient.ts Root client + configuration
188
+ api/ AuthClient, DaaUserClient + typed resource clients
189
+ auth/ Login-attempt material (registration-flow key, verifier, receipt)
190
+ models/ Typed account, page, address, deposit, transfer, withdrawal, fiat-account (wire/ACH), money, and prepared-login models
191
+ wire/ Response decoding: `data` envelope, payload mapping
192
+ transport/ Injected transport boundary
193
+ crypto/ Exact-byte serialization, Base64URL, SHA-256, JWK thumbprint, native-backed CSPRNG
194
+ securekey/ DAA Owner-key interfaces + in-memory & native-bridge stores
195
+ errors.ts DaaSdkError model + DaaError
196
+ DaaReactNativeSdk.podspec Declares the DaaSdk CocoaPods dependency
197
+ android/build.gradle Declares the com.circle.daa:daa-android-sdk dependency
198
+ ios/ Expo DaaSecureKey + DaaRegistration Swift modules
199
+ android/src/ Expo DaaSecureKey + DaaRegistration Kotlin modules
200
+ expo-module.config.json Expo autolinking
201
+ ```
202
+
203
+ ## Develop
204
+
205
+ ```bash
206
+ yarn install
207
+ yarn test # unit tests (jest + ts-jest)
208
+ yarn check:type # tsc --noEmit
209
+ ```
210
+
211
+ ## References
212
+
213
+ - Reporting a security vulnerability: [`SECURITY.md`](./SECURITY.md)
214
+ - Contributing: [`CONTRIBUTING.md`](./CONTRIBUTING.md)
215
+
216
+ ## License
217
+
218
+ [Apache License 2.0](LICENSE)
@@ -0,0 +1,97 @@
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.6.0 provides the APIs and behaviour this module relies
80
+ // on: it sets all of the BiometricPrompt text itself from the validated
81
+ // operation, so signDeviceAuthorization and
82
+ // signRegistrationDeviceAuthorization take the FragmentActivity directly
83
+ // and DaaSecureKeyModule.kt passes no prompt text; its registration signer
84
+ // accepts the minimal device-proof claim set this package sends; it has
85
+ // the native SCA ceremony (DaaScaApproveContract / DaaScaEnrollContract)
86
+ // with strict callback parsing, which DaaScaModule.kt bridges, and runs a
87
+ // custom-scheme enrollment redirect only in an Auth Tab (with no allowed
88
+ // Auth Tab browser the ceremony fails Unsupported(InsecureRedirect)); and
89
+ // it has DaaPrepareReceiptSignature, DaaSecureRandom, and
90
+ // DaaRegistrationFlowKey, which DaaRegistrationModule.kt calls. The SCA
91
+ // ceremony requires compileSdk 36 and AGP 8.9.1+ of every consumer
92
+ // (androidx.browser 1.9.0), hence the 36 defaults above.
93
+ api("com.circle.daa:daa-android-sdk:0.6.0")
94
+ // This module calls runBlocking. daa-android-sdk scopes coroutines as
95
+ // implementation, so it is not on this compile classpath transitively.
96
+ implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.2")
97
+ }
@@ -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
+ }