@circle-fin/daa-react-native-sdk 0.0.0-stage → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (304) hide show
  1. package/DaaReactNativeSdk.podspec +63 -0
  2. package/LICENSE +176 -0
  3. package/README.md +217 -2
  4. package/android/build.gradle +97 -0
  5. package/android/src/main/AndroidManifest.xml +1 -0
  6. package/android/src/main/java/com/circle/daa/reactnative/DaaRegistrationExceptions.kt +47 -0
  7. package/android/src/main/java/com/circle/daa/reactnative/DaaRegistrationModule.kt +121 -0
  8. package/android/src/main/java/com/circle/daa/reactnative/DaaScaExceptions.kt +60 -0
  9. package/android/src/main/java/com/circle/daa/reactnative/DaaScaModule.kt +179 -0
  10. package/android/src/main/java/com/circle/daa/reactnative/DaaSecureKeyExceptions.kt +73 -0
  11. package/android/src/main/java/com/circle/daa/reactnative/DaaSecureKeyModule.kt +185 -0
  12. package/android/src/main/java/com/circle/daa/reactnative/InstallationIdentityStore.kt +73 -0
  13. package/android/src/main/java/com/circle/daa/reactnative/UnpaddedBase64Url.kt +45 -0
  14. package/build/DaaClient.d.ts +57 -0
  15. package/build/DaaClient.js +158 -0
  16. package/build/api/AccountLimitsClient.d.ts +79 -0
  17. package/build/api/AccountLimitsClient.js +142 -0
  18. package/build/api/AccountsClient.d.ts +95 -0
  19. package/build/api/AccountsClient.js +276 -0
  20. package/build/api/AchFiatAccountsClient.d.ts +92 -0
  21. package/build/api/AchFiatAccountsClient.js +142 -0
  22. package/build/api/AuthClient.d.ts +120 -0
  23. package/build/api/AuthClient.js +257 -0
  24. package/build/api/DaaUserClient.d.ts +124 -0
  25. package/build/api/DaaUserClient.js +245 -0
  26. package/build/api/DepositAddressesClient.d.ts +112 -0
  27. package/build/api/DepositAddressesClient.js +222 -0
  28. package/build/api/DepositsClient.d.ts +106 -0
  29. package/build/api/DepositsClient.js +183 -0
  30. package/build/api/FiatAccountsClient.d.ts +43 -0
  31. package/build/api/FiatAccountsClient.js +46 -0
  32. package/build/api/TransactionsClient.d.ts +64 -0
  33. package/build/api/TransactionsClient.js +120 -0
  34. package/build/api/TransfersClient.d.ts +104 -0
  35. package/build/api/TransfersClient.js +321 -0
  36. package/build/api/WireFiatAccountsClient.d.ts +99 -0
  37. package/build/api/WireFiatAccountsClient.js +156 -0
  38. package/build/api/WithdrawalsClient.d.ts +94 -0
  39. package/build/api/WithdrawalsClient.js +305 -0
  40. package/build/api/loginFailure.d.ts +43 -0
  41. package/build/api/loginFailure.js +64 -0
  42. package/build/api/pagination.d.ts +29 -0
  43. package/build/api/pagination.js +50 -0
  44. package/build/api/queryParameters.d.ts +23 -0
  45. package/build/api/queryParameters.js +77 -0
  46. package/build/api/resourceRequest.d.ts +60 -0
  47. package/build/api/resourceRequest.js +79 -0
  48. package/build/api/signedResource.d.ts +77 -0
  49. package/build/api/signedResource.js +168 -0
  50. package/build/auth/RegistrationFlowKey.d.ts +93 -0
  51. package/build/auth/RegistrationFlowKey.js +203 -0
  52. package/build/auth/daaRegistrationNative.d.ts +80 -0
  53. package/build/auth/daaRegistrationNative.js +184 -0
  54. package/build/auth/deviceAuthorization.d.ts +73 -0
  55. package/build/auth/deviceAuthorization.js +243 -0
  56. package/build/auth/ownerGrant.d.ts +29 -0
  57. package/build/auth/ownerGrant.js +90 -0
  58. package/build/auth/prepareReceipt.d.ts +150 -0
  59. package/build/auth/prepareReceipt.js +357 -0
  60. package/build/auth/registrationAuthorization.d.ts +48 -0
  61. package/build/auth/registrationAuthorization.js +243 -0
  62. package/build/auth/registrationCodeVerifier.d.ts +31 -0
  63. package/build/auth/registrationCodeVerifier.js +75 -0
  64. package/build/config.d.ts +79 -0
  65. package/build/config.js +116 -0
  66. package/build/crypto/base64url.d.ts +26 -0
  67. package/build/crypto/base64url.js +87 -0
  68. package/build/crypto/bytes.d.ts +27 -0
  69. package/build/crypto/bytes.js +32 -0
  70. package/build/crypto/es256Jws.d.ts +56 -0
  71. package/build/crypto/es256Jws.js +196 -0
  72. package/build/crypto/jwkThumbprint.d.ts +32 -0
  73. package/build/crypto/jwkThumbprint.js +49 -0
  74. package/build/crypto/random.d.ts +35 -0
  75. package/build/crypto/random.js +106 -0
  76. package/build/crypto/serialization.d.ts +26 -0
  77. package/build/crypto/serialization.js +43 -0
  78. package/build/crypto/sha256.d.ts +18 -0
  79. package/build/crypto/sha256.js +100 -0
  80. package/build/errors.d.ts +190 -0
  81. package/build/errors.js +252 -0
  82. package/build/index.d.ts +61 -0
  83. package/build/index.js +67 -0
  84. package/build/models/Account.d.ts +201 -0
  85. package/build/models/Account.js +147 -0
  86. package/build/models/AccountLimitsUsage.d.ts +169 -0
  87. package/build/models/AccountLimitsUsage.js +86 -0
  88. package/build/models/Ach.d.ts +135 -0
  89. package/build/models/Ach.js +184 -0
  90. package/build/models/AddressObject.d.ts +128 -0
  91. package/build/models/AddressObject.js +141 -0
  92. package/build/models/BusinessPii.d.ts +84 -0
  93. package/build/models/BusinessPii.js +142 -0
  94. package/build/models/CreateAccountRequest.d.ts +74 -0
  95. package/build/models/CreateAccountRequest.js +19 -0
  96. package/build/models/CreateTransferRequest.d.ts +91 -0
  97. package/build/models/CreateTransferRequest.js +19 -0
  98. package/build/models/CreateWithdrawalRequest.d.ts +99 -0
  99. package/build/models/CreateWithdrawalRequest.js +19 -0
  100. package/build/models/DaaUserContext.d.ts +96 -0
  101. package/build/models/DaaUserContext.js +133 -0
  102. package/build/models/Deposit.d.ts +241 -0
  103. package/build/models/Deposit.js +149 -0
  104. package/build/models/DepositSummary.d.ts +91 -0
  105. package/build/models/DepositSummary.js +114 -0
  106. package/build/models/FiatAccount.d.ts +99 -0
  107. package/build/models/FiatAccount.js +151 -0
  108. package/build/models/GenerateAddressRequest.d.ts +67 -0
  109. package/build/models/GenerateAddressRequest.js +68 -0
  110. package/build/models/Money.d.ts +76 -0
  111. package/build/models/Money.js +99 -0
  112. package/build/models/Page.d.ts +33 -0
  113. package/build/models/Page.js +57 -0
  114. package/build/models/PendingDeviceRegistration.d.ts +90 -0
  115. package/build/models/PendingDeviceRegistration.js +180 -0
  116. package/build/models/PreparedSocialLogin.d.ts +155 -0
  117. package/build/models/PreparedSocialLogin.js +235 -0
  118. package/build/models/Transaction.d.ts +187 -0
  119. package/build/models/Transaction.js +134 -0
  120. package/build/models/Transfer.d.ts +335 -0
  121. package/build/models/Transfer.js +240 -0
  122. package/build/models/Wire.d.ts +213 -0
  123. package/build/models/Wire.js +264 -0
  124. package/build/models/Withdrawal.d.ts +201 -0
  125. package/build/models/Withdrawal.js +156 -0
  126. package/build/models/redaction.d.ts +18 -0
  127. package/build/models/redaction.js +23 -0
  128. package/build/sca/ScaClient.d.ts +105 -0
  129. package/build/sca/ScaClient.js +193 -0
  130. package/build/securekey/InMemorySecureKey.d.ts +23 -0
  131. package/build/securekey/InMemorySecureKey.js +127 -0
  132. package/build/securekey/NativeSecureKey.d.ts +24 -0
  133. package/build/securekey/NativeSecureKey.js +178 -0
  134. package/build/securekey/NativeSecureKeyBridge.d.ts +83 -0
  135. package/build/securekey/NativeSecureKeyBridge.js +19 -0
  136. package/build/securekey/SecureKey.d.ts +137 -0
  137. package/build/securekey/SecureKey.js +19 -0
  138. package/build/securekey/alias.d.ts +88 -0
  139. package/build/securekey/alias.js +175 -0
  140. package/build/securekey/ownerAuthKeyResolver.d.ts +56 -0
  141. package/build/securekey/ownerAuthKeyResolver.js +63 -0
  142. package/build/securekey/resolveNativeBridge.d.ts +30 -0
  143. package/build/securekey/resolveNativeBridge.js +120 -0
  144. package/build/testing.d.ts +18 -0
  145. package/build/testing.js +34 -0
  146. package/build/transport/DaaTransport.d.ts +35 -0
  147. package/build/transport/DaaTransport.js +19 -0
  148. package/build/transport/headers.d.ts +30 -0
  149. package/build/transport/headers.js +45 -0
  150. package/build/validation/requestBody.d.ts +27 -0
  151. package/build/validation/requestBody.js +56 -0
  152. package/build/validation/uuid.d.ts +25 -0
  153. package/build/validation/uuid.js +33 -0
  154. package/build/wire/accountLimitsUsagePayload.d.ts +30 -0
  155. package/build/wire/accountLimitsUsagePayload.js +130 -0
  156. package/build/wire/accountPayload.d.ts +36 -0
  157. package/build/wire/accountPayload.js +100 -0
  158. package/build/wire/achPayload.d.ts +24 -0
  159. package/build/wire/achPayload.js +82 -0
  160. package/build/wire/addressObjectPayload.d.ts +44 -0
  161. package/build/wire/addressObjectPayload.js +64 -0
  162. package/build/wire/daaStatusCodes.d.ts +64 -0
  163. package/build/wire/daaStatusCodes.js +69 -0
  164. package/build/wire/dataEnvelope.d.ts +40 -0
  165. package/build/wire/dataEnvelope.js +79 -0
  166. package/build/wire/depositPayload.d.ts +42 -0
  167. package/build/wire/depositPayload.js +159 -0
  168. package/build/wire/deviceContextPayload.d.ts +33 -0
  169. package/build/wire/deviceContextPayload.js +57 -0
  170. package/build/wire/deviceRegistrationResultPayload.d.ts +32 -0
  171. package/build/wire/deviceRegistrationResultPayload.js +128 -0
  172. package/build/wire/errorEnvelope.d.ts +43 -0
  173. package/build/wire/errorEnvelope.js +85 -0
  174. package/build/wire/fiatAccountPayload.d.ts +37 -0
  175. package/build/wire/fiatAccountPayload.js +93 -0
  176. package/build/wire/instant.d.ts +27 -0
  177. package/build/wire/instant.js +91 -0
  178. package/build/wire/jsonNumber.d.ts +30 -0
  179. package/build/wire/jsonNumber.js +34 -0
  180. package/build/wire/moneyPayload.d.ts +30 -0
  181. package/build/wire/moneyPayload.js +56 -0
  182. package/build/wire/paginationLinks.d.ts +28 -0
  183. package/build/wire/paginationLinks.js +167 -0
  184. package/build/wire/payload.d.ts +60 -0
  185. package/build/wire/payload.js +121 -0
  186. package/build/wire/pendingRegistrationPayload.d.ts +32 -0
  187. package/build/wire/pendingRegistrationPayload.js +54 -0
  188. package/build/wire/socialLoginRequestPayload.d.ts +31 -0
  189. package/build/wire/socialLoginRequestPayload.js +72 -0
  190. package/build/wire/transactionPayload.d.ts +31 -0
  191. package/build/wire/transactionPayload.js +126 -0
  192. package/build/wire/transferPayload.d.ts +43 -0
  193. package/build/wire/transferPayload.js +218 -0
  194. package/build/wire/wireEnums.d.ts +22 -0
  195. package/build/wire/wireEnums.js +69 -0
  196. package/build/wire/wirePayload.d.ts +29 -0
  197. package/build/wire/wirePayload.js +138 -0
  198. package/build/wire/withdrawalPayload.d.ts +27 -0
  199. package/build/wire/withdrawalPayload.js +179 -0
  200. package/expo-module.config.json +14 -0
  201. package/ios/DaaRegistrationExceptions.swift +58 -0
  202. package/ios/DaaRegistrationModule.swift +143 -0
  203. package/ios/DaaScaExceptions.swift +96 -0
  204. package/ios/DaaScaModule.swift +125 -0
  205. package/ios/DaaSecureKeyExceptions.swift +77 -0
  206. package/ios/DaaSecureKeyModule.swift +162 -0
  207. package/ios/InstallationIdentityStore.swift +126 -0
  208. package/ios/UnpaddedBase64URL.swift +42 -0
  209. package/package.json +114 -4
  210. package/src/DaaClient.ts +171 -0
  211. package/src/api/AccountLimitsClient.ts +146 -0
  212. package/src/api/AccountsClient.ts +305 -0
  213. package/src/api/AchFiatAccountsClient.ts +147 -0
  214. package/src/api/AuthClient.ts +331 -0
  215. package/src/api/DaaUserClient.ts +270 -0
  216. package/src/api/DepositAddressesClient.ts +239 -0
  217. package/src/api/DepositsClient.ts +208 -0
  218. package/src/api/FiatAccountsClient.ts +50 -0
  219. package/src/api/TransactionsClient.ts +137 -0
  220. package/src/api/TransfersClient.ts +361 -0
  221. package/src/api/WireFiatAccountsClient.ts +172 -0
  222. package/src/api/WithdrawalsClient.ts +339 -0
  223. package/src/api/loginFailure.ts +75 -0
  224. package/src/api/pagination.ts +63 -0
  225. package/src/api/queryParameters.ts +82 -0
  226. package/src/api/resourceRequest.ts +135 -0
  227. package/src/api/signedResource.ts +267 -0
  228. package/src/auth/RegistrationFlowKey.ts +274 -0
  229. package/src/auth/daaRegistrationNative.ts +236 -0
  230. package/src/auth/deviceAuthorization.ts +302 -0
  231. package/src/auth/ownerGrant.ts +102 -0
  232. package/src/auth/prepareReceipt.ts +522 -0
  233. package/src/auth/registrationAuthorization.ts +306 -0
  234. package/src/auth/registrationCodeVerifier.ts +76 -0
  235. package/src/config.ts +156 -0
  236. package/src/crypto/base64url.ts +88 -0
  237. package/src/crypto/bytes.ts +30 -0
  238. package/src/crypto/es256Jws.ts +240 -0
  239. package/src/crypto/jwkThumbprint.ts +65 -0
  240. package/src/crypto/random.ts +113 -0
  241. package/src/crypto/serialization.ts +42 -0
  242. package/src/crypto/sha256.ts +105 -0
  243. package/src/errors.ts +319 -0
  244. package/src/index.ts +223 -0
  245. package/src/models/Account.ts +264 -0
  246. package/src/models/AccountLimitsUsage.ts +192 -0
  247. package/src/models/Ach.ts +269 -0
  248. package/src/models/AddressObject.ts +169 -0
  249. package/src/models/BusinessPii.ts +154 -0
  250. package/src/models/CreateAccountRequest.ts +109 -0
  251. package/src/models/CreateTransferRequest.ts +114 -0
  252. package/src/models/CreateWithdrawalRequest.ts +120 -0
  253. package/src/models/DaaUserContext.ts +172 -0
  254. package/src/models/Deposit.ts +307 -0
  255. package/src/models/DepositSummary.ts +142 -0
  256. package/src/models/FiatAccount.ts +195 -0
  257. package/src/models/GenerateAddressRequest.ts +101 -0
  258. package/src/models/Money.ts +91 -0
  259. package/src/models/Page.ts +48 -0
  260. package/src/models/PendingDeviceRegistration.ts +197 -0
  261. package/src/models/PreparedSocialLogin.ts +287 -0
  262. package/src/models/Transaction.ts +247 -0
  263. package/src/models/Transfer.ts +459 -0
  264. package/src/models/Wire.ts +405 -0
  265. package/src/models/Withdrawal.ts +283 -0
  266. package/src/models/redaction.ts +22 -0
  267. package/src/sca/ScaClient.ts +289 -0
  268. package/src/securekey/InMemorySecureKey.ts +138 -0
  269. package/src/securekey/NativeSecureKey.ts +179 -0
  270. package/src/securekey/NativeSecureKeyBridge.ts +109 -0
  271. package/src/securekey/SecureKey.ts +149 -0
  272. package/src/securekey/alias.ts +204 -0
  273. package/src/securekey/ownerAuthKeyResolver.ts +96 -0
  274. package/src/securekey/resolveNativeBridge.ts +185 -0
  275. package/src/testing.ts +32 -0
  276. package/src/transport/DaaTransport.ts +42 -0
  277. package/src/transport/headers.ts +46 -0
  278. package/src/validation/requestBody.ts +60 -0
  279. package/src/validation/uuid.ts +31 -0
  280. package/src/wire/accountLimitsUsagePayload.ts +182 -0
  281. package/src/wire/accountPayload.ts +108 -0
  282. package/src/wire/achPayload.ts +98 -0
  283. package/src/wire/addressObjectPayload.ts +64 -0
  284. package/src/wire/daaStatusCodes.ts +69 -0
  285. package/src/wire/dataEnvelope.ts +80 -0
  286. package/src/wire/depositPayload.ts +186 -0
  287. package/src/wire/deviceContextPayload.ts +58 -0
  288. package/src/wire/deviceRegistrationResultPayload.ts +153 -0
  289. package/src/wire/errorEnvelope.ts +87 -0
  290. package/src/wire/fiatAccountPayload.ts +112 -0
  291. package/src/wire/instant.ts +93 -0
  292. package/src/wire/jsonNumber.ts +33 -0
  293. package/src/wire/moneyPayload.ts +55 -0
  294. package/src/wire/paginationLinks.ts +204 -0
  295. package/src/wire/payload.ts +146 -0
  296. package/src/wire/pendingRegistrationPayload.ts +75 -0
  297. package/src/wire/socialLoginRequestPayload.ts +89 -0
  298. package/src/wire/transactionPayload.ts +145 -0
  299. package/src/wire/transferPayload.ts +249 -0
  300. package/src/wire/wireEnums.ts +74 -0
  301. package/src/wire/wirePayload.ts +160 -0
  302. package/src/wire/withdrawalPayload.ts +219 -0
  303. package/testing.d.ts +19 -0
  304. package/testing.js +25 -0
