@circle-fin/daa-react-native-sdk 0.4.0 → 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 (157) hide show
  1. package/DaaReactNativeSdk.podspec +14 -8
  2. package/README.md +498 -24
  3. package/android/build.gradle +12 -7
  4. package/android/src/main/java/com/circle/daa/reactnative/DaaRegistrationModule.kt +1 -18
  5. package/android/src/main/java/com/circle/daa/reactnative/DaaSecureKeyExceptions.kt +38 -4
  6. package/android/src/main/java/com/circle/daa/reactnative/DaaSecureKeyModule.kt +139 -6
  7. package/android/src/main/java/com/circle/daa/reactnative/InstallationIdentityStore.kt +50 -1
  8. package/build/DaaClient.d.ts +183 -3
  9. package/build/DaaClient.js +296 -12
  10. package/build/api/AccountsClient.d.ts +3 -0
  11. package/build/api/AccountsClient.js +3 -0
  12. package/build/api/AuthClient.d.ts +17 -42
  13. package/build/api/AuthClient.js +26 -62
  14. package/build/api/ContractExecutionsClient.d.ts +114 -0
  15. package/build/api/ContractExecutionsClient.js +462 -0
  16. package/build/api/DaaUserClient.d.ts +74 -11
  17. package/build/api/DaaUserClient.js +84 -17
  18. package/build/api/TransactionsClient.d.ts +1 -1
  19. package/build/api/TransactionsClient.js +1 -0
  20. package/build/api/TransfersClient.d.ts +3 -0
  21. package/build/api/TransfersClient.js +3 -0
  22. package/build/api/WithdrawalsClient.d.ts +3 -0
  23. package/build/api/WithdrawalsClient.js +3 -0
  24. package/build/api/deviceApproval.d.ts +48 -0
  25. package/build/api/deviceApproval.js +247 -0
  26. package/build/api/deviceStatus.d.ts +61 -0
  27. package/build/api/deviceStatus.js +216 -0
  28. package/build/api/loginFailure.d.ts +10 -2
  29. package/build/api/loginFailure.js +33 -2
  30. package/build/api/signedResource.d.ts +49 -2
  31. package/build/api/signedResource.js +135 -36
  32. package/build/auth/RegistrationFlowKey.js +1 -1
  33. package/build/auth/daaRegistrationNative.d.ts +0 -22
  34. package/build/auth/daaRegistrationNative.js +3 -29
  35. package/build/auth/deviceAuthorization.d.ts +17 -3
  36. package/build/auth/deviceAuthorization.js +60 -8
  37. package/build/auth/registrationAuthorization.d.ts +2 -2
  38. package/build/auth/registrationAuthorization.js +13 -10
  39. package/build/config.d.ts +27 -0
  40. package/build/config.js +15 -0
  41. package/build/crypto/matchingCode.d.ts +47 -0
  42. package/build/crypto/matchingCode.js +93 -0
  43. package/build/errors.d.ts +150 -33
  44. package/build/errors.js +208 -47
  45. package/build/index.d.ts +11 -3
  46. package/build/models/ContractExecution.d.ts +197 -0
  47. package/build/models/ContractExecution.js +130 -0
  48. package/build/models/CreateContractExecutionRequest.d.ts +81 -0
  49. package/build/models/CreateContractExecutionRequest.js +19 -0
  50. package/build/models/DaaUserContext.d.ts +53 -3
  51. package/build/models/DaaUserContext.js +33 -2
  52. package/build/models/DeviceStatus.d.ts +69 -0
  53. package/build/models/DeviceStatus.js +19 -0
  54. package/build/models/PendingDeviceApproval.d.ts +121 -0
  55. package/build/models/PendingDeviceApproval.js +208 -0
  56. package/build/models/PendingDeviceRegistration.d.ts +162 -23
  57. package/build/models/PendingDeviceRegistration.js +525 -69
  58. package/build/models/PreparedContractExecution.d.ts +70 -0
  59. package/build/models/PreparedContractExecution.js +77 -0
  60. package/build/models/PreparedSocialLogin.d.ts +19 -26
  61. package/build/models/PreparedSocialLogin.js +32 -15
  62. package/build/models/Transaction.d.ts +48 -2
  63. package/build/models/Transaction.js +52 -4
  64. package/build/models/codeSecrets.d.ts +100 -0
  65. package/build/models/codeSecrets.js +321 -0
  66. package/build/securekey/InMemorySecureKey.d.ts +3 -1
  67. package/build/securekey/InMemorySecureKey.js +47 -6
  68. package/build/securekey/NativeSecureKey.d.ts +3 -1
  69. package/build/securekey/NativeSecureKey.js +204 -27
  70. package/build/securekey/NativeSecureKeyBridge.d.ts +72 -4
  71. package/build/securekey/SecureKey.d.ts +128 -8
  72. package/build/securekey/alias.d.ts +9 -0
  73. package/build/securekey/alias.js +11 -2
  74. package/build/securekey/ownerAuthKeyResolver.d.ts +26 -9
  75. package/build/securekey/ownerAuthKeyResolver.js +35 -20
  76. package/build/securekey/registration.d.ts +19 -0
  77. package/build/securekey/registration.js +38 -0
  78. package/build/securekey/resolveNativeBridge.d.ts +3 -0
  79. package/build/securekey/resolveNativeBridge.js +88 -7
  80. package/build/transport/headers.d.ts +11 -0
  81. package/build/transport/headers.js +36 -0
  82. package/build/wire/contractExecutionPayload.d.ts +24 -0
  83. package/build/wire/contractExecutionPayload.js +130 -0
  84. package/build/wire/daaStatusCodes.d.ts +20 -3
  85. package/build/wire/daaStatusCodes.js +20 -3
  86. package/build/wire/deviceContextPayload.d.ts +9 -7
  87. package/build/wire/deviceContextPayload.js +9 -7
  88. package/build/wire/deviceRegistrationResultPayload.d.ts +55 -10
  89. package/build/wire/deviceRegistrationResultPayload.js +116 -82
  90. package/build/wire/deviceStatusPayload.d.ts +20 -0
  91. package/build/wire/deviceStatusPayload.js +66 -0
  92. package/build/wire/instant.js +4 -1
  93. package/build/wire/pendingRegistrationPayload.d.ts +16 -0
  94. package/build/wire/pendingRegistrationPayload.js +18 -0
  95. package/build/wire/socialLoginRequestPayload.d.ts +0 -5
  96. package/build/wire/socialLoginRequestPayload.js +2 -19
  97. package/build/wire/transactionPayload.d.ts +2 -2
  98. package/build/wire/transactionPayload.js +27 -4
  99. package/ios/DaaRegistrationModule.swift +1 -19
  100. package/ios/DaaSecureKeyExceptions.swift +53 -5
  101. package/ios/DaaSecureKeyModule.swift +149 -5
  102. package/ios/InstallationIdentityStore.swift +43 -7
  103. package/package.json +1 -1
  104. package/src/DaaClient.ts +353 -15
  105. package/src/api/AccountsClient.ts +3 -0
  106. package/src/api/AuthClient.ts +33 -98
  107. package/src/api/ContractExecutionsClient.ts +527 -0
  108. package/src/api/DaaUserClient.ts +92 -17
  109. package/src/api/TransactionsClient.ts +1 -0
  110. package/src/api/TransfersClient.ts +3 -0
  111. package/src/api/WithdrawalsClient.ts +3 -0
  112. package/src/api/deviceApproval.ts +306 -0
  113. package/src/api/deviceStatus.ts +238 -0
  114. package/src/api/loginFailure.ts +39 -2
  115. package/src/api/signedResource.ts +206 -46
  116. package/src/auth/RegistrationFlowKey.ts +1 -1
  117. package/src/auth/daaRegistrationNative.ts +4 -49
  118. package/src/auth/deviceAuthorization.ts +74 -11
  119. package/src/auth/registrationAuthorization.ts +12 -9
  120. package/src/config.ts +36 -0
  121. package/src/crypto/matchingCode.ts +100 -0
  122. package/src/errors.ts +309 -52
  123. package/src/index.ts +36 -1
  124. package/src/models/ContractExecution.ts +250 -0
  125. package/src/models/CreateContractExecutionRequest.ts +100 -0
  126. package/src/models/DaaUserContext.ts +59 -3
  127. package/src/models/DeviceStatus.ts +50 -0
  128. package/src/models/PendingDeviceApproval.ts +229 -0
  129. package/src/models/PendingDeviceRegistration.ts +673 -79
  130. package/src/models/PreparedContractExecution.ts +128 -0
  131. package/src/models/PreparedSocialLogin.ts +41 -31
  132. package/src/models/Transaction.ts +77 -2
  133. package/src/models/codeSecrets.ts +360 -0
  134. package/src/securekey/InMemorySecureKey.ts +61 -7
  135. package/src/securekey/NativeSecureKey.ts +234 -25
  136. package/src/securekey/NativeSecureKeyBridge.ts +84 -4
  137. package/src/securekey/SecureKey.ts +138 -8
  138. package/src/securekey/alias.ts +11 -3
  139. package/src/securekey/ownerAuthKeyResolver.ts +63 -24
  140. package/src/securekey/registration.ts +40 -0
  141. package/src/securekey/resolveNativeBridge.ts +167 -9
  142. package/src/transport/headers.ts +47 -0
  143. package/src/wire/contractExecutionPayload.ts +152 -0
  144. package/src/wire/daaStatusCodes.ts +20 -3
  145. package/src/wire/deviceContextPayload.ts +9 -7
  146. package/src/wire/deviceRegistrationResultPayload.ts +156 -98
  147. package/src/wire/deviceStatusPayload.ts +68 -0
  148. package/src/wire/instant.ts +4 -1
  149. package/src/wire/pendingRegistrationPayload.ts +44 -1
  150. package/src/wire/socialLoginRequestPayload.ts +2 -25
  151. package/src/wire/transactionPayload.ts +40 -4
  152. package/build/auth/prepareReceipt.d.ts +0 -150
  153. package/build/auth/prepareReceipt.js +0 -357
  154. package/build/crypto/es256Jws.d.ts +0 -56
  155. package/build/crypto/es256Jws.js +0 -196
  156. package/src/auth/prepareReceipt.ts +0 -522
  157. package/src/crypto/es256Jws.ts +0 -240
