@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.
Files changed (337) hide show
  1. package/DaaReactNativeSdk.podspec +69 -0
  2. package/LICENSE +176 -0
  3. package/README.md +691 -2
  4. package/android/build.gradle +102 -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 +104 -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 +107 -0
  11. package/android/src/main/java/com/circle/daa/reactnative/DaaSecureKeyModule.kt +318 -0
  12. package/android/src/main/java/com/circle/daa/reactnative/InstallationIdentityStore.kt +122 -0
  13. package/android/src/main/java/com/circle/daa/reactnative/UnpaddedBase64Url.kt +45 -0
  14. package/build/DaaClient.d.ts +237 -0
  15. package/build/DaaClient.js +442 -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 +98 -0
  19. package/build/api/AccountsClient.js +279 -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 +95 -0
  23. package/build/api/AuthClient.js +221 -0
  24. package/build/api/ContractExecutionsClient.d.ts +114 -0
  25. package/build/api/ContractExecutionsClient.js +462 -0
  26. package/build/api/DaaUserClient.d.ts +187 -0
  27. package/build/api/DaaUserClient.js +312 -0
  28. package/build/api/DepositAddressesClient.d.ts +112 -0
  29. package/build/api/DepositAddressesClient.js +222 -0
  30. package/build/api/DepositsClient.d.ts +106 -0
  31. package/build/api/DepositsClient.js +183 -0
  32. package/build/api/FiatAccountsClient.d.ts +43 -0
  33. package/build/api/FiatAccountsClient.js +46 -0
  34. package/build/api/TransactionsClient.d.ts +64 -0
  35. package/build/api/TransactionsClient.js +121 -0
  36. package/build/api/TransfersClient.d.ts +107 -0
  37. package/build/api/TransfersClient.js +324 -0
  38. package/build/api/WireFiatAccountsClient.d.ts +99 -0
  39. package/build/api/WireFiatAccountsClient.js +156 -0
  40. package/build/api/WithdrawalsClient.d.ts +97 -0
  41. package/build/api/WithdrawalsClient.js +308 -0
  42. package/build/api/deviceApproval.d.ts +48 -0
  43. package/build/api/deviceApproval.js +247 -0
  44. package/build/api/deviceStatus.d.ts +61 -0
  45. package/build/api/deviceStatus.js +216 -0
  46. package/build/api/loginFailure.d.ts +51 -0
  47. package/build/api/loginFailure.js +95 -0
  48. package/build/api/pagination.d.ts +29 -0
  49. package/build/api/pagination.js +50 -0
  50. package/build/api/queryParameters.d.ts +23 -0
  51. package/build/api/queryParameters.js +77 -0
  52. package/build/api/resourceRequest.d.ts +60 -0
  53. package/build/api/resourceRequest.js +79 -0
  54. package/build/api/signedResource.d.ts +124 -0
  55. package/build/api/signedResource.js +267 -0
  56. package/build/auth/RegistrationFlowKey.d.ts +93 -0
  57. package/build/auth/RegistrationFlowKey.js +203 -0
  58. package/build/auth/daaRegistrationNative.d.ts +58 -0
  59. package/build/auth/daaRegistrationNative.js +158 -0
  60. package/build/auth/deviceAuthorization.d.ts +87 -0
  61. package/build/auth/deviceAuthorization.js +295 -0
  62. package/build/auth/ownerGrant.d.ts +29 -0
  63. package/build/auth/ownerGrant.js +90 -0
  64. package/build/auth/registrationAuthorization.d.ts +48 -0
  65. package/build/auth/registrationAuthorization.js +246 -0
  66. package/build/auth/registrationCodeVerifier.d.ts +31 -0
  67. package/build/auth/registrationCodeVerifier.js +75 -0
  68. package/build/config.d.ts +106 -0
  69. package/build/config.js +131 -0
  70. package/build/crypto/base64url.d.ts +26 -0
  71. package/build/crypto/base64url.js +87 -0
  72. package/build/crypto/bytes.d.ts +27 -0
  73. package/build/crypto/bytes.js +32 -0
  74. package/build/crypto/jwkThumbprint.d.ts +32 -0
  75. package/build/crypto/jwkThumbprint.js +49 -0
  76. package/build/crypto/matchingCode.d.ts +47 -0
  77. package/build/crypto/matchingCode.js +93 -0
  78. package/build/crypto/random.d.ts +35 -0
  79. package/build/crypto/random.js +106 -0
  80. package/build/crypto/serialization.d.ts +26 -0
  81. package/build/crypto/serialization.js +43 -0
  82. package/build/crypto/sha256.d.ts +18 -0
  83. package/build/crypto/sha256.js +100 -0
  84. package/build/errors.d.ts +307 -0
  85. package/build/errors.js +413 -0
  86. package/build/index.d.ts +69 -0
  87. package/build/index.js +67 -0
  88. package/build/models/Account.d.ts +201 -0
  89. package/build/models/Account.js +147 -0
  90. package/build/models/AccountLimitsUsage.d.ts +169 -0
  91. package/build/models/AccountLimitsUsage.js +86 -0
  92. package/build/models/Ach.d.ts +135 -0
  93. package/build/models/Ach.js +184 -0
  94. package/build/models/AddressObject.d.ts +128 -0
  95. package/build/models/AddressObject.js +141 -0
  96. package/build/models/BusinessPii.d.ts +84 -0
  97. package/build/models/BusinessPii.js +142 -0
  98. package/build/models/ContractExecution.d.ts +197 -0
  99. package/build/models/ContractExecution.js +130 -0
  100. package/build/models/CreateAccountRequest.d.ts +74 -0
  101. package/build/models/CreateAccountRequest.js +19 -0
  102. package/build/models/CreateContractExecutionRequest.d.ts +81 -0
  103. package/build/models/CreateContractExecutionRequest.js +19 -0
  104. package/build/models/CreateTransferRequest.d.ts +91 -0
  105. package/build/models/CreateTransferRequest.js +19 -0
  106. package/build/models/CreateWithdrawalRequest.d.ts +99 -0
  107. package/build/models/CreateWithdrawalRequest.js +19 -0
  108. package/build/models/DaaUserContext.d.ts +146 -0
  109. package/build/models/DaaUserContext.js +164 -0
  110. package/build/models/Deposit.d.ts +241 -0
  111. package/build/models/Deposit.js +149 -0
  112. package/build/models/DepositSummary.d.ts +91 -0
  113. package/build/models/DepositSummary.js +114 -0
  114. package/build/models/DeviceStatus.d.ts +69 -0
  115. package/build/models/DeviceStatus.js +19 -0
  116. package/build/models/FiatAccount.d.ts +99 -0
  117. package/build/models/FiatAccount.js +151 -0
  118. package/build/models/GenerateAddressRequest.d.ts +67 -0
  119. package/build/models/GenerateAddressRequest.js +68 -0
  120. package/build/models/Money.d.ts +76 -0
  121. package/build/models/Money.js +99 -0
  122. package/build/models/Page.d.ts +33 -0
  123. package/build/models/Page.js +57 -0
  124. package/build/models/PendingDeviceApproval.d.ts +121 -0
  125. package/build/models/PendingDeviceApproval.js +208 -0
  126. package/build/models/PendingDeviceRegistration.d.ts +229 -0
  127. package/build/models/PendingDeviceRegistration.js +636 -0
  128. package/build/models/PreparedContractExecution.d.ts +70 -0
  129. package/build/models/PreparedContractExecution.js +77 -0
  130. package/build/models/PreparedSocialLogin.d.ts +148 -0
  131. package/build/models/PreparedSocialLogin.js +252 -0
  132. package/build/models/Transaction.d.ts +233 -0
  133. package/build/models/Transaction.js +182 -0
  134. package/build/models/Transfer.d.ts +335 -0
  135. package/build/models/Transfer.js +240 -0
  136. package/build/models/Wire.d.ts +213 -0
  137. package/build/models/Wire.js +264 -0
  138. package/build/models/Withdrawal.d.ts +201 -0
  139. package/build/models/Withdrawal.js +156 -0
  140. package/build/models/codeSecrets.d.ts +100 -0
  141. package/build/models/codeSecrets.js +321 -0
  142. package/build/models/redaction.d.ts +18 -0
  143. package/build/models/redaction.js +23 -0
  144. package/build/sca/ScaClient.d.ts +105 -0
  145. package/build/sca/ScaClient.js +193 -0
  146. package/build/securekey/InMemorySecureKey.d.ts +25 -0
  147. package/build/securekey/InMemorySecureKey.js +168 -0
  148. package/build/securekey/NativeSecureKey.d.ts +26 -0
  149. package/build/securekey/NativeSecureKey.js +355 -0
  150. package/build/securekey/NativeSecureKeyBridge.d.ts +151 -0
  151. package/build/securekey/NativeSecureKeyBridge.js +19 -0
  152. package/build/securekey/SecureKey.d.ts +257 -0
  153. package/build/securekey/SecureKey.js +19 -0
  154. package/build/securekey/alias.d.ts +97 -0
  155. package/build/securekey/alias.js +184 -0
  156. package/build/securekey/ownerAuthKeyResolver.d.ts +73 -0
  157. package/build/securekey/ownerAuthKeyResolver.js +78 -0
  158. package/build/securekey/registration.d.ts +19 -0
  159. package/build/securekey/registration.js +38 -0
  160. package/build/securekey/resolveNativeBridge.d.ts +33 -0
  161. package/build/securekey/resolveNativeBridge.js +201 -0
  162. package/build/testing.d.ts +18 -0
  163. package/build/testing.js +34 -0
  164. package/build/transport/DaaTransport.d.ts +35 -0
  165. package/build/transport/DaaTransport.js +19 -0
  166. package/build/transport/headers.d.ts +41 -0
  167. package/build/transport/headers.js +81 -0
  168. package/build/validation/requestBody.d.ts +27 -0
  169. package/build/validation/requestBody.js +56 -0
  170. package/build/validation/uuid.d.ts +25 -0
  171. package/build/validation/uuid.js +33 -0
  172. package/build/wire/accountLimitsUsagePayload.d.ts +30 -0
  173. package/build/wire/accountLimitsUsagePayload.js +130 -0
  174. package/build/wire/accountPayload.d.ts +36 -0
  175. package/build/wire/accountPayload.js +100 -0
  176. package/build/wire/achPayload.d.ts +24 -0
  177. package/build/wire/achPayload.js +82 -0
  178. package/build/wire/addressObjectPayload.d.ts +44 -0
  179. package/build/wire/addressObjectPayload.js +64 -0
  180. package/build/wire/contractExecutionPayload.d.ts +24 -0
  181. package/build/wire/contractExecutionPayload.js +130 -0
  182. package/build/wire/daaStatusCodes.d.ts +81 -0
  183. package/build/wire/daaStatusCodes.js +86 -0
  184. package/build/wire/dataEnvelope.d.ts +40 -0
  185. package/build/wire/dataEnvelope.js +79 -0
  186. package/build/wire/depositPayload.d.ts +42 -0
  187. package/build/wire/depositPayload.js +159 -0
  188. package/build/wire/deviceContextPayload.d.ts +35 -0
  189. package/build/wire/deviceContextPayload.js +59 -0
  190. package/build/wire/deviceRegistrationResultPayload.d.ts +77 -0
  191. package/build/wire/deviceRegistrationResultPayload.js +162 -0
  192. package/build/wire/deviceStatusPayload.d.ts +20 -0
  193. package/build/wire/deviceStatusPayload.js +66 -0
  194. package/build/wire/errorEnvelope.d.ts +43 -0
  195. package/build/wire/errorEnvelope.js +85 -0
  196. package/build/wire/fiatAccountPayload.d.ts +37 -0
  197. package/build/wire/fiatAccountPayload.js +93 -0
  198. package/build/wire/instant.d.ts +27 -0
  199. package/build/wire/instant.js +94 -0
  200. package/build/wire/jsonNumber.d.ts +30 -0
  201. package/build/wire/jsonNumber.js +34 -0
  202. package/build/wire/moneyPayload.d.ts +30 -0
  203. package/build/wire/moneyPayload.js +56 -0
  204. package/build/wire/paginationLinks.d.ts +28 -0
  205. package/build/wire/paginationLinks.js +167 -0
  206. package/build/wire/payload.d.ts +60 -0
  207. package/build/wire/payload.js +121 -0
  208. package/build/wire/pendingRegistrationPayload.d.ts +48 -0
  209. package/build/wire/pendingRegistrationPayload.js +72 -0
  210. package/build/wire/socialLoginRequestPayload.d.ts +26 -0
  211. package/build/wire/socialLoginRequestPayload.js +55 -0
  212. package/build/wire/transactionPayload.d.ts +31 -0
  213. package/build/wire/transactionPayload.js +149 -0
  214. package/build/wire/transferPayload.d.ts +43 -0
  215. package/build/wire/transferPayload.js +218 -0
  216. package/build/wire/wireEnums.d.ts +22 -0
  217. package/build/wire/wireEnums.js +69 -0
  218. package/build/wire/wirePayload.d.ts +29 -0
  219. package/build/wire/wirePayload.js +138 -0
  220. package/build/wire/withdrawalPayload.d.ts +27 -0
  221. package/build/wire/withdrawalPayload.js +179 -0
  222. package/expo-module.config.json +14 -0
  223. package/ios/DaaRegistrationExceptions.swift +58 -0
  224. package/ios/DaaRegistrationModule.swift +125 -0
  225. package/ios/DaaScaExceptions.swift +96 -0
  226. package/ios/DaaScaModule.swift +125 -0
  227. package/ios/DaaSecureKeyExceptions.swift +125 -0
  228. package/ios/DaaSecureKeyModule.swift +306 -0
  229. package/ios/InstallationIdentityStore.swift +162 -0
  230. package/ios/UnpaddedBase64URL.swift +42 -0
  231. package/package.json +114 -4
  232. package/src/DaaClient.ts +509 -0
  233. package/src/api/AccountLimitsClient.ts +146 -0
  234. package/src/api/AccountsClient.ts +308 -0
  235. package/src/api/AchFiatAccountsClient.ts +147 -0
  236. package/src/api/AuthClient.ts +266 -0
  237. package/src/api/ContractExecutionsClient.ts +527 -0
  238. package/src/api/DaaUserClient.ts +345 -0
  239. package/src/api/DepositAddressesClient.ts +239 -0
  240. package/src/api/DepositsClient.ts +208 -0
  241. package/src/api/FiatAccountsClient.ts +50 -0
  242. package/src/api/TransactionsClient.ts +138 -0
  243. package/src/api/TransfersClient.ts +364 -0
  244. package/src/api/WireFiatAccountsClient.ts +172 -0
  245. package/src/api/WithdrawalsClient.ts +342 -0
  246. package/src/api/deviceApproval.ts +306 -0
  247. package/src/api/deviceStatus.ts +238 -0
  248. package/src/api/loginFailure.ts +112 -0
  249. package/src/api/pagination.ts +63 -0
  250. package/src/api/queryParameters.ts +82 -0
  251. package/src/api/resourceRequest.ts +135 -0
  252. package/src/api/signedResource.ts +427 -0
  253. package/src/auth/RegistrationFlowKey.ts +274 -0
  254. package/src/auth/daaRegistrationNative.ts +191 -0
  255. package/src/auth/deviceAuthorization.ts +365 -0
  256. package/src/auth/ownerGrant.ts +102 -0
  257. package/src/auth/registrationAuthorization.ts +309 -0
  258. package/src/auth/registrationCodeVerifier.ts +76 -0
  259. package/src/config.ts +192 -0
  260. package/src/crypto/base64url.ts +88 -0
  261. package/src/crypto/bytes.ts +30 -0
  262. package/src/crypto/jwkThumbprint.ts +65 -0
  263. package/src/crypto/matchingCode.ts +100 -0
  264. package/src/crypto/random.ts +113 -0
  265. package/src/crypto/serialization.ts +42 -0
  266. package/src/crypto/sha256.ts +105 -0
  267. package/src/errors.ts +576 -0
  268. package/src/index.ts +258 -0
  269. package/src/models/Account.ts +264 -0
  270. package/src/models/AccountLimitsUsage.ts +192 -0
  271. package/src/models/Ach.ts +269 -0
  272. package/src/models/AddressObject.ts +169 -0
  273. package/src/models/BusinessPii.ts +154 -0
  274. package/src/models/ContractExecution.ts +250 -0
  275. package/src/models/CreateAccountRequest.ts +109 -0
  276. package/src/models/CreateContractExecutionRequest.ts +100 -0
  277. package/src/models/CreateTransferRequest.ts +114 -0
  278. package/src/models/CreateWithdrawalRequest.ts +120 -0
  279. package/src/models/DaaUserContext.ts +228 -0
  280. package/src/models/Deposit.ts +307 -0
  281. package/src/models/DepositSummary.ts +142 -0
  282. package/src/models/DeviceStatus.ts +50 -0
  283. package/src/models/FiatAccount.ts +195 -0
  284. package/src/models/GenerateAddressRequest.ts +101 -0
  285. package/src/models/Money.ts +91 -0
  286. package/src/models/Page.ts +48 -0
  287. package/src/models/PendingDeviceApproval.ts +229 -0
  288. package/src/models/PendingDeviceRegistration.ts +791 -0
  289. package/src/models/PreparedContractExecution.ts +128 -0
  290. package/src/models/PreparedSocialLogin.ts +297 -0
  291. package/src/models/Transaction.ts +322 -0
  292. package/src/models/Transfer.ts +459 -0
  293. package/src/models/Wire.ts +405 -0
  294. package/src/models/Withdrawal.ts +283 -0
  295. package/src/models/codeSecrets.ts +360 -0
  296. package/src/models/redaction.ts +22 -0
  297. package/src/sca/ScaClient.ts +289 -0
  298. package/src/securekey/InMemorySecureKey.ts +192 -0
  299. package/src/securekey/NativeSecureKey.ts +388 -0
  300. package/src/securekey/NativeSecureKeyBridge.ts +189 -0
  301. package/src/securekey/SecureKey.ts +279 -0
  302. package/src/securekey/alias.ts +212 -0
  303. package/src/securekey/ownerAuthKeyResolver.ts +135 -0
  304. package/src/securekey/registration.ts +40 -0
  305. package/src/securekey/resolveNativeBridge.ts +343 -0
  306. package/src/testing.ts +32 -0
  307. package/src/transport/DaaTransport.ts +42 -0
  308. package/src/transport/headers.ts +93 -0
  309. package/src/validation/requestBody.ts +60 -0
  310. package/src/validation/uuid.ts +31 -0
  311. package/src/wire/accountLimitsUsagePayload.ts +182 -0
  312. package/src/wire/accountPayload.ts +108 -0
  313. package/src/wire/achPayload.ts +98 -0
  314. package/src/wire/addressObjectPayload.ts +64 -0
  315. package/src/wire/contractExecutionPayload.ts +152 -0
  316. package/src/wire/daaStatusCodes.ts +86 -0
  317. package/src/wire/dataEnvelope.ts +80 -0
  318. package/src/wire/depositPayload.ts +186 -0
  319. package/src/wire/deviceContextPayload.ts +60 -0
  320. package/src/wire/deviceRegistrationResultPayload.ts +211 -0
  321. package/src/wire/deviceStatusPayload.ts +68 -0
  322. package/src/wire/errorEnvelope.ts +87 -0
  323. package/src/wire/fiatAccountPayload.ts +112 -0
  324. package/src/wire/instant.ts +96 -0
  325. package/src/wire/jsonNumber.ts +33 -0
  326. package/src/wire/moneyPayload.ts +55 -0
  327. package/src/wire/paginationLinks.ts +204 -0
  328. package/src/wire/payload.ts +146 -0
  329. package/src/wire/pendingRegistrationPayload.ts +118 -0
  330. package/src/wire/socialLoginRequestPayload.ts +66 -0
  331. package/src/wire/transactionPayload.ts +181 -0
  332. package/src/wire/transferPayload.ts +249 -0
  333. package/src/wire/wireEnums.ts +74 -0
  334. package/src/wire/wirePayload.ts +160 -0
  335. package/src/wire/withdrawalPayload.ts +219 -0
  336. package/testing.d.ts +19 -0
  337. package/testing.js +25 -0
