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