package/build/config.js CHANGED
@@ -21,6 +21,7 @@ exports.DEVICE_KEY_POLICY = exports.DAA_ENVIRONMENTS = void 0;
21
21
  exports.isRecord = isRecord;
22
22
  exports.isRequiredDeviceKeyPolicy = isRequiredDeviceKeyPolicy;
23
23
  exports.assertDeviceKeyPolicy = assertDeviceKeyPolicy;
24
+ exports.assertAddDeviceApproval = assertAddDeviceApproval;
24
25
  exports.publicApiOriginFor = publicApiOriginFor;
25
26
  exports.assertPublicApiOrigin = assertPublicApiOrigin;
26
27
  /**
@@ -72,6 +73,20 @@ function assertDeviceKeyPolicy(value) {
72
73
  }
73
74
  return exports.DEVICE_KEY_POLICY;
74
75
  }
76
+ /**
77
+ * Runtime check for `addDeviceApproval`: `true`, `false`, or unset (off). A
78
+ * JS caller passing anything else (say, the string `'false'`) fails at
79
+ * construction instead of being read as on or off.
80
+ */
81
+ function assertAddDeviceApproval(value) {
82
+ if (value === undefined) {
83
+ return false;
84
+ }
85
+ if (typeof value !== 'boolean') {
86
+ throw new Error('DAA: addDeviceApproval must be a boolean');
87
+ }
88
+ return value;
89
+ }
75
90
  /** SDK-owned trust anchor used to authenticate absolute pagination links. */