package/README.md CHANGED
@@ -1,3 +1,692 @@
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`, and contract execution `prepare`, are
22
+ wired through it.
23
+ - The DAA **Owner-key** interfaces (P-256 / ES256) on the public entry. No
24
+ generic signing API. The concrete WebCrypto-backed in-memory **test double**
25
+ is exported only from the `./testing` subpath and fails closed in a React
26
+ Native release bundle.
27
+ - `DaaSdkError` model.
28
+ - Typed reads for accounts, account limits/usage, deposit addresses, deposits,
29
+ transfers, withdrawals, self-custody contract executions, and wire/ACH fiat
30
+ accounts (plus their receiving instructions) behind `DaaUserClient`, plus unsigned deposit-address
31
+ create-or-resolve and the Owner-authorized `accounts.create` /
32
+ `transfers.create` / `withdrawals.create`, and self-custody contract
33
+ execution (`contractExecutions`, below).
34
+ Every signed create takes its request shape from the Owner-authorization
35
+ registry, rejects a property it does not name before anything is signed, and
36
+ fails closed until the AuthKey carries Circle's registration acknowledgement.
37
+ Account, deposit-address, deposit, transfer, and withdrawal listings return
38
+ trusted pages: navigation accepts only same-origin links for the originating
39
+ collection and preserves the API's opaque query exactly.
40
+ `accountLimits.get(accountId, query?)` reads
41
+ `GET /v1/accounts/{accountId}/limits/usage`; the public API reference
42
+ ([list-account-limits-usage](https://developers.circle.com/api-reference/digital-asset-accounts/all/list-account-limits-usage))
43
+ is its contract. `usd_cents` and `count` values are returned
44
+ unconverted:
45
+
46
+ ```ts
47
+ const usage = await daaUserClient.accountLimits.get('1000662322', {
48
+ operation: 'withdrawal',
49
+ window: 'P30D',
50
+ })
51
+ for (const item of usage.items) {
52
+ console.log(item.operation.kind, item.effectiveThreshold, item.usagePercent)
53
+ }
54
+ ```
55
+
56
+ Response models are exported as **types only**: every instance a caller holds
57
+ came from a response the SDK decoded. Reached through `DaaClient.forUser(context)`,
58
+ which opens only for an `ACTIVE` `DaaUserContext` from Device Registration
59
+ Complete.
60
+
61
+ - `contractExecutions` — Owner-authorized contract calls from a self-custody
62
+ account, in ABI mode (`abiFunctionSignature` + `abiParameters`, one value
63
+ per signature argument) or raw mode (`callData`), with an optional native
64
+ `amount`. There are no fee or gas options: DAA manages execution fees. A
65
+ create is two steps so that a retry is exact: `prepare` serializes the body
66
+ once and signs one authorization; `submit` sends that pair unchanged, and is
67
+ what to call again after a transport failure, a `429` or `5xx`, or a
68
+ restart (`toPersisted` / `restore`). DAA answers
69
+ an exact replay with the stored execution, even after the authorization has
70
+ expired. Never prepare the same intent again under a new idempotency key
71
+ after a failed submit: DAA may already have accepted the first. The one
72
+ exception is `clock_skew`, which means DAA refused the authorization because
73
+ the device clock was off when `prepare` signed it: correct the device time,
74
+ then prepare a new execution, as for an expired authorization. Poll `get`
75
+ for the outcome. Signing on a device needs `DaaSdk` 0.8.0 and
76
+ `daa-android-sdk` 0.7.0 or later (this package pins `DaaSdk` 0.9.0 and
77
+ `daa-android-sdk` 0.8.0); older native SDKs refuse the `contract_execution`
78
+ operation.
79
+
80
+ ```ts
81
+ // App-provided: newUuidV4() (React Native has no crypto.randomUUID),
82
+ // a durable `store`, `sleep(ms)`, and the `token` / `spender` addresses.
83
+ const prepared = await daaUserClient.contractExecutions.prepare({
84
+ idempotencyKey: newUuidV4(),
85
+ accountId,
86
+ blockchain: 'ETH',
87
+ contractAddress: token,
88
+ abiFunctionSignature: 'approve(address,uint256)',
89
+ abiParameters: [spender, '1000000'],
90
+ })
91
+ await store.save(prepared.toPersisted()) // survives a restart mid-request
92
+
93
+ let execution
94
+ for (;;) {
95
+ try {
96
+ execution = await daaUserClient.contractExecutions.submit(prepared)
97
+ break
98
+ } catch (err) {
99
+ const retryable = isDaaError(err) && 'retryable' in err.detail && err.detail.retryable
100
+ // Resubmitting this same prepared value is always safe: it sends identical
101
+ // bytes, so DAA returns the stored execution or refuses it again. That
102
+ // includes a contract_violation for a response the SDK could not read,
103
+ // which DAA may still have accepted. Never prepare the intent again.
104
+ if (!retryable) throw err
105
+ await sleep(2000) // resubmit the same prepared value, never a new key
106
+ }
107
+ }
108
+ while (execution.status.kind === 'pending') {
109
+ await sleep(2000)
110
+ execution = await daaUserClient.contractExecutions.get(execution.id)
111
+ }
112
+ await store.delete(prepared.idempotencyKey) // terminal: the record is done
113
+
114
+ if (execution.status.kind === 'failed') {
115
+ // authorization_failed / execution_denied: refused before signing, no hash.
116
+ // blockchain_error: included and reverted; transactionHash and networkFee
117
+ // are still reported.
118
+ console.log(execution.errorCode?.kind, execution.transactionHash, execution.networkFee)
119
+ }
120
+ ```
121
+
122
+ Account activity reports these as `type.kind === 'contract_execution'` rows
123
+ with a `contractExecution` summary (`id`, `blockchain`, `contractAddress`,
124
+ `functionSelector`); the full call is read with `get`.
125
+
126
+ - `DaaUserClient.refreshContext()` and `.close()` — the lifecycle methods.
127
+ `refreshContext` is a signed `get_device_context` read
128
+ (`GET /v1/accounts/auth/context`), not an unsigned one: it carries a fresh
129
+ `X-Device-Authorization` over the empty body byte array and decodes the same
130
+ `DeviceContext` that Device Registration Complete produces. This SDK holds
131
+ no retained context object and no cancellable in-flight work, so `close()`
132
+ refuses all further work through this instance: `refreshContext`,
133
+ every signed `create` on `accounts` / `transfers` / `withdrawals`,
134
+ `contractExecutions.prepare` and `submit`, every
135
+ unsigned read, the unsigned `depositAddresses.create`, and `next()` /
136
+ `previous()` on a previously returned `Page` fail closed with
137
+ `contract_violation` afterward. A request already sent completes. The
138
+ registered AuthKey itself is untouched.
139
+ - `DaaClient.restore({ clientEntityId })` and `DaaClient.forgetLocalKey({ clientEntityId })`
140
+ — session restore after an app restart, and the explicit local key delete.
141
+ See [Restoring a session](#restoring-a-session-after-an-app-restart).
142
+ - `DaaClient.getDeviceStatus({ authKeyId })` and `DaaClient.watchDeviceStatus({ authKeyId, onStatus, signal })`
143
+ — the add-a-device status of a new AuthKey waiting for approval. See
144
+ [Following an add-a-device request](#following-an-add-a-device-request).
145
+ - `AuthClient.prepareSocialLogin` — the Prepare call. Mints a registration code
146
+ verifier and an ephemeral P-256 registration-flow key, then
147
+ `POST /v1/accounts/auth/loginRequests` with the S256 challenge and the flow
148
+ public key. It touches **no AuthKey**: AuthKey selection comes after the
149
+ Social Session response, so nothing at Prepare reads the secure-key store.
150
+ Returns a `PreparedSocialLogin` (`loginRequestId`, `oidcNonce`, `oidcState`,
151
+ `expiresAt`). `oidcNonce` and `oidcState` are not authenticated by the SDK:
152
+ bind the provider redirect with your app's own OAuth `state`, and carry
153
+ `oidcState` inside or next to it. `completeSocialSession` posts
154
+ `POST /v1/accounts/auth/sessions` and selects the AuthKey only after that
155
+ response. It takes the provider `idToken` **and** the `clientEntityId` of an
156
+ end user the application's own backend has already onboarded: the service
157
+ requires that field and Circle never creates the entity, so an application
158
+ onboards first and passes the id here.
159
+ `PendingDeviceRegistration.complete` sends Device Registration
160
+ Complete (`POST /v1/accounts/auth/keys`, `type: "deviceKey"`) with
161
+ `X-Registration-Flow-Authorization` and
162
+ `X-Device-Authorization` over the exact body bytes, with `codeSeal` when
163
+ `addDeviceApproval` is on (see [Adding a device](#adding-a-device)).
164
+
165
+ ### Adding a device
166
+
167
+ Adding a device is off by default: set `addDeviceApproval: true` in the
168
+ `DaaClient` configuration to turn it on. The switch is temporary and becomes
169
+ the default once every DAA environment runs enclave 0.1.93 and returns the
170
+ request's `codeSeal`.
171
+
172
+ **Keep it off in production for now.** If the app restarts after it sent the
173
+ code secret, signing in again returns that request, sealed with a secret the
174
+ app no longer has (see below). This SDK reports that code as unavailable, but
175
+ only when DAA's `pending_approval` answer carries the request's `codeSeal`;
176
+ without it, the app would show a code that can't match. Turn it on in this
177
+ order for each environment:
178
+
179
+ 1. DAA runs enclave 0.1.93 or later and returns `codeSeal` with
180
+ `pending_approval`. Older enclaves refuse the `codeSeal` the switch adds to
181
+ every registration, first devices included.
182
+ 2. Turn on `addDeviceApproval`. Until DAA turns on device approval, the seal is
183
+ ignored and every device still comes back `ACTIVE`.
184
+ 3. DAA turns on device approval. From then on, DAA refuses a new device on an
185
+ existing account whose registration has no `codeSeal`, so an app with the
186
+ switch off can't add a second device there (the error arrives as `api`).
187
+
188
+ With it on, the SDK asks before it creates a key on a new device. When DAA
189
+ says a new device would wait for approval (the Session's `deviceApproval`) and
190
+ this device has no key Circle registered for the end user,
191
+ `completeSocialSession` creates no key and returns `confirmationRequired: true`.
192
+ Ask the user whether to add this device, and call `complete()` with
193
+ `confirmAddDevice: true` only if they confirm. If they don't, call
194
+ `prepared.abandon()` (the `PreparedSocialLogin` this sign-in started from):
195
+ nothing was created or sent, but dropping `pending` alone keeps this sign-in's
196
+ native flow key until the app exits.
197
+
198
+ A key that is waiting for approval isn't registered on the device yet, and
199
+ the SDK can't tell it from no key without creating one, so it reports
200
+ `confirmationRequired` for it too. Save the waiting request's `authKeyId` when
201
+ `complete()` returns `PENDING_APPROVAL` (you need it to follow the request
202
+ anyway), and check it before asking:
203
+
204
+ ```ts
205
+ const pending = await prepared.completeSocialSession({ idToken, clientEntityId })
206
+ if (pending.confirmationRequired && !(await isWaitingForApproval(appUserId))) {
207
+ if (pending.deviceApproval?.hasActiveDevice === false) {
208
+ // None of the user's devices can approve this one now (for example, they
209
+ // are all in their cool-down), so DAA would refuse a new key with
210
+ // device_approval_unavailable. Tell the user; don't offer to add it.
211
+ await prepared.abandon()
212
+ return showNoDeviceCanApprove()
213
+ }
214
+ if (!(await askAddThisDevice())) {
215
+ await prepared.abandon()
216
+ return
217
+ }
218
+ }
219
+ // A waiting request resumes without asking: DAA returns it, with the same code.
220
+ const result = await pending.complete({ confirmAddDevice: true })
221
+
222
+ async function isWaitingForApproval(appUserId: string): Promise<boolean> {
223
+ // Saved as `daa.pendingRequest.<appUserId>` when complete() returned
224
+ // PENDING_APPROVAL.
225
+ const saved = await appStorage.get(`daa.pendingRequest.${appUserId}`)
226
+ if (saved === undefined) return false
227
+ const status = await client.getDeviceStatus({ authKeyId: saved.authKeyId })
228
+ return status.status === 'pending_approval'
229
+ }
230
+ ```
231
+
232
+ `confirmAddDevice` is ignored when `confirmationRequired` is `false`, so the
233
+ same `complete()` call works for every device. Without it when
234
+ `confirmationRequired` is `true`, `complete()` throws `contract_violation` and
235
+ nothing is created or sent.
236
+
237
+ What a sign-in does with the key already on the device:
238
+
239
+ | Key on this device | Ask the user | `complete()` |
240
+ | ------------------------------------------------------------ | ------------------------------------------ | ---------------------------------------------------------------------------------------------------------- |
241
+ | None | Yes | Creates key B. `PENDING_APPROVAL`, or `ACTIVE` where DAA doesn't add keys as waiting yet |
242
+ | None, and `hasActiveDevice` is `false` | No: tell them no device can approve it now | Usually `device_approval_unavailable` (`api` 409 `420080` for an account with a passkey) |
243
+ | Active | No (`confirmationRequired` is `false`) | `ACTIVE` |
244
+ | Approved, in its cool-down | No (`confirmationRequired` is `false`) | `PENDING_ACTIVATION` (see [Signing in again during the cool-down](#signing-in-again-during-the-cool-down)) |
245
+ | Waiting for approval (`getDeviceStatus`: `pending_approval`) | No: resume | The same request, `PENDING_APPROVAL` with the same code |
246
+ | Request expired or cancelled | Yes | A new request for the same key, `PENDING_APPROVAL` |
247
+ | Declined with Not me (`denied`) | Ask whether to start over | `device_denied` until the app calls `forgetLocalKey` (see below) |
248
+
249
+ `deviceApproval` is a hint read when the Session was answered, not the
250
+ outcome: `complete()` returns whatever DAA decides.
251
+
252
+ If creating the key fails after the user confirmed (for example
253
+ `device_lock_not_set` when the phone has no passcode), `complete()` throws that
254
+ error and this registration is used up: sign in again once the user fixed it.
255
+
256
+ When `complete()` returns `status: 'PENDING_APPROVAL'`:
257
+
258
+ 1. Call `await pendingApproval.sendCodeSecret()`. DAA then sends the
259
+ `account.device.pending` webhook, so your backend can prompt the other
260
+ device. On a retryable error (`transport`, or `api` with `429`/`5xx`) call it
261
+ again: DAA accepts the same secret again and re-sends the webhook. A
262
+ `contract_violation` means this `pendingApproval` is no longer the key's
263
+ latest request and nothing was sent: use the `pendingApproval` of the later
264
+ sign-in, or, if that sign-in failed or got no answer, sign in again.
265
+ `matching_code_unavailable` means this device can't show the code for this
266
+ request and nothing was sent (see below).
267
+ 2. Show `pendingApproval.getMatchingCode()` on this device (as `482 913`) and
268
+ tell the user to approve on their other device, where they type the code.
269
+ This device's key can't sign until then, and the request expires at
270
+ `pendingApproval.expiresAt`.
271
+ 3. Follow the request with `client.watchDeviceStatus` until it ends (see
272
+ [Following an add-a-device request](#following-an-add-a-device-request)).
273
+
274
+ If registration fails with `device_denied`, the user declined this device with
275
+ Not me, and this key can't ask again. As with a `denied` status, ask the user
276
+ whether to start over; only if they confirm, call `forgetLocalKey` and sign in
277
+ again with a new key. The SDK never deletes the key itself.
278
+
279
+ The code secret is kept with the device key (Keychain on iOS, Keystore on
280
+ Android) until it is sent. If the user signs in again before `expiresAt`, in
281
+ the same app session or after a restart, DAA returns the same request and
282
+ `getMatchingCode()` returns the same code. `sendCodeSecret()` deletes the
283
+ secret from that storage before it sends it, so it is never sealed into
284
+ another request, and keeps it in memory only. So after a restart that follows
285
+ the send, DAA still returns the same request, sealed with the sent secret, and
286
+ no code this device shows could match: `getMatchingCode()` and
287
+ `sendCodeSecret()` throw `matching_code_unavailable` and nothing is sent. Tell
288
+ the user to wait until `pendingApproval.expiresAt` and sign in again, which
289
+ opens a new request this device can show the code for.
290
+
291
+ Registration can also fail with `device_registration_limit` (too many
292
+ add-a-device requests recently; `retryAfterSeconds` when DAA sends it),
293
+ `device_denied` (the user declined this device with Not me),
294
+ `device_approval_conflict` (another new device was waiting, so both must sign
295
+ in again) or `device_approval_unavailable` (no active device can approve this
296
+ one). A `complete()` that takes longer than two minutes, prompt and transport
297
+ included, fails with `transport` (`retryable: false`), so a transport that
298
+ never answers can't hold the next sign-in with the same key.
299
+
300
+ ### Signing in again during the cool-down
301
+
302
+ After the user approves a device, the account has a cool-down before that
303
+ device may sign. If the user signs in on it again before then, `complete()`
304
+ returns `status: 'PENDING_ACTIVATION'` with the key's `authKeyId` and
305
+ `readyAt`, and no context: nothing can sign before `readyAt`. The SDK stores
306
+ the key's identifiers, so once the cool-down ends one `restore` gets the
307
+ context without another login.
308
+
309
+ There is no context to read `clientEntityId` from, so store
310
+ `pending.clientEntityId` (the `PendingDeviceRegistration` you called
311
+ `complete()` on) as you would `context.clientEntityId`, and store `authKeyId`
312
+ and `readyAt` too:
313
+
314
+ ```ts
315
+ if (result.status === 'PENDING_ACTIVATION') {
316
+ await appStorage.set(`daa.clientEntityId.${appUserId}`, pending.clientEntityId)
317
+ await appStorage.set(`daa.coolDown.${appUserId}`, {
318
+ authKeyId: result.authKeyId,
319
+ readyAt: result.readyAt,
320
+ })
321
+ // Show "This device is ready at <readyAt>".
322
+ const status = await client.watchDeviceStatus({ authKeyId: result.authKeyId, signal })
323
+ if (status.status === 'active') {
324
+ const restored = await client.restore({ clientEntityId: pending.clientEntityId })
325
+ }
326
+ // Any other status: the key won't become active. Don't call restore.
327
+ }
328
+ ```
329
+
330
+ After an app restart before `readyAt`, don't call `restore` yet: it shows the
331
+ authentication prompt and fails with `device_pending`. Wait until `readyAt`,
332
+ or until `client.getDeviceStatus({ authKeyId })` is `active`, then call it.
333
+
334
+ ### Approving a new device
335
+
336
+ On the user's existing device, when your backend pushes the
337
+ `account.device.pending` webhook's `requestId`, show a screen where the user
338
+ types the code the new device shows, then:
339
+
340
+ ```ts
341
+ const status = await user.approveDevice({ requestId, typedCode })
342
+ // status.status === 'pending_activation' until status.readyAt
343
+ ```
344
+
345
+ The SDK reads the request from the device list
346
+ (`GET /v1/accounts/auth/devices`), checks the typed code (spaces and dashes are
347
+ ignored), and only then asks for Face ID or the fingerprint, whose prompt shows
348
+ the code. It fails with `matching_code_mismatch` when the code is wrong (nothing
349
+ was signed; let the user type it again), `device_approval_not_ready` when the
350
+ new device hasn't sent its code secret yet (try again in a few seconds),
351
+ `device_approval_invalid` when the request is no longer waiting (expired,
352
+ decided on another device, or cancelled), `device_approval_busy` when the
353
+ account changed meanwhile (call it again; the user sees the prompt again), and
354
+ `user_cancelled` when the user dismisses the prompt (the request keeps
355
+ waiting).
356
+
357
+ After a `transport` failure, a retryable `api` error, a `401` (once your
358
+ credentials are refreshed) or a `contract_violation`, call `approveDevice`
359
+ again on the same `DaaUserClient` with the same `requestId`. It signs the same
360
+ approval body again, so the user sees the prompt again, and DAA returns its
361
+ saved result if the first call went through. Another `4xx` is DAA refusing the
362
+ approval, and calling again gets the same answer. Calling it with a new client
363
+ after a restart reads the device list, where an approved request is gone, so it
364
+ fails with `device_approval_invalid`;
365
+ check the device list for the new device instead. After
366
+ `device_approval_busy`, calling again also re-signs the same body: DAA saved
367
+ nothing for it, so it runs the approval again. Wait for one call to finish
368
+ before calling again for the same request; two calls at once each show the
369
+ prompt.
370
+
371
+ ### When saving the registration fails
372
+
373
+ After DAA answers `ACTIVE` (or `PENDING_ACTIVATION`), `complete()` saves the
374
+ `authKeyId` and `ownerBindingId` it returned next to the key on the device. If
375
+ that save fails (for example a Keychain or Keystore write error), or doesn't
376
+ finish within the two-minute deadline, `complete()` throws
377
+ `registration_not_saved` (`transport` for the deadline). The device is
378
+ registered with Circle, but until the save succeeds, session restore can't find
379
+ the key and a new login with it is refused. Call `complete()` on the same
380
+ `PendingDeviceRegistration` again: it sends nothing, retries only the save, and
381
+ on success returns the same result. Don't start a new login and don't delete
382
+ the key for this error. If the user signed in again with the same key and that
383
+ newer registration answered first, the retry throws `contract_violation` and
384
+ saves nothing: use the newer result.
385
+ If the save that missed the deadline finished on its own before the retry, the
386
+ retry throws `contract_violation` ("already been consumed"): the identifiers
387
+ are saved, so don't delete the key; `DaaClient.restore` finds it.
388
+
389
+ If the save fails because the key is gone (`key_invalidated`, or
390
+ `device_not_initialized` when it is no longer on the device), `complete()`
391
+ throws that kind instead and keeps nothing to retry: handle it as that kind
392
+ says. If the app deleted the key (`forgetLocalKey`) and signed in again with a
393
+ new one, the retry throws `contract_violation` and saves nothing. Any other
394
+ failure of the save, including one the user can fix such as a missing screen
395
+ lock, comes as `registration_not_saved` with the native kind on `cause`.
396
+
397
+ Prepare mints the verifier and flow key through the Expo `DaaRegistration`
398
+ module (`DaaSecureRandom` / `DaaRegistrationFlowKey` in the native SDKs), not
399
+ through `DaaSecureKey` and not through host WebCrypto. A React Native host
400
+ missing that module fails closed with `contract_violation` when minting.
401
+ Node tests inject a fake in `jest.setup.js`.
402
+
403
+ The Expo `DaaSecureKey` module (`ios/`, `android/`, `expo-module.config.json`)
404
+ delegates Owner AuthKey operations to the native SDKs, and
405
+ `resolveNativeBridge()` loads it via `requireOptionalNativeModule` — failing
406
+ closed in Node and Jest where no native module exists.
407
+ `X-Device-Authorization` is minted in TypeScript (`authorizeExactRequest`);
408
+ production `signExactBytes` reaches Expo `signDeviceAuthorization`.
409
+
410
+ ### Following an add-a-device request
411
+
412
+ When DAA adds a new device's AuthKey as waiting for approval on an existing
413
+ device, follow the request with its `authKeyId`:
414
+
415
+ ```ts
416
+ const outcome = await client.watchDeviceStatus({ authKeyId, onStatus, signal })
417
+ ```
418
+
419
+ `watchDeviceStatus` reads `GET /v1/accounts/auth/devices/{authKeyId}` every
420
+ 5 s and resolves with `active`, `denied`, `expired` or `cancelled` (DAA reports
421
+ `expired` itself once the request's `expiresAt` passes). `pending_activation`
422
+ means approved but in the account's cool-down until `readyAt`; the watch keeps
423
+ going until `active`. A status this SDK version doesn't know resolves as
424
+ `unrecognized`: don't act on the key. Run one watch per `authKeyId`: pass a
425
+ `signal` and abort it when the user leaves the screen, so a screen that is
426
+ opened again doesn't leave the old watch reading too. Save `authKeyId` so that after a restart one
427
+ `client.getDeviceStatus({ authKeyId })` tells you where the request stands.
428
+
429
+ If the status is `denied`, the user declined this device with Not me, and
430
+ this key can't ask again. Ask the user whether to start over; only if they
431
+ confirm, call `forgetLocalKey` and sign in again with a new key. The SDK never
432
+ deletes the key itself, and no other status is a reason to.
433
+
434
+ ## Restoring a session after an app restart
435
+
436
+ `DaaUserContext` lives in memory only. After a restart, restore it from the
437
+ AuthKey this device already registered — one biometric or device-credential
438
+ prompt, no new social login:
439
+
440
+ ```ts
441
+ // Stored by the app, keyed by its own user id, when that user last completed
442
+ // login: `result.context.clientEntityId`.
443
+ const clientEntityId = await appStorage.get(`daa.clientEntityId.${appUserId}`)
444
+
445
+ const restored = await daa.restore({ clientEntityId })
446
+ if (restored.status === 'ACTIVE') {
447
+ const user = daa.forUser(restored.context)
448
+ // ...
449
+ } else {
450
+ // 'no_local_key': no registered key on this device for that user. Offer
451
+ // sign-in (auth.prepareSocialLogin) when the user chooses it.
452
+ }
453
+ ```
454
+
455
+ `restore` reads the stored registration without creating a key, signs one
456
+ `GET /v1/accounts/auth/context` with it, and returns an `ACTIVE` context only if
457
+ Circle confirms the same AuthKey. Run it while the app is in the foreground: iOS
458
+ cannot show the authentication prompt during a background launch.
459
+
460
+ Rules for the app:
461
+
462
+ 1. **Never fall back automatically.** A thrown error from `restore` is an error,
463
+ not "no key". Do not start a social login in response to it, and never
464
+ delete the key automatically. Only the `no_local_key` result means there is
465
+ nothing to restore.
466
+ 2. **Handle credential rejection on every signed write**, not only on restore.
467
+ A rejected device authorization (`contract_violation`) can come from
468
+ `restore`, `refreshContext`, or any signed
469
+ `create`. Surface it to the user; do not delete the key or re-enroll
470
+ automatically.
471
+ 3. **For a `contract_violation` from `restore`, keep the key and offer
472
+ sign-in.** It covers a revoked or unknown AuthKey (the service
473
+ answers `403` with DAA status `420036`), identifiers that no longer match,
474
+ and a response the SDK cannot read. Signing in again re-registers the same
475
+ key and records fresh identifiers, so the next restore works. A key the
476
+ service has revoked cannot re-register; once the user confirms, remove it
477
+ with `forgetLocalKey` (below) so the next sign-in registers a new key. Log
478
+ `err.detail.correlationId` when present for support. One exception on iOS:
479
+ a prompt that the system or the app interrupted (for example the app left
480
+ the foreground during the prompt) also arrives as `contract_violation`
481
+ today, while Android reports it as `user_cancelled`. If the app left the
482
+ foreground while `restore` was running, call `restore` again once it is
483
+ back in the foreground before offering sign-in.
484
+ 4. **`clock_skew` is not a sign-in case.** DAA refused the authorization
485
+ because the device clock is off, and a new login would fail the same way.
486
+ Keep the key, ask the user to correct the device time, then call `restore`
487
+ again.
488
+ 5. **`user_cancelled` is not a sign-in case either.** The user dismissed the
489
+ authentication prompt; nothing was sent and the key is untouched. Do not
490
+ start a social login: let the user call `restore` again when they choose.
491
+ 6. **`device_pending` is not a sign-in case.** The key was approved and is in
492
+ the account's cool-down (see
493
+ [Signing in again during the cool-down](#signing-in-again-during-the-cool-down)).
494
+ Keep the key, don't start a social login, and call `restore` again once
495
+ the device status is `active`.
496
+ 7. **Store `clientEntityId` exactly as `DaaUserContext.clientEntityId` returns
497
+ it** (a lowercase UUID), keyed by your own user id, and clear it when that
498
+ user signs out or the app switches users, so a restore can only ever target
499
+ the user who is actually signed in to your app. The key slot is derived
500
+ from those exact characters, so `restore` accepts only the lowercase form:
501
+ an uppercase copy fails with `contract_violation` rather than reporting
502
+ `no_local_key`. Login is unaffected: it names the key from the service's
503
+ lowercase echo, not from your input.
504
+
505
+ `forgetLocalKey({ clientEntityId })` deletes this device's key for that user. Use
506
+ it only on an explicit user action, such as "remove this device", confirming
507
+ the removal of a key Circle has revoked, or confirming a fresh start after this
508
+ new device was declined (a `denied` status, see
509
+ [Following an add-a-device request](#following-an-add-a-device-request), or a
510
+ `device_denied` registration error). It is local only and does not revoke
511
+ the key with Circle, and the next sign-in registers a new key.
512
+
513
+ ## Installing
514
+
515
+ ```
516
+ yarn add @circle-fin/daa-react-native-sdk
517
+ ```
518
+
519
+ ### The native SDKs are separate artifacts
520
+
521
+ This package bridges to two native SDKs published as coordinates rather than
522
+ vendoring them. The
523
+ tarball ships `DaaReactNativeSdk.podspec` and `android/build.gradle`, which only
524
+ _declare_ the native dependencies — installing from npm does not fetch them. The
525
+ host app's own CocoaPods and Gradle resolve them at build time.
526
+
527
+ **iOS.** `daa-ios-sdk` is a CocoaPods spec source, not published to the public
528
+ trunk. Add it alongside the CDN in your `Podfile`, then `pod install`:
529
+
530
+ ```ruby
531
+ source 'https://github.com/circlefin/daa-ios-sdk.git'
532
+ source 'https://cdn.cocoapods.org/'
533
+ ```
534
+
535
+ **Android.** `com.circle.daa:daa-android-sdk` is published to GitHub Packages,
536
+ which needs a GitHub token even for public packages. Add a `maven {}` block to
537
+ your app's root `build.gradle`, sourced from the environment so nothing is
538
+ committed:
539
+
540
+ ```gradle
541
+ allprojects {
542
+ repositories {
543
+ // ...your existing repositories
544
+ maven {
545
+ url System.getenv('DAA_ANDROID_MAVEN_URL')
546
+ credentials {
547
+ username System.getenv('DAA_ANDROID_MAVEN_USERNAME')
548
+ password System.getenv('DAA_ANDROID_MAVEN_PASSWORD')
549
+ }
550
+ }
551
+ }
552
+ }
553
+ ```
554
+
555
+ | Variable | Value |
556
+ | ---------------------------- | -------------------------------------------------------- |
557
+ | `DAA_ANDROID_MAVEN_URL` | `https://maven.pkg.github.com/circlefin/daa-android-sdk` |
558
+ | `DAA_ANDROID_MAVEN_USERNAME` | your GitHub username |
559
+ | `DAA_ANDROID_MAVEN_PASSWORD` | a GitHub PAT with `read:packages` scope |
560
+
561
+ ### Upgrading to `DaaSdk` 0.9.0 and `daa-android-sdk` 0.8.0
562
+
563
+ - **Device registration needs these native versions.** Device Registration
564
+ Complete now goes to `POST /v1/accounts/auth/keys`, and both of its proofs
565
+ name `register_device_key` version 3. Earlier native releases refuse to sign
566
+ them, so `complete()` fails on the device before it sends a request. This
567
+ package pins these versions. If your app overrides the native pins, do not
568
+ resolve anything older.
569
+ - **The add-a-device code secret survives an app restart.** `complete()` keeps
570
+ it with the device key through native `codeSecret()` / `deleteCodeSecret()`,
571
+ new in these releases, so a sign-in after a restart shows the same code for
572
+ a request still waiting, until the secret is sent. A custom `SecureKeyStore`
573
+ whose `OwnerAuthKey` lacks both optional methods keeps the secret in memory
574
+ as before; one with only one of them fails `complete()` with
575
+ `contract_violation`.
576
+
577
+ ### Upgrading for adding a device
578
+
579
+ - **Off until you set `addDeviceApproval: true`.** Nothing below changes
580
+ until you do. Turn it on after DAA runs enclave 0.1.93 or later (older
581
+ enclaves refuse `codeSeal`, first devices included) and before DAA turns on
582
+ device approval (which refuses a second device without `codeSeal`); see
583
+ [Adding a device](#adding-a-device).
584
+ - **`complete()` has a new result, `PENDING_APPROVAL`.** A new device on an
585
+ account that already has an active one now gets
586
+ `{ status: 'PENDING_APPROVAL', pendingApproval }`, which has no `context`.
587
+ Check `result.status` before reading `result.context`, and show the matching
588
+ code (see [Adding a device](#adding-a-device)). The key can't sign until the
589
+ user approves it on their other device.
590
+ - **Ask before adding the device.** When DAA says a new device would wait
591
+ for approval and this device has no registered key,
592
+ `completeSocialSession` creates no key and returns
593
+ `confirmationRequired: true`; `complete()` then needs
594
+ `confirmAddDevice: true`, passed after the user confirms, and throws
595
+ `contract_violation` without it (see [Adding a device](#adding-a-device)).
596
+ - **Four new error kinds from `complete()`.** `device_registration_limit`,
597
+ `device_denied`, `device_approval_conflict` and
598
+ `device_approval_unavailable` used to arrive as `api` errors.
599
+ - **`registration_not_saved` from `complete()`.** DAA registered the device
600
+ but saving its identifiers on the device failed; call `complete()` again
601
+ (see [When saving the registration fails](#when-saving-the-registration-fails)).
602
+ A native failure of that save used to arrive as its own kind; now only
603
+ `key_invalidated` and `device_not_initialized` still do, and every other one
604
+ is `registration_not_saved` with the original on `cause`.
605
+ - **`matching_code_unavailable` from `getMatchingCode()` and
606
+ `sendCodeSecret()`.** The request was sealed with a code secret this device
607
+ no longer has, such as after an app restart that followed the send (see
608
+ [Adding a device](#adding-a-device)).
609
+
610
+ ### Upgrading for session restore
611
+
612
+ - **Session restore needs `DaaSdk` 0.7.0+ and `daa-android-sdk` 0.6.0+.**
613
+ `DaaClient.restore()` calls the native `resolveExisting()` and the
614
+ identifier-recording `acknowledgeRegistration`, which earlier native
615
+ releases do not have. This package pins versions that have them.
616
+ - **The first restore after upgrading returns `no_local_key`.** A key
617
+ registered by an earlier version has no recorded `authKeyId` or
618
+ `ownerBindingId`. The user signs in once more with the same key; restore
619
+ works from then on.
620
+
621
+ ### Upgrading: AuthKey registration record
622
+
623
+ - **iOS cannot roll back below `DaaSdk` 0.7.0, and Android cannot roll back
624
+ below `daa-android-sdk` 0.6.0.** Device Registration Complete now records
625
+ the AuthKey's `authKeyId` and `ownerBindingId` beside the key, and earlier
626
+ native releases can no longer read a key recorded that way: they fail
627
+ closed on every acknowledged key. On iOS, an app and its extensions that
628
+ share a Keychain access group must upgrade together.
629
+
630
+ ### Upgrading to `DaaSdk` 0.5.1 and `daa-android-sdk` 0.5.0
631
+
632
+ - **The biometric prompt text belongs to the native SDKs.** Face ID, Touch ID
633
+ and the Android BiometricPrompt show text that the native SDK sets from the
634
+ operation being signed, for example `Authorizing: transfer`. The text is
635
+ English only. Your app cannot set or change it.
636
+ - **iOS apps that share Keychain items may lose their AuthKey.** The AuthKey now
637
+ lives in your app's own application-identifier Keychain group
638
+ (`<App ID prefix>.<bundle identifier>`). Before, it lived in the first group
639
+ of your `keychain-access-groups` entitlement. If you use Keychain Sharing and
640
+ a shared group is first in that list, the SDK does not find the AuthKey that
641
+ an earlier version created. `resolveOrCreate` returns `"created"`, and the
642
+ device must register again. Apps without Keychain Sharing, and apps that list
643
+ their own group first, are not affected.
644
+ - **iOS fails closed when the AuthKey Keychain group cannot be resolved.** If
645
+ the SDK cannot resolve your app's own group, for example in a background
646
+ launch before the first unlock after boot, the call throws instead of running
647
+ an unscoped Keychain query. Nothing is cached, so a later call tries again.
648
+ - **Android needs an Auth Tab browser for a custom-scheme enrollment
649
+ redirect.** A custom-scheme `redirectUri` for `enroll` now runs only in an
650
+ Auth Tab. On a device with no allowed browser that offers one, `enroll`
651
+ rejects with a `ScaError` whose `code` is `Unsupported` and whose `reason` is
652
+ `InsecureRedirect`, and nothing opens. An `https` App Link is not affected,
653
+ and `approve` already refuses a custom scheme.
654
+
655
+ ## Layout
656
+
657
+ ```
658
+ src/
659
+ index.ts Public surface — `.` (types + client + serialization)
660
+ testing.ts `./testing` subpath — in-memory secure-key test double
661
+ DaaClient.ts Root client + configuration
662
+ api/ AuthClient, DaaUserClient + typed resource clients
663
+ auth/ Login-attempt material (registration-flow key, verifier)
664
+ models/ Typed account, page, address, deposit, transfer, withdrawal, contract-execution, fiat-account (wire/ACH), money, and prepared-login models
665
+ wire/ Response decoding: `data` envelope, payload mapping
666
+ transport/ Injected transport boundary
667
+ crypto/ Exact-byte serialization, Base64URL, SHA-256, JWK thumbprint, native-backed CSPRNG
668
+ securekey/ DAA Owner-key interfaces + in-memory & native-bridge stores
669
+ errors.ts DaaSdkError model + DaaError
670
+ DaaReactNativeSdk.podspec Declares the DaaSdk CocoaPods dependency
671
+ android/build.gradle Declares the com.circle.daa:daa-android-sdk dependency
672
+ ios/ Expo DaaSecureKey + DaaRegistration Swift modules
673
+ android/src/ Expo DaaSecureKey + DaaRegistration Kotlin modules
674
+ expo-module.config.json Expo autolinking
675
+ ```
676
+
677
+ ## Develop
678
+
679
+ ```bash
680
+ yarn install
681
+ yarn test # unit tests (jest + ts-jest)
682
+ yarn check:type # tsc --noEmit
683
+ ```
684
+
685
+ ## References
686
+
687
+ - Reporting a security vulnerability: [`SECURITY.md`](./SECURITY.md)
688
+ - Contributing: [`CONTRIBUTING.md`](./CONTRIBUTING.md)
689
+
690
+ ## License
691
+
692
+ [Apache License 2.0](LICENSE)