@@ -0,0 +1,156 @@
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 _WithdrawalToAmount_amount, _WithdrawalDetail_amount, _WithdrawalDetail_toAmount, _WithdrawalDetail_fees, _WithdrawalDetail_externalRef, _WithdrawalDetail_adjustments, _WithdrawalDetail_returnObject, _WithdrawalDetail_customerExternalRef, _WithdrawalDetail_subAccountSweeps;
31
+ Object.defineProperty(exports, "__esModule", { value: true });
32
+ exports.WithdrawalDetail = exports.WithdrawalToAmount = void 0;
33
+ const redaction_1 = require("./redaction");
34
+ /** Target fiat amount. Unlike `Money`, its service-side amount is deliberately optional. */
35
+ class WithdrawalToAmount {
36
+ /** @internal Constructed only by the response decoder. */
37
+ constructor(amount, currency) {
38
+ _WithdrawalToAmount_amount.set(this, void 0);
39
+ __classPrivateFieldSet(this, _WithdrawalToAmount_amount, amount, "f");
40
+ this.currency = currency;
41
+ Object.freeze(this);
42
+ }
43
+ get amount() {
44
+ return __classPrivateFieldGet(this, _WithdrawalToAmount_amount, "f");
45
+ }
46
+ toJSON() {
47
+ return { amount: __classPrivateFieldGet(this, _WithdrawalToAmount_amount, "f") === null ? null : redaction_1.REDACTED, currency: this.currency };
48
+ }
49
+ toString() {
50
+ return `WithdrawalToAmount(amount=${__classPrivateFieldGet(this, _WithdrawalToAmount_amount, "f") === null ? 'null' : redaction_1.REDACTED}, currency=${this.currency})`;
51
+ }
52
+ }
53
+ exports.WithdrawalToAmount = WithdrawalToAmount;
54
+ _WithdrawalToAmount_amount = new WeakMap();
55
+ /**
56
+ * GET-only DAA withdrawal projection.
57
+ *
58
+ * The guaranteed core follows the service's two read paths, not the generated
59
+ * schema: `id`, `sourceAccountId`, `destination`, `amount`, `status`, and
60
+ * `createDate` are produced by both payout-backed and stored-withdrawal reads.
61
+ * Enrichment is omitted from the response whenever unavailable. Amounts plus
62
+ * bank/customer references are private so object inspection, spread, and
63
+ * enumeration cannot disclose them.
64
+ */
65
+ class WithdrawalDetail {
66
+ /** @internal Constructed only by the response decoder. */
67
+ constructor(fields) {
68
+ _WithdrawalDetail_amount.set(this, void 0);
69
+ _WithdrawalDetail_toAmount.set(this, void 0);
70
+ _WithdrawalDetail_fees.set(this, void 0);
71
+ _WithdrawalDetail_externalRef.set(this, void 0);
72
+ _WithdrawalDetail_adjustments.set(this, void 0);
73
+ _WithdrawalDetail_returnObject.set(this, void 0);
74
+ _WithdrawalDetail_customerExternalRef.set(this, void 0);
75
+ _WithdrawalDetail_subAccountSweeps.set(this, void 0);
76
+ this.id = fields.id;
77
+ this.sourceAccountId = fields.sourceAccountId;
78
+ this.destination = fields.destination;
79
+ this.status = fields.status;
80
+ this.trackingRef = fields.trackingRef;
81
+ this.errorCode = fields.errorCode;
82
+ this.riskEvaluation = fields.riskEvaluation;
83
+ this.burnAll = fields.burnAll;
84
+ this.createDate = fields.createDate;
85
+ this.updateDate = fields.updateDate;
86
+ this.policyEvaluation = fields.policyEvaluation;
87
+ __classPrivateFieldSet(this, _WithdrawalDetail_amount, fields.amount, "f");
88
+ __classPrivateFieldSet(this, _WithdrawalDetail_toAmount, fields.toAmount, "f");
89
+ __classPrivateFieldSet(this, _WithdrawalDetail_fees, fields.fees, "f");
90
+ __classPrivateFieldSet(this, _WithdrawalDetail_externalRef, fields.externalRef, "f");
91
+ __classPrivateFieldSet(this, _WithdrawalDetail_adjustments, fields.adjustments, "f");
92
+ __classPrivateFieldSet(this, _WithdrawalDetail_returnObject, fields.returnObject, "f");
93
+ __classPrivateFieldSet(this, _WithdrawalDetail_customerExternalRef, fields.customerExternalRef, "f");
94
+ __classPrivateFieldSet(this, _WithdrawalDetail_subAccountSweeps, Object.freeze(fields.subAccountSweeps.slice()), "f");
95
+ Object.freeze(this);
96
+ }
97
+ get amount() {
98
+ return __classPrivateFieldGet(this, _WithdrawalDetail_amount, "f");
99
+ }
100
+ get toAmount() {
101
+ return __classPrivateFieldGet(this, _WithdrawalDetail_toAmount, "f");
102
+ }
103
+ get fees() {
104
+ return __classPrivateFieldGet(this, _WithdrawalDetail_fees, "f");
105
+ }
106
+ get externalRef() {
107
+ return __classPrivateFieldGet(this, _WithdrawalDetail_externalRef, "f");
108
+ }
109
+ get adjustments() {
110
+ return __classPrivateFieldGet(this, _WithdrawalDetail_adjustments, "f");
111
+ }
112
+ get returnObject() {
113
+ return __classPrivateFieldGet(this, _WithdrawalDetail_returnObject, "f");
114
+ }
115
+ get customerExternalRef() {
116
+ return __classPrivateFieldGet(this, _WithdrawalDetail_customerExternalRef, "f");
117
+ }
118
+ get subAccountSweeps() {
119
+ return __classPrivateFieldGet(this, _WithdrawalDetail_subAccountSweeps, "f");
120
+ }
121
+ toJSON() {
122
+ return {
123
+ id: this.id,
124
+ sourceAccountId: this.sourceAccountId,
125
+ destination: this.destination,
126
+ amount: __classPrivateFieldGet(this, _WithdrawalDetail_amount, "f").toJSON(),
127
+ toAmount: __classPrivateFieldGet(this, _WithdrawalDetail_toAmount, "f"),
128
+ fees: __classPrivateFieldGet(this, _WithdrawalDetail_fees, "f")?.toJSON() ?? null,
129
+ status: this.status,
130
+ trackingRef: this.trackingRef,
131
+ errorCode: this.errorCode,
132
+ externalRef: __classPrivateFieldGet(this, _WithdrawalDetail_externalRef, "f") === null ? null : redaction_1.REDACTED,
133
+ riskEvaluation: this.riskEvaluation,
134
+ adjustments: `${__classPrivateFieldGet(this, _WithdrawalDetail_adjustments, "f") === null ? 0 : 1} entry`,
135
+ return: `${__classPrivateFieldGet(this, _WithdrawalDetail_returnObject, "f") === null ? 0 : 1} entry`,
136
+ customerExternalRef: __classPrivateFieldGet(this, _WithdrawalDetail_customerExternalRef, "f") === null ? null : redaction_1.REDACTED,
137
+ burnAll: this.burnAll,
138
+ subAccountSweeps: `${__classPrivateFieldGet(this, _WithdrawalDetail_subAccountSweeps, "f").length} entries`,
139
+ createDate: this.createDate,
140
+ updateDate: this.updateDate,
141
+ policyEvaluation: this.policyEvaluation,
142
+ };
143
+ }
144
+ toString() {
145
+ return (`WithdrawalDetail(id=${this.id}, sourceAccountId=${this.sourceAccountId}, ` +
146
+ `status=${this.status.kind}, amount=${__classPrivateFieldGet(this, _WithdrawalDetail_amount, "f").toString()}, ` +
147
+ `fees=${__classPrivateFieldGet(this, _WithdrawalDetail_fees, "f") === null ? 'null' : __classPrivateFieldGet(this, _WithdrawalDetail_fees, "f").toString()}, ` +
148
+ `externalRef=${__classPrivateFieldGet(this, _WithdrawalDetail_externalRef, "f") === null ? 'null' : redaction_1.REDACTED}, ` +
149
+ `customerExternalRef=${__classPrivateFieldGet(this, _WithdrawalDetail_customerExternalRef, "f") === null ? 'null' : redaction_1.REDACTED}, ` +
150
+ `adjustments=${__classPrivateFieldGet(this, _WithdrawalDetail_adjustments, "f") === null ? 0 : 1} entry, ` +
151
+ `return=${__classPrivateFieldGet(this, _WithdrawalDetail_returnObject, "f") === null ? 0 : 1} entry, ` +
152
+ `subAccountSweeps=${__classPrivateFieldGet(this, _WithdrawalDetail_subAccountSweeps, "f").length} entries)`);
153
+ }
154
+ }
155
+ exports.WithdrawalDetail = WithdrawalDetail;
156
+ _WithdrawalDetail_amount = new WeakMap(), _WithdrawalDetail_toAmount = new WeakMap(), _WithdrawalDetail_fees = new WeakMap(), _WithdrawalDetail_externalRef = new WeakMap(), _WithdrawalDetail_adjustments = new WeakMap(), _WithdrawalDetail_returnObject = new WeakMap(), _WithdrawalDetail_customerExternalRef = new WeakMap(), _WithdrawalDetail_subAccountSweeps = new WeakMap();
@@ -0,0 +1,18 @@
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
+ export declare const REDACTED = "<redacted>";
@@ -0,0 +1,23 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.REDACTED = void 0;
21
+ // The one spelling of a redacted value, so a model cannot half-redact and a test
22
+ // cannot pass against a different placeholder than the one production renders.
23
+ exports.REDACTED = '<redacted>';
@@ -0,0 +1,105 @@
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
+ /**
19
+ * Passkey strong customer authentication (SCA) through Circle's hosted
20
+ * ceremony page, run by the native iOS / Android SDKs.
21
+ *
22
+ * The flow: your backend opens a challenge (or registration) with your app's
23
+ * `redirectUri` and keeps the returned id; it hands the app only the
24
+ * `frameToken`. The app calls {@link ScaClient.approve} (or `enroll`) and sends
25
+ * the returned string, unmodified, back to the backend, which retries the
26
+ * gated request with `X-Sca-Challenge-Id` and `X-Sca-Assertion`.
27
+ */
28
+ /** Public environments only; reach another Circle host with `circleOrigin`. */
29
+ export type ScaEnvironment = 'sandbox' | 'production';
30
+ export interface ScaConfig {
31
+ environment: ScaEnvironment;
32
+ /**
33
+ * The callback URI registered with Circle for your app, exactly as
34
+ * registered. Android requires an `https` App Link for `approve`.
35
+ */
36
+ redirectUri: string;
37
+ /**
38
+ * Another Circle ceremony origin (bare `https://*.circle.com`). Only with
39
+ * `sandbox`; refused for `production`.
40
+ */
41
+ circleOrigin?: string;
42
+ /** Deadline for an approval, ms. Default 300 000, range 30 000–3 600 000. */
43
+ approveTimeoutMs?: number;
44
+ /** Deadline for an enrollment, ms. Default 600 000, range 30 000–3 600 000. */
45
+ enrollTimeoutMs?: number;
46
+ }
47
+ export type ScaErrorCode = 'Cancelled' | 'Expired' | 'Unsupported' | 'AlreadyEnrolled' | 'Protocol' | 'Transport' | 'InvalidConfiguration' | 'CeremonyInProgress' | 'NativeModuleUnavailable';
48
+ /**
49
+ * A failed ceremony. `code` is the stable vocabulary to branch on; `reason`
50
+ * narrows `Unsupported` and `Protocol` where the platform can tell (for
51
+ * example `NoAllowedBrowser`, `CallbackNotRouted`, `SessionUnavailable`,
52
+ * `StateMismatch`, `InvalidFrameToken`). `Protocol` is an integration bug,
53
+ * never a reason to offer a different authentication method.
54
+ *
55
+ * The SDK always sets `message` to one of its own literals, never to text from
56
+ * the native SDKs: it is what crash reporters log by default. For a failure that
57
+ * came from native, the native rejection is kept as `cause` for deliberate
58
+ * inspection.
59
+ */
60
+ export declare class ScaError extends Error {
61
+ readonly code: ScaErrorCode;
62
+ readonly reason: string | null;
63
+ readonly cause: unknown;
64
+ constructor(code: ScaErrorCode, message: string, reason?: string | null, cause?: unknown);
65
+ }
66
+ export declare function isScaError(err: unknown): err is ScaError;
67
+ export interface ScaCapabilities {
68
+ protocolVersion: number;
69
+ /** `webAuthenticationSession` (iOS), `authTab` / `customTab` (Android), or `none`. */
70
+ surface: string;
71
+ /** The redirect URI reaches this app's callback (Android: an exported, routed activity). */
72
+ callbackReady: boolean;
73
+ /** Android API 31+: whether the App Link is verified; otherwise `null`. */
74
+ callbackVerified: boolean | null;
75
+ /** Android: whether the callback activity is task-isolated; otherwise `null`. */
76
+ callbackTaskIsolated: boolean | null;
77
+ platformPasskeys: boolean;
78
+ }
79
+ export interface ScaClient {
80
+ readonly config: Readonly<ScaConfig>;
81
+ /** Returns the exact `X-Sca-Assertion` value. Send it unmodified. */
82
+ approve(frameToken: string): Promise<string>;
83
+ /** Returns the registration response JSON text for your backend. */
84
+ enroll(frameToken: string): Promise<string>;
85
+ capabilities(): Promise<ScaCapabilities>;
86
+ }
87
+ interface DaaScaNativeModule {
88
+ approve(config: ScaConfig, frameToken: string): Promise<string>;
89
+ enroll(config: ScaConfig, frameToken: string): Promise<string>;
90
+ capabilities(config: ScaConfig): Promise<Record<string, unknown>>;
91
+ }
92
+ /**
93
+ * Translates a native rejection into a {@link ScaError}. The result's
94
+ * `message` is the fixed text for its code; the rejection itself is kept as
95
+ * the non-enumerable `cause`.
96
+ */
97
+ export declare function mapNativeScaError(err: unknown): ScaError;
98
+ /**
99
+ * Creates an SCA client. One ceremony runs at a time across the app: a second
100
+ * `approve` or `enroll` while one is open rejects with `CeremonyInProgress`
101
+ * and leaves the open one alone. Disable the control that starts a ceremony
102
+ * until the call settles.
103
+ */
104
+ export declare function createScaClient(config: ScaConfig, native?: DaaScaNativeModule | null): ScaClient;
105
+ export {};
@@ -0,0 +1,193 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.ScaError = void 0;
21
+ exports.isScaError = isScaError;
22
+ exports.mapNativeScaError = mapNativeScaError;
23
+ exports.createScaClient = createScaClient;
24
+ const expo_modules_core_1 = require("expo-modules-core");
25
+ /**
26
+ * A failed ceremony. `code` is the stable vocabulary to branch on; `reason`
27
+ * narrows `Unsupported` and `Protocol` where the platform can tell (for
28
+ * example `NoAllowedBrowser`, `CallbackNotRouted`, `SessionUnavailable`,
29
+ * `StateMismatch`, `InvalidFrameToken`). `Protocol` is an integration bug,
30
+ * never a reason to offer a different authentication method.
31
+ *
32
+ * The SDK always sets `message` to one of its own literals, never to text from
33
+ * the native SDKs: it is what crash reporters log by default. For a failure that
34
+ * came from native, the native rejection is kept as `cause` for deliberate
35
+ * inspection.
36
+ */
37
+ class ScaError extends Error {
38
+ constructor(code, message, reason = null, cause = undefined) {
39
+ super(message);
40
+ this.name = 'ScaError';
41
+ this.code = code;
42
+ this.reason = reason;
43
+ this.cause = cause;
44
+ // Keep `cause` non-enumerable so JSON.stringify and crash reporters that
45
+ // walk own enumerable properties do not export the native rejection (its
46
+ // message, code, or native stack). It stays readable via `err.cause`.
47
+ Object.defineProperty(this, 'cause', { enumerable: false });
48
+ }
49
+ }
50
+ exports.ScaError = ScaError;
51
+ function isScaError(err) {
52
+ return err instanceof ScaError;
53
+ }
54
+ const NATIVE_CODES = {
55
+ SCA_CANCELLED: 'Cancelled',
56
+ SCA_EXPIRED: 'Expired',
57
+ SCA_UNSUPPORTED: 'Unsupported',
58
+ SCA_ALREADY_ENROLLED: 'AlreadyEnrolled',
59
+ SCA_PROTOCOL: 'Protocol',
60
+ SCA_TRANSPORT: 'Transport',
61
+ SCA_INVALID_CONFIGURATION: 'InvalidConfiguration',
62
+ SCA_CEREMONY_IN_PROGRESS: 'CeremonyInProgress',
63
+ };
64
+ // The `message` for each code. The native rejection's own text never reaches
65
+ // `ScaError.message`: it can carry platform or internal detail, and `message`
66
+ // is what crash reporters log by default. The native rejection stays on the
67
+ // non-enumerable `cause`.
68
+ const MESSAGES = {
69
+ Cancelled: 'The SCA ceremony was cancelled',
70
+ Expired: 'The SCA ceremony deadline passed',
71
+ Unsupported: 'This device or app cannot run the SCA ceremony',
72
+ AlreadyEnrolled: 'A passkey is already enrolled on this authenticator',
73
+ Protocol: 'The SCA ceremony failed with a protocol error',
74
+ Transport: 'The SCA ceremony failed on a transport error',
75
+ InvalidConfiguration: 'The SCA configuration was rejected',
76
+ CeremonyInProgress: 'Another SCA ceremony is still open',
77
+ NativeModuleUnavailable: 'The DaaSca native module is not linked in this build',
78
+ };
79
+ // Expo prefixes an async function's message ("Calling the 'approve' function
80
+ // has failed\n→ Caused by: …"), so the tag is read from the innermost cause.
81
+ // Android passes the native exception's code through; iOS does not (the
82
+ // rejection reaches JS without a code), so both bridges also tag the innermost
83
+ // message with the code ("[SCA_UNSUPPORTED:NoAllowedBrowser] …"). A known
84
+ // `code` wins; otherwise the tag is used; otherwise it is a Protocol failure.
85
+ // The message itself is read only for that tag.
86
+ const CAUSE_SEPARATOR = '→ Caused by: ';
87
+ const CODE_TAG = /^\[(SCA_[A-Z_]+(?::[A-Za-z]+)?)\] ?/;
88
+ // A reason is a name from the platform's vocabulary. One with any other shape
89
+ // is native text, not a reason, and is dropped rather than passed on.
90
+ const REASON = /^[A-Za-z]+$/;
91
+ function innermostMessage(message) {
92
+ const at = message.lastIndexOf(CAUSE_SEPARATOR);
93
+ return at < 0 ? message : message.slice(at + CAUSE_SEPARATOR.length);
94
+ }
95
+ function knownCode(base) {
96
+ return Object.prototype.hasOwnProperty.call(NATIVE_CODES, base) ? NATIVE_CODES[base] : undefined;
97
+ }
98
+ function splitCode(nativeCode) {
99
+ const separator = nativeCode.indexOf(':');
100
+ if (separator < 0) {
101
+ return [nativeCode, null];
102
+ }
103
+ const reason = nativeCode.slice(separator + 1);
104
+ return [nativeCode.slice(0, separator), REASON.test(reason) ? reason : null];
105
+ }
106
+ /**
107
+ * Translates a native rejection into a {@link ScaError}. The result's
108
+ * `message` is the fixed text for its code; the rejection itself is kept as
109
+ * the non-enumerable `cause`.
110
+ */
111
+ function mapNativeScaError(err) {
112
+ if (err instanceof ScaError) {
113
+ return err;
114
+ }
115
+ const rawCode = typeof err?.code === 'string' ? err.code : '';
116
+ const rawMessage = typeof err?.message === 'string'
117
+ ? err.message
118
+ : '';
119
+ const tag = CODE_TAG.exec(innermostMessage(rawMessage));
120
+ const fromCode = splitCode(rawCode);
121
+ const [base, reason] = knownCode(fromCode[0])
122
+ ? fromCode
123
+ : tag
124
+ ? splitCode(tag[1] ?? '')
125
+ : fromCode;
126
+ const code = knownCode(base) ?? 'Protocol';
127
+ return new ScaError(code, MESSAGES[code], reason, err);
128
+ }
129
+ function validated(config) {
130
+ if (config.environment !== 'sandbox' && config.environment !== 'production') {
131
+ throw new ScaError('InvalidConfiguration', "environment must be 'sandbox' or 'production'");
132
+ }
133
+ if (typeof config.redirectUri !== 'string' || config.redirectUri.length === 0) {
134
+ throw new ScaError('InvalidConfiguration', 'redirectUri is required');
135
+ }
136
+ // The native SDKs re-validate everything (URI rules, origin, timeout range).
137
+ return Object.freeze({ ...config });
138
+ }
139
+ /**
140
+ * Creates an SCA client. One ceremony runs at a time across the app: a second
141
+ * `approve` or `enroll` while one is open rejects with `CeremonyInProgress`
142
+ * and leaves the open one alone. Disable the control that starts a ceremony
143
+ * until the call settles.
144
+ */
145
+ function createScaClient(config, native = (0, expo_modules_core_1.requireOptionalNativeModule)('DaaSca')) {
146
+ const frozen = validated(config);
147
+ const module = () => {
148
+ if (native === null) {
149
+ throw new ScaError('NativeModuleUnavailable', MESSAGES.NativeModuleUnavailable);
150
+ }
151
+ return native;
152
+ };
153
+ let inFlight = false;
154
+ const ceremony = async (run, frameToken) => {
155
+ if (typeof frameToken !== 'string' || frameToken.length === 0) {
156
+ throw new ScaError('InvalidConfiguration', 'frameToken is required');
157
+ }
158
+ if (inFlight) {
159
+ throw new ScaError('CeremonyInProgress', MESSAGES.CeremonyInProgress);
160
+ }
161
+ inFlight = true;
162
+ try {
163
+ return await run(module());
164
+ }
165
+ catch (err) {
166
+ throw mapNativeScaError(err);
167
+ }
168
+ finally {
169
+ inFlight = false;
170
+ }
171
+ };
172
+ return {
173
+ config: frozen,
174
+ approve: (frameToken) => ceremony((n) => n.approve(frozen, frameToken), frameToken),
175
+ enroll: (frameToken) => ceremony((n) => n.enroll(frozen, frameToken), frameToken),
176
+ async capabilities() {
177
+ try {
178
+ const raw = await module().capabilities(frozen);
179
+ return {
180
+ protocolVersion: Number(raw.protocolVersion),
181
+ surface: String(raw.surface),
182
+ callbackReady: raw.callbackReady === true,
183
+ callbackVerified: typeof raw.callbackVerified === 'boolean' ? raw.callbackVerified : null,
184
+ callbackTaskIsolated: typeof raw.callbackTaskIsolated === 'boolean' ? raw.callbackTaskIsolated : null,
185
+ platformPasskeys: raw.platformPasskeys === true,
186
+ };
187
+ }
188
+ catch (err) {
189
+ throw mapNativeScaError(err);
190
+ }
191
+ },
192
+ };
193
+ }
@@ -0,0 +1,23 @@
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 { OwnerAuthKey, OwnerKeyIdentity, SecureKeyStore } from './SecureKey';
19
+ export declare class InMemorySecureKeyStore implements SecureKeyStore {
20
+ #private;
21
+ constructor();
22
+ resolveOrCreate(identity: OwnerKeyIdentity): Promise<OwnerAuthKey>;
23
+ }
@@ -0,0 +1,127 @@
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 _InMemoryOwnerAuthKey_acknowledged, _InMemoryOwnerAuthKey_keyPair, _InMemorySecureKeyStore_instances, _InMemorySecureKeyStore_keys, _InMemorySecureKeyStore_generate;
31
+ Object.defineProperty(exports, "__esModule", { value: true });
32
+ exports.InMemorySecureKeyStore = void 0;
33
+ const base64url_1 = require("../crypto/base64url");
34
+ const bytes_1 = require("../crypto/bytes");
35
+ const jwkThumbprint_1 = require("../crypto/jwkThumbprint");
36
+ const alias_1 = require("./alias");
37
+ // A WebCrypto-backed, in-memory implementation of the DAA Owner-key API. It
38
+ // produces real P-256/ES256 signatures so it can drive golden vectors and unit
39
+ // tests WITHOUT native hardware. It is NOT a production secure-key
40
+ // implementation: keys live in process memory, not a secure enclave/keystore.
41
+ function getSubtle() {
42
+ const c = globalThis.crypto;
43
+ if (!c || !c.subtle) {
44
+ throw new Error('DAA: WebCrypto (crypto.subtle) is not available');
45
+ }
46
+ return c.subtle;
47
+ }
48
+ function assertDevelopmentEnvironment() {
49
+ const g = globalThis;
50
+ const nodeEnvironment = g.process?.env?.NODE_ENV;
51
+ const explicitlyProduction = g.__DEV__ === false || nodeEnvironment === 'production';
52
+ const explicitlyDevelopment = g.__DEV__ === true || nodeEnvironment === 'development' || nodeEnvironment === 'test';
53
+ if (explicitlyProduction) {
54
+ throw new Error('DAA: InMemorySecureKeyStore is a test double and must not be used in ' +
55
+ 'production; wire the native secure-key store instead.');
56
+ }
57
+ if (!explicitlyDevelopment) {
58
+ throw new Error('DAA: InMemorySecureKeyStore requires an explicit development or test ' +
59
+ 'environment marker (__DEV__ or NODE_ENV).');
60
+ }
61
+ }
62
+ class InMemoryOwnerAuthKey {
63
+ constructor(keyPair) {
64
+ // There is no durable store behind this double, so a handle always starts
65
+ // unacknowledged and the state lives only as long as the handle does. The
66
+ // native store persists the equivalent state in the OS keystore.
67
+ _InMemoryOwnerAuthKey_acknowledged.set(this, false);
68
+ _InMemoryOwnerAuthKey_keyPair.set(this, void 0);
69
+ __classPrivateFieldSet(this, _InMemoryOwnerAuthKey_keyPair, keyPair, "f");
70
+ }
71
+ resolution() {
72
+ return __classPrivateFieldGet(this, _InMemoryOwnerAuthKey_acknowledged, "f") ? 'existing' : 'created';
73
+ }
74
+ async acknowledgeRegistration() {
75
+ __classPrivateFieldSet(this, _InMemoryOwnerAuthKey_acknowledged, true, "f");
76
+ }
77
+ async publicKeySpkiBase64Url() {
78
+ const spki = await getSubtle().exportKey('spki', __classPrivateFieldGet(this, _InMemoryOwnerAuthKey_keyPair, "f").publicKey);
79
+ return (0, base64url_1.toBase64Url)(new Uint8Array(spki));
80
+ }
81
+ async thumbprint() {
82
+ // Same one-place RFC 7638 derivation the native store uses.
83
+ const spki = await getSubtle().exportKey('spki', __classPrivateFieldGet(this, _InMemoryOwnerAuthKey_keyPair, "f").publicKey);
84
+ return (0, jwkThumbprint_1.p256JwkThumbprint)(new Uint8Array(spki));
85
+ }
86
+ async signExactBytes(message) {
87
+ const sig = await getSubtle().sign({ name: 'ECDSA', hash: 'SHA-256' }, __classPrivateFieldGet(this, _InMemoryOwnerAuthKey_keyPair, "f").privateKey, (0, bytes_1.toArrayBuffer)(message));
88
+ return new Uint8Array(sig); // JOSE R || S, 64 bytes.
89
+ }
90
+ async signRegistrationDeviceAuthorization(message) {
91
+ // This test double has no separate native validators to route between —
92
+ // it is one WebCrypto key signing whatever exact bytes it is given
93
+ // either way. The two methods exist here only so this class satisfies
94
+ // OwnerAuthKey and a test can assert on WHICH method the production
95
+ // caller reached; native's two validators are what actually diverge.
96
+ return this.signExactBytes(message);
97
+ }
98
+ }
99
+ _InMemoryOwnerAuthKey_acknowledged = new WeakMap(), _InMemoryOwnerAuthKey_keyPair = new WeakMap();
100
+ class InMemorySecureKeyStore {
101
+ constructor() {
102
+ _InMemorySecureKeyStore_instances.add(this);
103
+ _InMemorySecureKeyStore_keys.set(this, new Map());
104
+ assertDevelopmentEnvironment();
105
+ }
106
+ async resolveOrCreate(identity) {
107
+ const id = (0, alias_1.secureKeyAlias)(identity);
108
+ let existing = __classPrivateFieldGet(this, _InMemorySecureKeyStore_keys, "f").get(id);
109
+ if (!existing) {
110
+ // Evict on failure so a transient error (e.g. crypto.subtle not yet
111
+ // available) is not memoized permanently for this identity.
112
+ existing = __classPrivateFieldGet(this, _InMemorySecureKeyStore_instances, "m", _InMemorySecureKeyStore_generate).call(this).catch((err) => {
113
+ __classPrivateFieldGet(this, _InMemorySecureKeyStore_keys, "f").delete(id);
114
+ throw err;
115
+ });
116
+ __classPrivateFieldGet(this, _InMemorySecureKeyStore_keys, "f").set(id, existing);
117
+ }
118
+ return existing;
119
+ }
120
+ }
121
+ exports.InMemorySecureKeyStore = InMemorySecureKeyStore;
122
+ _InMemorySecureKeyStore_keys = new WeakMap(), _InMemorySecureKeyStore_instances = new WeakSet(), _InMemorySecureKeyStore_generate = async function _InMemorySecureKeyStore_generate() {
123
+ const keyPair = (await getSubtle().generateKey({ name: 'ECDSA', namedCurve: 'P-256' },
124
+ // Non-exportable private key; the public key is still exportable.
125
+ false, ['sign', 'verify']));
126
+ return new InMemoryOwnerAuthKey(keyPair);
127
+ };