76
91
  function publicApiOriginFor(environment) {
77
92
  return PUBLIC_API_ORIGINS[environment];
@@ -0,0 +1,47 @@
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
+ * The add-a-device matching code, shared with `DeviceApprovalMatchingCode` in
20
+ * daa-ios-sdk and its daa-android-sdk counterpart. The new device and the
21
+ * approving device must produce the same six digits from the same inputs; the
22
+ * tests pin the native SDKs' known-answer vector.
23
+ *
24
+ * All three inputs are 32 bytes: `thumbprint` is the new AuthKey's RFC 7638
25
+ * JWK thumbprint, `codeNonce` is the enclave's, and `codeSecret` is the new
26
+ * device's own random value.
27
+ */
28
+ /**
29
+ * `SHA-256("daa-device-code-seal-v1" || thumbprint || codeSecret)`: the
30
+ * commitment the new device signs into its registration as `codeSeal`, before
31
+ * the enclave picks `codeNonce`.
32
+ */
33
+ export declare function codeSeal(thumbprint: Uint8Array, codeSecret: Uint8Array): Uint8Array;
34
+ /**
35
+ * Six ASCII digits: the first four bytes of
36
+ * `SHA-256("daa-device-approval-v1" || thumbprint || codeNonce || codeSecret)`
37
+ * as a big-endian integer, modulo 1,000,000, zero-padded.
38
+ */
39
+ export declare function matchingCode(thumbprint: Uint8Array, codeNonce: Uint8Array, codeSecret: Uint8Array): string;
40
+ /**
41
+ * The 32 bytes a 43-character unpadded Base64URL value encodes, or `null` when
42
+ * it is any other length, uses another alphabet, or is not the canonical
43
+ * encoding (non-zero trailing bits). For the wire and native forms of the
44
+ * thumbprint and `codeNonce`, so a malformed value fails as the caller's typed
45
+ * error rather than as `fromBase64Url`'s plain `Error`.
46
+ */
47
+ export declare function canonicalBytes32(value: string): Uint8Array | null;
@@ -0,0 +1,93 @@
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.codeSeal = codeSeal;
21
+ exports.matchingCode = matchingCode;
22
+ exports.canonicalBytes32 = canonicalBytes32;
23
+ const errors_1 = require("../errors");
24
+ const base64url_1 = require("./base64url");
25
+ const sha256_1 = require("./sha256");
26
+ const SEAL_DOMAIN = new TextEncoder().encode('daa-device-code-seal-v1');
27
+ const CODE_DOMAIN = new TextEncoder().encode('daa-device-approval-v1');
28
+ /**
29
+ * The add-a-device matching code, shared with `DeviceApprovalMatchingCode` in
30
+ * daa-ios-sdk and its daa-android-sdk counterpart. The new device and the
31
+ * approving device must produce the same six digits from the same inputs; the
32
+ * tests pin the native SDKs' known-answer vector.
33
+ *
34
+ * All three inputs are 32 bytes: `thumbprint` is the new AuthKey's RFC 7638
35
+ * JWK thumbprint, `codeNonce` is the enclave's, and `codeSecret` is the new
36
+ * device's own random value.
37
+ */
38
+ /**
39
+ * `SHA-256("daa-device-code-seal-v1" || thumbprint || codeSecret)`: the
40
+ * commitment the new device signs into its registration as `codeSeal`, before
41
+ * the enclave picks `codeNonce`.
42
+ */
43
+ function codeSeal(thumbprint, codeSecret) {
44
+ requireBytes32(thumbprint, 'thumbprint');
45
+ requireBytes32(codeSecret, 'codeSecret');
46
+ return (0, sha256_1.sha256)(concat(SEAL_DOMAIN, thumbprint, codeSecret));
47
+ }
48
+ /**
49
+ * Six ASCII digits: the first four bytes of
50
+ * `SHA-256("daa-device-approval-v1" || thumbprint || codeNonce || codeSecret)`
51
+ * as a big-endian integer, modulo 1,000,000, zero-padded.
52
+ */
53
+ function matchingCode(thumbprint, codeNonce, codeSecret) {
54
+ requireBytes32(thumbprint, 'thumbprint');
55
+ requireBytes32(codeNonce, 'codeNonce');
56
+ requireBytes32(codeSecret, 'codeSecret');
57
+ const digest = (0, sha256_1.sha256)(concat(CODE_DOMAIN, thumbprint, codeNonce, codeSecret));
58
+ const value = new DataView(digest.buffer, digest.byteOffset, 4).getUint32(0);
59
+ return String(value % 1000000).padStart(6, '0');
60
+ }
61
+ /**
62
+ * The 32 bytes a 43-character unpadded Base64URL value encodes, or `null` when
63
+ * it is any other length, uses another alphabet, or is not the canonical
64
+ * encoding (non-zero trailing bits). For the wire and native forms of the
65
+ * thumbprint and `codeNonce`, so a malformed value fails as the caller's typed
66
+ * error rather than as `fromBase64Url`'s plain `Error`.
67
+ */
68
+ function canonicalBytes32(value) {
69
+ if (!BYTES32_BASE64URL.test(value)) {
70
+ return null;
71
+ }
72
+ try {
73
+ return (0, base64url_1.fromBase64Url)(value);
74
+ }
75
+ catch {
76
+ return null;
77
+ }
78
+ }
79
+ const BYTES32_BASE64URL = /^[A-Za-z0-9_-]{43}$/;
80
+ function requireBytes32(value, name) {
81
+ if (value.length !== 32) {
82
+ throw (0, errors_1.contractViolation)(`matching code input ${name} must be 32 bytes`);
83
+ }
84
+ }
85
+ function concat(...parts) {
86
+ const out = new Uint8Array(parts.reduce((total, part) => total + part.length, 0));
87
+ let offset = 0;
88
+ for (const part of parts) {
89
+ out.set(part, offset);
90
+ offset += part.length;
91
+ }
92
+ return out;
93
+ }
package/build/errors.d.ts CHANGED
@@ -26,14 +26,18 @@ export type DaaSdkError = {
26
26
  retryable: boolean;
27
27
  } | {
28
28
  kind: 'local_user_authentication_required';
29
+ } | {
30
+ kind: 'device_lock_not_set';
31
+ } | {
32
+ kind: 'device_not_supported';
33
+ } | {
34
+ kind: 'key_invalidated';
29
35
  } | {
30
36
  kind: 'login_request_expired';
31
37
  } | {
32
38
  kind: 'owner_grant_invalid';
33
39
  } | {
34
40
  kind: 'owner_grant_expired';
35
- } | {
36
- kind: 'prepare_receipt_invalid';
37
41
  } | {
38
42
  kind: 'owner_binding_invalid';
39
43
  } | {
@@ -47,6 +51,41 @@ export type DaaSdkError = {
47
51
  } | {
48
52
  kind: 'contract_violation';
49
53
  correlationId?: string;
54
+ } | {
55
+ kind: 'clock_skew';
56
+ correlationId?: string;
57
+ } | {
58
+ kind: 'user_cancelled';
59
+ } | {
60
+ kind: 'device_registration_limit';
61
+ retryAfterSeconds?: number;
62
+ correlationId?: string;
63
+ } | {
64
+ kind: 'device_denied';
65
+ correlationId?: string;
66
+ } | {
67
+ kind: 'device_approval_conflict';
68
+ correlationId?: string;
69
+ } | {
70
+ kind: 'device_approval_unavailable';
71
+ correlationId?: string;
72
+ } | {
73
+ kind: 'registration_not_saved';
74
+ } | {
75
+ kind: 'matching_code_unavailable';
76
+ } | {
77
+ kind: 'matching_code_mismatch';
78
+ } | {
79
+ kind: 'device_approval_not_ready';
80
+ } | {
81
+ kind: 'device_approval_invalid';
82
+ correlationId?: string;
83
+ } | {
84
+ kind: 'device_approval_busy';
85
+ correlationId?: string;
86
+ } | {
87
+ kind: 'device_pending';
88
+ correlationId?: string;
50
89
  };
51
90
  /**
52
91
  * An Error carrying a structured `DaaSdkError`. The SDK throws this so callers
@@ -135,35 +174,6 @@ export declare function transportFailure(cause: unknown, idempotencyKey?: string
135
174
  * {@link idempotencyConflict}), and this variant does not.
136
175
  */
137
176
  export declare function loginRequestExpired(correlationId: string | null): DaaError;
138
- /**
139
- * The Prepare receipt could not be verified: it is missing where one is
140
- * required, malformed, signed by no pinned key, bound to values other than this
141
- * attempt's, outside its validity window, or the platform verifier is missing
142
- * or failed.
143
- *
144
- * On the login path this is raised only when a trust anchor is pinned for the
145
- * environment: the SDK then verifies the receipt and fails closed on any
146
- * mismatch, and nothing from that Prepare response reaches the application.
147
- * With no anchor pinned, the receipt is ignored. Not retryable in place: the
148
- * caller's recovery is a new `prepareSocialLogin`, which sends a fresh
149
- * challenge and flow key. A failure that persists across fresh attempts points
150
- * at the relay or at trust material that does not match the service's signer,
151
- * not at the user.
152
- *
153
- * The receipt is unverified server-supplied text and never goes into the
154
- * message; `message` here is one of the SDK's own literals.
155
- */
156
- export declare function prepareReceiptInvalid(message: string, cause?: unknown): DaaError;
157
- /**
158
- * The same error with the response's `X-Request-Id` named in its message.
159
- *
160
- * For a check that runs on a decoded response without seeing the response
161
- * itself — the Prepare receipt's verification has many throw sites and none of
162
- * them holds the headers — so the caller that does hold the response adds the
163
- * id once. The detail, the cause, and the stack of the check that threw are
164
- * unchanged.
165
- */
166
- export declare function withRequestId(err: DaaError, correlationId: string | null): DaaError;
167
177
  /**
168
178
  * An idempotency key was reused with different request bytes: a `409` with
169
179
  * `IDEMPOTENCY_KEY_REUSED` (`420034`). Another `409` is not this error.
@@ -177,6 +187,112 @@ export declare function withRequestId(err: DaaError, correlationId: string | nul
177
187
  * `idempotency_conflict` also carries it, as an optional field.
178
188
  */
179
189
  export declare function idempotencyConflict(idempotencyKey: string, correlationId: string | null): DaaError;
190
+ /**
191
+ * DAA refused a registered-device authorization as invalid
192
+ * (`DEVICE_AUTHORIZATION_INVALID`), and the authorization's own `iat`/`exp`
193
+ * fail DAA's 60-second freshness rule against the response's HTTP `Date`.
194
+ *
195
+ * The device clock was wrong when the authorization was signed, so the
196
+ * recovery is to correct the device time and send a newly signed request — not
197
+ * to treat the AuthKey as rejected. A prepared contract execution cannot be
198
+ * re-signed: `submit` resends the authorization made at `prepare`, so correcting
199
+ * the clock does not help it; prepare a new execution instead, as for an expired
200
+ * authorization (see `ContractExecutionsClient.submit`). `Date` is not signed,
201
+ * so it is used only to choose this classification; its value is not carried on
202
+ * the error.
203
+ */
204
+ export declare function clockSkew(correlationId: string | null): DaaError;
205
+ /**
206
+ * The user dismissed the device's user-authentication prompt (biometrics or
207
+ * device credential) for an AuthKey operation.
208
+ *
209
+ * Deliberate user intent, not a credential problem: the AuthKey is untouched
210
+ * and nothing was sent. The caller keeps the key and lets the user try again
211
+ * when they choose. For a signed request, that means sending it again. For
212
+ * Device Registration Complete the pending registration is used up, so trying
213
+ * again means a new login started by the user. That login reuses the same
214
+ * AuthKey.
215
+ */
216
+ export declare function userCancelled(cause?: unknown): DaaError;
217
+ /**
218
+ * DAA refused a signed request because the signing key can't sign yet
219
+ * (`DEVICE_PENDING`, `420118`, `409`): it was approved from another device and
220
+ * is in the account's cool-down until its `readyAt`, or it is still waiting
221
+ * for approval. `restore`, `refreshContext` and every signed write report it.
222
+ * Nothing changed on DAA and the key stays valid: keep it, wait (follow
223
+ * `watchDeviceStatus` until `active`), then call `restore` again. Never
224
+ * `forgetLocalKey` or start a new login for it.
225
+ */
226
+ export declare function devicePending(correlationId?: string | null): DaaError;
227
+ /**
228
+ * This device can't show the matching code for its add-a-device request: DAA
229
+ * returned the request with a `codeSeal` that this device's code secret
230
+ * doesn't open. The request was sealed with a secret this SDK no longer holds
231
+ * (the app restarted while it was waiting, or a registration that timed out
232
+ * reached DAA late). A code shown now could never match, so
233
+ * `PendingDeviceApproval.getMatchingCode()` and `sendCodeSecret()` throw this
234
+ * instead, and nothing is sent. Tell the user to wait until the request's
235
+ * `expiresAt` and sign in again: that opens a new request this device can show
236
+ * the code for.
237
+ */
238
+ export declare function matchingCodeUnavailable(): DaaError;
239
+ /**
240
+ * Device Registration Complete succeeded, and DAA has this device's AuthKey
241
+ * `ACTIVE` (or `PENDING_ACTIVATION`), but saving the `authKeyId` and
242
+ * `ownerBindingId` it returned on this device failed (for example a Keychain or
243
+ * Keystore write error). Until they are saved, session restore can't find the key, and a new login with it fails with
244
+ * DAA's `AUTH_KEY_BINDING_CONFLICT`. Call `complete()` on the same
245
+ * `PendingDeviceRegistration` again: it sends nothing and retries only the save.
246
+ * The native error is on `cause`, never in the message. A save that fails
247
+ * because the key is gone (`key_invalidated`, `device_not_initialized`) throws
248
+ * that kind instead: retrying could never succeed.
249
+ */
250
+ export declare function registrationNotSaved(cause: unknown): DaaError;
251
+ /**
252
+ * The add-a-device states Device Registration Complete can refuse with, by the
253
+ * DAA code it sends. What the app does next differs for each:
254
+ *
255
+ * - `device_registration_limit` (`DEVICE_REGISTRATION_LIMIT`, `420109`, `429`):
256
+ * the account had 5 add-a-device requests in the last 10 minutes. Wait
257
+ * `retryAfterSeconds` (from `Retry-After`, when the response has a whole
258
+ * number of seconds there) and sign in again.
259
+ * - `device_denied` (`DEVICE_DENIED`, `420111`, `403`): the user declined this
260
+ * key with Not me on another device, so this key can't ask again.
261
+ * - `device_approval_conflict` (`DEVICE_APPROVAL_CONFLICT`, `420112`, `409`):
262
+ * another new device was already waiting, so DAA cancelled both requests.
263
+ * Both devices must sign in again.
264
+ * - `device_approval_unavailable` (`DEVICE_APPROVAL_UNAVAILABLE`, `420113`,
265
+ * `409`): the account has no active device that could approve this one. If a
266
+ * device is in its cool-down, signing in again after it ends works;
267
+ * otherwise the user must recover the account.
268
+ *
269
+ * In every case this `PendingDeviceRegistration` is used up: trying again
270
+ * needs a new login.
271
+ * `correlationId`, the response's `X-Request-Id`, goes on the detail and in
272
+ * the message, as on `contract_violation`.
273
+ */
274
+ export declare function deviceRegistrationFailure(kind: 'device_registration_limit' | 'device_denied' | 'device_approval_conflict' | 'device_approval_unavailable', correlationId: string | null, retryAfterSeconds?: number | null): DaaError;
275
+ /**
276
+ * Why `DaaUserClient.approveDevice` refused, and what the app does next:
277
+ *
278
+ * - `matching_code_mismatch` (local): the code the user typed is not the one
279
+ * the new device shows. Nothing was signed or sent, and no biometric prompt
280
+ * was shown. Let the user type it again.
281
+ * - `device_approval_not_ready` (local): the new device has not sent its code
282
+ * secret yet, so the code can't be checked. Nothing was signed or sent.
283
+ * Try again in a few seconds.
284
+ * - `device_approval_invalid` (`DEVICE_APPROVAL_INVALID`, `420117`, `409`, or
285
+ * the request is no longer in the device list): the request is not waiting
286
+ * any more. It expired, was decided on another device, or was cancelled.
287
+ * Don't retry; the new device signs in again if the user still wants it.
288
+ * - `device_approval_busy` (`DEVICE_APPROVAL_BUSY`, `420120`, `409`): the
289
+ * account changed while DAA was approving. Call `approveDevice` again; it
290
+ * signs the same approval body again, so the user sees the biometric prompt again.
291
+ *
292
+ * `correlationId`, the response's `X-Request-Id`, goes on the two DAA kinds'
293
+ * detail and in the message, as on `contract_violation`.
294
+ */
295
+ export declare function deviceApprovalFailure(kind: 'matching_code_mismatch' | 'device_approval_not_ready' | 'device_approval_invalid' | 'device_approval_busy', correlationId?: string | null, cause?: unknown): DaaError;
180
296
  /**
181
297
  * Map an error thrown by the native secure-key module onto `DaaSdkError`. The
182
298
  * raw native message is never propagated into `.message` — it can contain
@@ -184,7 +300,8 @@ export declare function idempotencyConflict(idempotencyKey: string, correlationI
184
300
  * as `.cause` for deliberate inspection.
185
301
  *
186
302
  * An already-structured `DaaError` passes through unchanged. Otherwise a stable
187
- * `code` on the native error maps the known custody states; anything else
188
- * collapses to `contract_violation`.
303
+ * native code (the error's `code`, or on iOS the `[CODE]` tag on the innermost
304
+ * cause) maps the known custody states; anything else collapses to
305
+ * `contract_violation`.
189
306
  */
190
307
  export declare function mapNativeError(err: unknown): DaaError;