@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
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) 2026, Circle Internet Group, Inc. All rights reserved.
4
+ *
5
+ * SPDX-License-Identifier: Apache-2.0
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ */
19
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
20
+ if (kind === "m") throw new TypeError("Private method is not writable");
21
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
22
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
23
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
24
+ };
25
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
26
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
27
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
28
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
29
+ };
30
+ var _Page_next, _Page_previous;
31
+ Object.defineProperty(exports, "__esModule", { value: true });
32
+ exports.Page = void 0;
33
+ /** A frozen collection page with trusted navigation to adjacent pages. */
34
+ class Page {
35
+ /** @internal Constructed only by a typed collection client. */
36
+ constructor(items, next, previous) {
37
+ _Page_next.set(this, void 0);
38
+ _Page_previous.set(this, void 0);
39
+ this.items = Object.freeze([...items]);
40
+ __classPrivateFieldSet(this, _Page_next, next, "f");
41
+ __classPrivateFieldSet(this, _Page_previous, previous, "f");
42
+ Object.freeze(this);
43
+ }
44
+ /** Load the following page, or return `null` when the API supplied no link. */
45
+ async next() {
46
+ return __classPrivateFieldGet(this, _Page_next, "f") === null ? null : __classPrivateFieldGet(this, _Page_next, "f").call(this);
47
+ }
48
+ /** Load the preceding page, or return `null` when the API supplied no link. */
49
+ async previous() {
50
+ return __classPrivateFieldGet(this, _Page_previous, "f") === null ? null : __classPrivateFieldGet(this, _Page_previous, "f").call(this);
51
+ }
52
+ toJSON() {
53
+ return Object.freeze({ items: this.items });
54
+ }
55
+ }
56
+ exports.Page = Page;
57
+ _Page_next = new WeakMap(), _Page_previous = new WeakMap();
@@ -0,0 +1,121 @@
1
+ /**
2
+ * Copyright (c) 2026, Circle Internet Group, Inc. All rights reserved.
3
+ *
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ import type { DaaTransport } from '../transport/DaaTransport';
19
+ import type { OwnerAuthKey } from '../securekey/SecureKey';
20
+ /**
21
+ * A new device's registration on an account that already has a device: DAA
22
+ * added this AuthKey as waiting for approval, and an existing device must
23
+ * approve it before it can sign.
24
+ *
25
+ * The app calls {@link sendCodeSecret}, which is what makes DAA tell the
26
+ * partner (`account.device.pending` webhook) to prompt the existing device,
27
+ * and shows {@link getMatchingCode} on this device. The user types the code on
28
+ * the existing device, which approves after checking that the typed code is
29
+ * the one this device's code secret produces. The key can't sign anything
30
+ * until then, and DAA cancels the request at `expiresAt`. Follow the request
31
+ * with `DaaClient.watchDeviceStatus({ authKeyId })`.
32
+ *
33
+ * The code secret is kept with the AuthKey (Keychain on iOS, Keystore-encrypted
34
+ * storage on Android) until DAA says no request is waiting for it, or until
35
+ * {@link sendCodeSecret} sends it. It leaves the device only through
36
+ * {@link sendCodeSecret}, for this request only.
37
+ *
38
+ * If the app discards this object, or restarts, signing in again before
39
+ * `expiresAt` returns the same request and the same code. Once
40
+ * {@link sendCodeSecret} has run, the secret is kept in process memory only:
41
+ * after a restart a sign-in before `expiresAt` still returns the same request,
42
+ * but this device no longer holds the secret its seal commits to. DAA returns
43
+ * that seal, so this SDK can tell: {@link getMatchingCode} and
44
+ * {@link sendCodeSecret} then throw `matching_code_unavailable` and nothing is
45
+ * sent. Have the user wait until `expiresAt` and sign in again.
46
+ *
47
+ * Not constructible by a consumer: exported from `index.ts` as a type only.
48
+ */
49
+ export declare class PendingDeviceApproval {
50
+ #private;
51
+ /** The add-a-device request this device waits on. */
52
+ readonly requestId: string;
53
+ /** This device's new AuthKey id. It can't sign until the request is approved. */
54
+ readonly authKeyId: string;
55
+ /** When DAA cancels the request unless it was approved, as ISO-8601 text. */
56
+ readonly expiresAt: string;
57
+ /** @internal Constructed only by `PendingDeviceRegistration.complete`. */
58
+ constructor(token: symbol, fields: {
59
+ readonly requestId: string;
60
+ readonly authKeyId: string;
61
+ readonly expiresAt: string;
62
+ readonly codeNonce: string;
63
+ readonly authKeyThumbprint: string;
64
+ readonly authKey: OwnerAuthKey;
65
+ readonly codeSecret: Uint8Array | null;
66
+ readonly transport: DaaTransport;
67
+ });
68
+ /**
69
+ * The six digits to show on this device, such as `"482913"`. Show them with
70
+ * a space in the middle (`482 913`); the approving device ignores spaces and
71
+ * dashes in what the user types. The same value every time.
72
+ *
73
+ * @throws DaaError with `detail.kind === 'matching_code_unavailable'` when
74
+ * DAA's seal for this request isn't one this device holds the secret for
75
+ * (the app restarted after the secret was sent): no code it shows
76
+ * could match. Tell the user to wait until `expiresAt` and sign in again.
77
+ */
78
+ getMatchingCode(): string;
79
+ /**
80
+ * Send this device's code secret to DAA for this request:
81
+ * `POST /v1/accounts/auth/devices/{authKeyId}/codeSecret`. DAA checks it
82
+ * against the seal this device signed into its registration, stores it, and
83
+ * sends the `account.device.pending` webhook so the partner can prompt the
84
+ * existing device. Until it is sent, the existing device can't check the
85
+ * code. Call it once the request is `PENDING_APPROVAL`, before or while
86
+ * showing {@link getMatchingCode}.
87
+ *
88
+ * Safe to call again: DAA accepts the same secret for the same request again
89
+ * (`204`) and re-sends the webhook while the request is waiting. That is the
90
+ * retry for a `500` or a transport failure, which may mean the secret was
91
+ * saved but the webhook was not sent.
92
+ *
93
+ * Once sent, this SDK never seals the secret into another request: the
94
+ * key's next registration seals a new one (a registration that timed out
95
+ * before the send may still reach DAA later with it; see `codeSecrets.ts`). If DAA answers that registration with
96
+ * this same request (it was still waiting), the code still comes from this
97
+ * secret. Waits for any registration of this key in flight: if DAA answers it
98
+ * with a different request, or doesn't answer, this request is no longer the
99
+ * one the secret is sealed into, and nothing is sent.
100
+ *
101
+ * @throws DaaError with `detail.kind === 'transport'` (retryable) when the
102
+ * transport throws; `api` for any status but `204`: retryable for `429`
103
+ * and `5xx` (call again), and not retryable for the `409` with
104
+ * `DEVICE_APPROVAL_INVALID` (`420117`), which DAA returns when this is no
105
+ * longer the key's latest request, the request has ended, or the secret
106
+ * doesn't match the seal; `contract_violation` (not retryable, nothing
107
+ * sent) when this SDK already knows the request is not the one the secret
108
+ * is sealed into: a later sign-in of this key returned another request or
109
+ * got no answer, or DAA said no request is waiting for the key. Sign in
110
+ * again for the current request. `matching_code_unavailable` (nothing
111
+ * sent), as for {@link getMatchingCode}: this device doesn't hold the
112
+ * secret DAA's seal for the request commits to. A secure-key error kind
113
+ * (nothing sent, call again) when deleting the secret from the AuthKey's
114
+ * storage failed, or `transport` (retryable, nothing sent) when that
115
+ * delete didn't finish within 5 seconds: it is deleted before the send so
116
+ * it is never sealed into another request, even after a restart.
117
+ */
118
+ sendCodeSecret(): Promise<void>;
119
+ }
120
+ /** @internal */
121
+ export declare function newPendingDeviceApproval(fields: ConstructorParameters<typeof PendingDeviceApproval>[1]): PendingDeviceApproval;
@@ -0,0 +1,208 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) 2026, Circle Internet Group, Inc. All rights reserved.
4
+ *
5
+ * SPDX-License-Identifier: Apache-2.0
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ */
19
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
20
+ if (kind === "m") throw new TypeError("Private method is not writable");
21
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
22
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
23
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
24
+ };
25
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
26
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
27
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
28
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
29
+ };
30
+ var _PendingDeviceApproval_thumbprint, _PendingDeviceApproval_codeNonce, _PendingDeviceApproval_codeSecret, _PendingDeviceApproval_authKeyThumbprint, _PendingDeviceApproval_authKey, _PendingDeviceApproval_transport;
31
+ Object.defineProperty(exports, "__esModule", { value: true });
32
+ exports.PendingDeviceApproval = void 0;
33
+ exports.newPendingDeviceApproval = newPendingDeviceApproval;
34
+ const deviceStatus_1 = require("../api/deviceStatus");
35
+ const base64url_1 = require("../crypto/base64url");
36
+ const matchingCode_1 = require("../crypto/matchingCode");
37
+ const serialization_1 = require("../crypto/serialization");
38
+ const errors_1 = require("../errors");
39
+ const headers_1 = require("../transport/headers");
40
+ const uuid_1 = require("../validation/uuid");
41
+ const errorEnvelope_1 = require("../wire/errorEnvelope");
42
+ const codeSecrets_1 = require("./codeSecrets");
43
+ const APPROVAL_TOKEN = Symbol('daa.pendingDeviceApproval');
44
+ /**
45
+ * A new device's registration on an account that already has a device: DAA
46
+ * added this AuthKey as waiting for approval, and an existing device must
47
+ * approve it before it can sign.
48
+ *
49
+ * The app calls {@link sendCodeSecret}, which is what makes DAA tell the
50
+ * partner (`account.device.pending` webhook) to prompt the existing device,
51
+ * and shows {@link getMatchingCode} on this device. The user types the code on
52
+ * the existing device, which approves after checking that the typed code is
53
+ * the one this device's code secret produces. The key can't sign anything
54
+ * until then, and DAA cancels the request at `expiresAt`. Follow the request
55
+ * with `DaaClient.watchDeviceStatus({ authKeyId })`.
56
+ *
57
+ * The code secret is kept with the AuthKey (Keychain on iOS, Keystore-encrypted
58
+ * storage on Android) until DAA says no request is waiting for it, or until
59
+ * {@link sendCodeSecret} sends it. It leaves the device only through
60
+ * {@link sendCodeSecret}, for this request only.
61
+ *
62
+ * If the app discards this object, or restarts, signing in again before
63
+ * `expiresAt` returns the same request and the same code. Once
64
+ * {@link sendCodeSecret} has run, the secret is kept in process memory only:
65
+ * after a restart a sign-in before `expiresAt` still returns the same request,
66
+ * but this device no longer holds the secret its seal commits to. DAA returns
67
+ * that seal, so this SDK can tell: {@link getMatchingCode} and
68
+ * {@link sendCodeSecret} then throw `matching_code_unavailable` and nothing is
69
+ * sent. Have the user wait until `expiresAt` and sign in again.
70
+ *
71
+ * Not constructible by a consumer: exported from `index.ts` as a type only.
72
+ */
73
+ class PendingDeviceApproval {
74
+ /** @internal Constructed only by `PendingDeviceRegistration.complete`. */
75
+ constructor(token, fields) {
76
+ _PendingDeviceApproval_thumbprint.set(this, void 0);
77
+ _PendingDeviceApproval_codeNonce.set(this, void 0);
78
+ /** `null` when DAA's seal for the request isn't this device's. */
79
+ _PendingDeviceApproval_codeSecret.set(this, void 0);
80
+ _PendingDeviceApproval_authKeyThumbprint.set(this, void 0);
81
+ _PendingDeviceApproval_authKey.set(this, void 0);
82
+ _PendingDeviceApproval_transport.set(this, void 0);
83
+ if (token !== APPROVAL_TOKEN) {
84
+ throw (0, errors_1.contractViolation)('PendingDeviceApproval must be constructed by the DAA SDK');
85
+ }
86
+ if (!(0, uuid_1.isUuid)(fields.requestId) || !(0, uuid_1.isUuid)(fields.authKeyId)) {
87
+ throw (0, errors_1.contractViolation)('PendingDeviceApproval ids must be UUIDs');
88
+ }
89
+ this.requestId = fields.requestId;
90
+ this.authKeyId = fields.authKeyId;
91
+ this.expiresAt = fields.expiresAt;
92
+ __classPrivateFieldSet(this, _PendingDeviceApproval_thumbprint, (0, base64url_1.fromBase64Url)(fields.authKeyThumbprint), "f");
93
+ __classPrivateFieldSet(this, _PendingDeviceApproval_codeNonce, (0, base64url_1.fromBase64Url)(fields.codeNonce), "f");
94
+ // Not copied: `markCodeSecretSent` finds the kept secret by reference.
95
+ // Only `PendingDeviceRegistration` passes it, and nothing writes to it.
96
+ __classPrivateFieldSet(this, _PendingDeviceApproval_codeSecret, fields.codeSecret, "f");
97
+ __classPrivateFieldSet(this, _PendingDeviceApproval_authKeyThumbprint, fields.authKeyThumbprint, "f");
98
+ __classPrivateFieldSet(this, _PendingDeviceApproval_authKey, fields.authKey, "f");
99
+ __classPrivateFieldSet(this, _PendingDeviceApproval_transport, fields.transport, "f");
100
+ // Fails here, at registration, rather than later when the app asks for
101
+ // the code: all three inputs must be 32 bytes.
102
+ if (__classPrivateFieldGet(this, _PendingDeviceApproval_codeSecret, "f") !== null) {
103
+ (0, matchingCode_1.matchingCode)(__classPrivateFieldGet(this, _PendingDeviceApproval_thumbprint, "f"), __classPrivateFieldGet(this, _PendingDeviceApproval_codeNonce, "f"), __classPrivateFieldGet(this, _PendingDeviceApproval_codeSecret, "f"));
104
+ }
105
+ Object.freeze(this);
106
+ }
107
+ /**
108
+ * The six digits to show on this device, such as `"482913"`. Show them with
109
+ * a space in the middle (`482 913`); the approving device ignores spaces and
110
+ * dashes in what the user types. The same value every time.
111
+ *
112
+ * @throws DaaError with `detail.kind === 'matching_code_unavailable'` when
113
+ * DAA's seal for this request isn't one this device holds the secret for
114
+ * (the app restarted after the secret was sent): no code it shows
115
+ * could match. Tell the user to wait until `expiresAt` and sign in again.
116
+ */
117
+ getMatchingCode() {
118
+ if (__classPrivateFieldGet(this, _PendingDeviceApproval_codeSecret, "f") === null) {
119
+ throw (0, errors_1.matchingCodeUnavailable)();
120
+ }
121
+ return (0, matchingCode_1.matchingCode)(__classPrivateFieldGet(this, _PendingDeviceApproval_thumbprint, "f"), __classPrivateFieldGet(this, _PendingDeviceApproval_codeNonce, "f"), __classPrivateFieldGet(this, _PendingDeviceApproval_codeSecret, "f"));
122
+ }
123
+ /**
124
+ * Send this device's code secret to DAA for this request:
125
+ * `POST /v1/accounts/auth/devices/{authKeyId}/codeSecret`. DAA checks it
126
+ * against the seal this device signed into its registration, stores it, and
127
+ * sends the `account.device.pending` webhook so the partner can prompt the
128
+ * existing device. Until it is sent, the existing device can't check the
129
+ * code. Call it once the request is `PENDING_APPROVAL`, before or while
130
+ * showing {@link getMatchingCode}.
131
+ *
132
+ * Safe to call again: DAA accepts the same secret for the same request again
133
+ * (`204`) and re-sends the webhook while the request is waiting. That is the
134
+ * retry for a `500` or a transport failure, which may mean the secret was
135
+ * saved but the webhook was not sent.
136
+ *
137
+ * Once sent, this SDK never seals the secret into another request: the
138
+ * key's next registration seals a new one (a registration that timed out
139
+ * before the send may still reach DAA later with it; see `codeSecrets.ts`). If DAA answers that registration with
140
+ * this same request (it was still waiting), the code still comes from this
141
+ * secret. Waits for any registration of this key in flight: if DAA answers it
142
+ * with a different request, or doesn't answer, this request is no longer the
143
+ * one the secret is sealed into, and nothing is sent.
144
+ *
145
+ * @throws DaaError with `detail.kind === 'transport'` (retryable) when the
146
+ * transport throws; `api` for any status but `204`: retryable for `429`
147
+ * and `5xx` (call again), and not retryable for the `409` with
148
+ * `DEVICE_APPROVAL_INVALID` (`420117`), which DAA returns when this is no
149
+ * longer the key's latest request, the request has ended, or the secret
150
+ * doesn't match the seal; `contract_violation` (not retryable, nothing
151
+ * sent) when this SDK already knows the request is not the one the secret
152
+ * is sealed into: a later sign-in of this key returned another request or
153
+ * got no answer, or DAA said no request is waiting for the key. Sign in
154
+ * again for the current request. `matching_code_unavailable` (nothing
155
+ * sent), as for {@link getMatchingCode}: this device doesn't hold the
156
+ * secret DAA's seal for the request commits to. A secure-key error kind
157
+ * (nothing sent, call again) when deleting the secret from the AuthKey's
158
+ * storage failed, or `transport` (retryable, nothing sent) when that
159
+ * delete didn't finish within 5 seconds: it is deleted before the send so
160
+ * it is never sealed into another request, even after a restart.
161
+ */
162
+ async sendCodeSecret() {
163
+ if (__classPrivateFieldGet(this, _PendingDeviceApproval_codeSecret, "f") === null) {
164
+ throw (0, errors_1.matchingCodeUnavailable)();
165
+ }
166
+ const codeSecret = __classPrivateFieldGet(this, _PendingDeviceApproval_codeSecret, "f");
167
+ const bodyBytes = (0, serialization_1.serializeBody)({
168
+ requestId: this.requestId,
169
+ codeSecret: (0, base64url_1.toBase64Url)(codeSecret),
170
+ });
171
+ // Decided after any registration of this key in flight has its answer,
172
+ // and recorded before sending: a request whose response is lost may still
173
+ // have reached DAA.
174
+ const maySend = await (0, codeSecrets_1.oneAtATime)(__classPrivateFieldGet(this, _PendingDeviceApproval_authKeyThumbprint, "f"), () => (0, codeSecrets_1.markCodeSecretSent)(__classPrivateFieldGet(this, _PendingDeviceApproval_authKeyThumbprint, "f"), codeSecret, this.requestId, __classPrivateFieldGet(this, _PendingDeviceApproval_authKey, "f")));
175
+ if (!maySend) {
176
+ throw (0, errors_1.contractViolation)('this request is no longer the one this code secret is sealed into; ' +
177
+ 'use the PendingDeviceApproval from the latest sign-in');
178
+ }
179
+ let response;
180
+ try {
181
+ response = await __classPrivateFieldGet(this, _PendingDeviceApproval_transport, "f").send({
182
+ method: 'POST',
183
+ path: `${deviceStatus_1.DEVICE_PATH_PREFIX}${this.authKeyId}/codeSecret`,
184
+ query: null,
185
+ headers: { 'Content-Type': 'application/json' },
186
+ bodyBytes,
187
+ });
188
+ }
189
+ catch (err) {
190
+ // A DaaError the consumer's transport threw keeps its own kind and
191
+ // retryability, as in `asTransportFailure`.
192
+ throw (0, errors_1.isDaaError)(err) ? err : (0, errors_1.transportFailure)(err);
193
+ }
194
+ if (response.status !== 204) {
195
+ throw (0, errors_1.apiFailure)({
196
+ httpStatus: response.status,
197
+ daaStatusCode: (0, errorEnvelope_1.readDaaStatusCode)(response.bodyBytes),
198
+ correlationId: (0, headers_1.headerValueIgnoringCase)(response.headers, 'X-Request-Id'),
199
+ });
200
+ }
201
+ }
202
+ }
203
+ exports.PendingDeviceApproval = PendingDeviceApproval;
204
+ _PendingDeviceApproval_thumbprint = new WeakMap(), _PendingDeviceApproval_codeNonce = new WeakMap(), _PendingDeviceApproval_codeSecret = new WeakMap(), _PendingDeviceApproval_authKeyThumbprint = new WeakMap(), _PendingDeviceApproval_authKey = new WeakMap(), _PendingDeviceApproval_transport = new WeakMap();
205
+ /** @internal */
206
+ function newPendingDeviceApproval(fields) {
207
+ return new PendingDeviceApproval(APPROVAL_TOKEN, fields);
208
+ }
@@ -0,0 +1,229 @@
1
+ /**
2
+ * Copyright (c) 2026, Circle Internet Group, Inc. All rights reserved.
3
+ *
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ import { type RegistrationFlowKey } from '../auth/RegistrationFlowKey';
19
+ import type { OwnerAuthKey } from '../securekey/SecureKey';
20
+ import type { DaaTransport } from '../transport/DaaTransport';
21
+ import type { DeviceApprovalHint } from '../wire/pendingRegistrationPayload';
22
+ import { type DeviceRegistrationResult } from './DaaUserContext';
23
+ /**
24
+ * Optional device signals for this registration, passed unchanged. DAA uses
25
+ * them to show the device's model and OS in the device list. None of the
26
+ * members is required.
27
+ */
28
+ export type DeviceRegistrationRiskSignals = Readonly<{
29
+ ipAddress?: string;
30
+ sessionId?: string;
31
+ deviceId?: string;
32
+ }>;
33
+ export type { DeviceApprovalHint };
34
+ /**
35
+ * Pending device registration after Social Session.
36
+ *
37
+ * `complete()` is Device Registration Complete: `POST /v1/accounts/auth/keys`
38
+ * with the body (`type: "deviceKey"`, `idempotencyKey`, `registrationHandle`,
39
+ * `registrationCodeVerifier`, `deviceKeyPublicKey`, and `codeSeal` with
40
+ * `addDeviceApproval` on), plus `riskSignals` when the caller passes them,
41
+ * including the registration code verifier minted before
42
+ * Prepare and redeemed here against the challenge Prepare sent. Two JWSs
43
+ * authorize it — `X-Device-Authorization` (signed by the proposed AuthKey) and
44
+ * `X-Registration-Flow-Authorization` (signed by the per-attempt flow key from
45
+ * Prepare) — both over the exact body bytes. Both carry the same request claims
46
+ * bar `jti`; only the flow proof also carries the binding claims (registration
47
+ * handle, profile, AuthKey thumbprint, code verifier). Building and signing
48
+ * those proofs is `authorizeRegistrationComplete`.
49
+ *
50
+ * Every device takes this same path, first or additional, with the same body
51
+ * and no mode to select. A first device comes back `ACTIVE`. A new device on an
52
+ * Owner that already has an active device comes back `PENDING_APPROVAL`: DAA
53
+ * adds the key as waiting, and an existing device approves it after the user
54
+ * types the matching code this device shows (see `PendingDeviceApproval`).
55
+ * `codeSeal` is what makes that code possible, so it is sent on every
56
+ * registration: the SDK can't know beforehand which outcome DAA will return.
57
+ *
58
+ * With `addDeviceApproval` on, the SDK asks first. When the Session's
59
+ * `deviceApproval.required` says a new device would wait for approval and this
60
+ * device has no AuthKey Circle registered for the end user,
61
+ * `confirmationRequired` is `true` and this sign-in hasn't created a key. Ask
62
+ * the user whether to add this device (`deviceApproval.hasActiveDevice` says
63
+ * whether one of their devices can approve it), and call
64
+ * `complete({ confirmAddDevice: true })` only if they confirm. That creates
65
+ * the key, or reuses the one this device made for an earlier request, and
66
+ * registers it. DAA's answer still decides the outcome: a request already
67
+ * waiting comes back `PENDING_APPROVAL` again, and `ACTIVE` is possible where
68
+ * DAA doesn't add keys as waiting yet.
69
+ *
70
+ * There is no `abandon()` here: call `PreparedSocialLogin.abandon()`, which
71
+ * releases the same flow key. If the caller backs out after Session without
72
+ * calling `complete()` or that `abandon()`, the native flow-key cache is held until the process
73
+ * exits; `complete()` releases it in `finally`. The API has no cancel call for
74
+ * a pending registration.
75
+ *
76
+ * Not constructible by a consumer: exported from `index.ts` as a type only.
77
+ */
78
+ export declare class PendingDeviceRegistration {
79
+ #private;
80
+ readonly registrationHandle: string;
81
+ readonly clientEntityId: string;
82
+ /**
83
+ * When the registration handle expires, as ISO-8601 text. The decoder also
84
+ * accepts the epoch-millisecond form the service sends for this timestamp
85
+ * and normalises it here, so a consumer never sees the wire's disagreement.
86
+ */
87
+ readonly expiresAt: string;
88
+ /**
89
+ * The Session's `deviceApproval`: whether a new device key for this end user
90
+ * would wait for approval, as DAA saw it when it answered. A hint for what to
91
+ * tell the user, not the outcome. `null` when DAA didn't send it.
92
+ */
93
+ readonly deviceApproval: DeviceApprovalHint | null;
94
+ /**
95
+ * `true` when the user must confirm adding this device before `complete()`
96
+ * creates and registers a key: `addDeviceApproval` is on,
97
+ * `deviceApproval.required` is `true`, and this device has no AuthKey Circle
98
+ * registered for the end user. Call `complete({ confirmAddDevice: true })`
99
+ * only after the user confirms, or without asking when the app knows this
100
+ * device's request is still waiting (`DaaClient.getDeviceStatus` on the
101
+ * `authKeyId` it saved says `pending_approval`): a key waiting for approval
102
+ * isn't registered on the device yet, so it reads as no key here. If the
103
+ * user declines, call `abandon()` on the `PreparedSocialLogin` this came
104
+ * from: nothing was created, but its native flow key is otherwise held until
105
+ * the process exits.
106
+ */
107
+ readonly confirmationRequired: boolean;
108
+ /** @internal Constructed only by `PreparedSocialLogin.completeSocialSession`. */
109
+ constructor(fields: {
110
+ readonly registrationHandle: string;
111
+ readonly clientEntityId: string;
112
+ readonly expiresAt: string;
113
+ readonly deviceApproval: DeviceApprovalHint | null;
114
+ readonly confirmationRequired: boolean;
115
+ readonly transport: DaaTransport;
116
+ readonly registrationCodeVerifier: string;
117
+ readonly registrationFlowKey: RegistrationFlowKey;
118
+ /** The AuthKey, or `null` to create it in `complete()` after confirmation. */
119
+ readonly authKey: OwnerAuthKey | null;
120
+ readonly resolveAuthKey: () => Promise<OwnerAuthKey>;
121
+ readonly addDeviceApproval: boolean;
122
+ });
123
+ /**
124
+ * Finish the ceremony: `POST /v1/accounts/auth/keys` with both
125
+ * `X-Device-Authorization` and `X-Registration-Flow-Authorization` bound to
126
+ * the exact body bytes. Both proofs name `register_device_key` version 3.
127
+ * DAA reads the body strictly and refuses any member outside the set in the
128
+ * class doc.
129
+ *
130
+ * The body is the same fields for every device — see the class doc.
131
+ * `codeSeal` is sent only with `addDeviceApproval` on (off by default). It
132
+ * commits to the AuthKey's 32-byte code secret. The same secret is sealed
133
+ * again until DAA says no request is waiting for this key, because DAA
134
+ * returns a waiting key's request and keeps its first seal; once
135
+ * `sendCodeSecret()` revealed it, the next registration seals a new one (see
136
+ * `codeSecrets.ts`). On `PENDING_APPROVAL` the returned
137
+ * `PendingDeviceApproval` holds the secret that request's seal commits to.
138
+ * DAA returns that seal, and if this SDK doesn't hold its secret (the app
139
+ * restarted after the secret was sent), the `PendingDeviceApproval`
140
+ * reports the code as unavailable (`matching_code_unavailable`) and sends
141
+ * nothing.
142
+ * DAA must run an enclave that accepts `codeSeal` (0.1.93 or later); older
143
+ * enclaves refuse the body. With the switch off, a `pending_approval` answer
144
+ * (a key already waiting from an earlier registration with it on) throws
145
+ * `contract_violation`: there is no secret to show its code from.
146
+ * The only input is the optional `riskSignals`, device signals for this
147
+ * registration. When given, they go into the body both proofs sign, so nothing
148
+ * between the app and DAA can change them. Without them, registration works
149
+ * the same and the device list shows the device without a model or OS.
150
+ *
151
+ * When `confirmationRequired` is `true`, pass `confirmAddDevice: true` once
152
+ * the user confirmed adding this device: only then is the AuthKey created
153
+ * and the registration sent. Without it, `complete()` throws
154
+ * `contract_violation` and nothing is created or sent. When
155
+ * `confirmationRequired` is `false`, `confirmAddDevice` is ignored.
156
+ *
157
+ * The input is checked before anything else: a malformed `riskSignals`, a
158
+ * `confirmAddDevice` that is not a boolean, or a missing confirmation throws
159
+ * `contract_violation` and leaves this registration unused, so the caller can
160
+ * call `complete()` again.
161
+ *
162
+ * The service returns a `KeyCredential` (see
163
+ * `wire/deviceRegistrationResultPayload.ts`): `credentialStatus: "active"`
164
+ * is `ACTIVE`, with `credentialId` as `deviceContext.authKeyId`;
165
+ * `pending_approval` is `PENDING_APPROVAL`; and `pending_activation` is
166
+ * `PENDING_ACTIVATION`. This endpoint never returns
167
+ * `RECOVERY_PENDING`. On `PENDING_APPROVAL`, the
168
+ * AuthKey is not acknowledged: it can't sign until an existing device
169
+ * approves it. On `PENDING_ACTIVATION` (approved, in the account's cool-down
170
+ * until `readyAt`) it is acknowledged but no context is returned: after
171
+ * `readyAt`, `DaaClient.restore` returns it. On `ACTIVE`, acknowledges
172
+ * the AuthKey with the context's `authKeyId` and `ownerBindingId`, so later
173
+ * `resolveOrCreate` returns `existing` and `SecureKeyStore.resolveExisting`
174
+ * can find it.
175
+ *
176
+ * @throws DaaError with `detail.kind === 'login_request_expired'` for `410`;
177
+ * `idempotency_conflict` for a `409` with `IDEMPOTENCY_KEY_REUSED`
178
+ * (`420034`); `contract_violation` for `LOGIN_REQUEST_CONSUMED` (`420039`),
179
+ * for a second call (except the retry after `registration_not_saved`,
180
+ * below), for unusable key material, for a response the SDK cannot read
181
+ * (including a `credentialStatus` other than `active`, `pending_approval`
182
+ * or `pending_activation`), and for malformed `riskSignals` (nothing is
183
+ * sent and this registration stays unused, so `complete()` can be called
184
+ * again), and for a missing `confirmAddDevice: true` when
185
+ * `confirmationRequired` (likewise nothing is sent and this registration
186
+ * stays unused); and `api` for any other status besides the documented
187
+ * `200`, including the `409` that DAA sends with `AUTH_KEY_BINDING_CONFLICT`
188
+ * (`420038`) or `PASSKEY_OWNER_CREDENTIAL_KIND_MISMATCH` (`420080`);
189
+ * `device_registration_limit`, `device_denied`, `device_approval_conflict`
190
+ * or `device_approval_unavailable` for the four add-a-device refusals (see
191
+ * `deviceRegistrationFailure`); `transport` with `retryable: false` when
192
+ * reading the AuthKey, or the queued prompt and `send()`, takes longer than
193
+ * two minutes (a later read or response is ignored; trying again needs a
194
+ * new login, unless DAA had answered and only saving its answer ran
195
+ * late: `complete()` then retries that save, as after
196
+ * `registration_not_saved`. If that late save finished first, the retry
197
+ * throws `contract_violation` ("already been consumed"): the identifiers
198
+ * are saved, and `DaaClient.restore` finds the key).
199
+ * `user_cancelled` when the user dismisses the authentication
200
+ * prompt: nothing was sent, but this registration is used up, so trying
201
+ * again needs a new login (which reuses the same AuthKey).
202
+ * When `confirmationRequired`, the AuthKey is created here, so a native
203
+ * failure creating it (for example `device_lock_not_set` or
204
+ * `device_not_supported`) is thrown here too; nothing was sent, but this
205
+ * registration is used up, so trying again needs a new login.
206
+ * `registration_not_saved` when DAA answered `ACTIVE` or
207
+ * `PENDING_ACTIVATION` but saving its
208
+ * `authKeyId` and `ownerBindingId` on this device failed (for example a
209
+ * Keychain or Keystore write error). The device is registered with Circle.
210
+ * Call `complete()` again: it sends nothing, retries only the save, and
211
+ * on success returns the same result (its input is ignored).
212
+ * The retry has the same two-minute deadline. If a newer registration of
213
+ * the same key answered in the meantime, the retry throws
214
+ * `contract_violation` and saves nothing: the newer registration's
215
+ * identifiers are the ones to keep.
216
+ * If the key on the device was replaced since (`forgetLocalKey`, then a
217
+ * new sign-in), the retry also throws `contract_violation` and saves
218
+ * nothing. If the save fails with `key_invalidated` or
219
+ * `device_not_initialized` (the key is gone), that kind is thrown as is and
220
+ * nothing is kept to retry: no save can succeed. Other native kinds (for
221
+ * example `device_lock_not_set` or `device_not_supported`, which the user
222
+ * can fix or retry) come as `registration_not_saved`, with the original on
223
+ * `cause`.
224
+ */
225
+ complete(input?: {
226
+ readonly riskSignals?: DeviceRegistrationRiskSignals;
227
+ readonly confirmAddDevice?: boolean;
228
+ }): Promise<DeviceRegistrationResult>;
229
+ }