@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
@@ -0,0 +1,128 @@
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
+ import { toBase64Url } from '../crypto/base64url'
20
+ import { contractViolation } from '../errors'
21
+ import { REDACTED } from './redaction'
22
+
23
+ // A contract execution that has been serialized and Owner-authorized once, and
24
+ // can be sent — and re-sent — exactly as authorized.
25
+ //
26
+ // DAA identifies an accepted execution by its idempotency key and the SHA-256
27
+ // of the exact request body, and requires the originally accepted Owner
28
+ // authorization on a replay. A retry that re-serialized the body, or that
29
+ // signed a fresh `X-Device-Authorization` with a new `jti`, would be a
30
+ // different request: a `409` at best, a second Owner approval at worst. So the
31
+ // SDK separates the two steps. `ContractExecutionsClient.prepare` serializes
32
+ // and signs exactly once; `submit` sends those bytes and that header, unchanged,
33
+ // as many times as the caller needs to learn the outcome.
34
+ //
35
+ // The authorization expires five minutes after it is signed, and that does not
36
+ // make a prepared execution useless. An exact replay of a request DAA already
37
+ // accepted returns the stored execution even after the JWS has expired. One DAA
38
+ // never accepted is refused, and the recovery is a new execution with a new
39
+ // idempotency key — never a fresh signature over the old one. `submit`
40
+ // therefore never checks expiry and never signs.
41
+
42
+ /**
43
+ * A prepared execution in a form an app can store across a restart.
44
+ *
45
+ * `body` is the exact signed request body, base64url-encoded so the bytes
46
+ * survive storage unchanged. `authorization` is the compact Owner JWS bound to
47
+ * those bytes. It authorizes this one request only, but store the record as
48
+ * you would any credential-bearing value, and delete it once the execution is
49
+ * terminal.
50
+ */
51
+ export type PersistedContractExecution = Readonly<{
52
+ version: 1
53
+ body: string
54
+ authorization: string
55
+ }>
56
+
57
+ /** The redacted shape `JSON.stringify(prepared)` produces. */
58
+ export type PreparedContractExecutionRendering = {
59
+ readonly idempotencyKey: string
60
+ readonly body: string
61
+ readonly authorization: string
62
+ }
63
+
64
+ type PreparedParts = Readonly<{ bodyBytes: Uint8Array; authorization: string }>
65
+
66
+ // Module-private, so the bytes and the header are reachable only by the
67
+ // client that sends them and by `toPersisted`, never through a property a
68
+ // logger or a spread would walk.
69
+ const PARTS = new WeakMap<PreparedContractExecution, PreparedParts>()
70
+
71
+ /**
72
+ * A serialized, Owner-authorized contract execution request.
73
+ *
74
+ * Send it with `ContractExecutionsClient.submit`. After a transport failure, a
75
+ * `5xx`, or an app restart, submit the same instance (or the one
76
+ * `ContractExecutionsClient.restore` rebuilds from {@link toPersisted}) again:
77
+ * the retry carries identical bytes and the identical authorization.
78
+ *
79
+ * Not constructible by a consumer: exported from `index.ts` as a type only.
80
+ */
81
+ export class PreparedContractExecution {
82
+ /** The request's idempotency key, which is also the JWS `idempotency_key` claim. */
83
+ readonly idempotencyKey: string
84
+
85
+ /** @internal Constructed only by `ContractExecutionsClient`. */
86
+ constructor(fields: { idempotencyKey: string; bodyBytes: Uint8Array; authorization: string }) {
87
+ this.idempotencyKey = fields.idempotencyKey
88
+ PARTS.set(
89
+ this,
90
+ Object.freeze({
91
+ // A private copy, so neither the caller of the constructor nor a
92
+ // reader of `toPersisted` can change the bytes a later retry sends.
93
+ bodyBytes: fields.bodyBytes.slice(),
94
+ authorization: fields.authorization,
95
+ }),
96
+ )
97
+ Object.freeze(this)
98
+ }
99
+
100
+ /** The record to store for a retry after restart. See {@link PersistedContractExecution}. */
101
+ toPersisted(): PersistedContractExecution {
102
+ const parts = preparedParts(this)
103
+ return Object.freeze({
104
+ version: 1 as const,
105
+ body: toBase64Url(parts.bodyBytes),
106
+ authorization: parts.authorization,
107
+ })
108
+ }
109
+
110
+ /** The key renders; the body and the authorization do not. */
111
+ toJSON(): PreparedContractExecutionRendering {
112
+ return { idempotencyKey: this.idempotencyKey, body: REDACTED, authorization: REDACTED }
113
+ }
114
+
115
+ /** The key prints; the body and the authorization do not. */
116
+ toString(): string {
117
+ return `PreparedContractExecution(idempotencyKey=${this.idempotencyKey}, body=${REDACTED}, authorization=${REDACTED})`
118
+ }
119
+ }
120
+
121
+ /** @internal The exact bytes and header a prepared execution sends. A copy of the bytes. */
122
+ export function preparedParts(prepared: PreparedContractExecution): PreparedParts {
123
+ const parts = PARTS.get(prepared)
124
+ if (parts === undefined) {
125
+ throw contractViolation('not a PreparedContractExecution this SDK prepared or restored')
126
+ }
127
+ return Object.freeze({ bodyBytes: parts.bodyBytes.slice(), authorization: parts.authorization })
128
+ }
@@ -43,7 +43,7 @@ const ID_TOKEN_MAX_LENGTH = 16384
43
43
  /**
44
44
  * A prepared social login: `PreparedSocialLogin`.
45
45
  *
46
- * The five public fields are what the consuming application carries through its
46
+ * The four public fields are what the consuming application carries through its
47
47
  * own provider login. There is deliberately no AuthKey field of any kind — no
48
48
  * `authKeyId`, no thumbprint — because AuthKey selection happens *after* the
49
49
  * Social Session response, so at this point in the flow no AuthKey has been
@@ -70,12 +70,6 @@ const ID_TOKEN_MAX_LENGTH = 16384
70
70
  * {@link PreparedSocialLogin.abandon} when the user backs out so the native
71
71
  * flow-key cache is dropped; dropping this object alone does not.
72
72
  *
73
- * `AuthClient.prepareSocialLogin` checks the Prepare receipt before it
74
- * constructs this object (`auth/prepareReceipt.ts`, `checkPrepareReceipt`), so
75
- * an instance only exists for a response that passed that check. Session does
76
- * not consume receipt claims: it sends `loginRequestId` plus the application's
77
- * `idToken` and `clientEntityId`.
78
- *
79
73
  * Not constructible by a consumer: exported from `index.ts` as a type only, and
80
74
  * the `#` private fields make the type nominal.
81
75
  */
@@ -84,32 +78,23 @@ export class PreparedSocialLogin {
84
78
  readonly loginRequestId: string
85
79
 
86
80
  /**
87
- * Single-use nonce the application supplies to the social provider. Only a
88
- * verified receipt's `nonce` claim binds it to `loginRequestId`, and no
89
- * receipt trust anchor is pinned in this release, so it is unauthenticated
90
- * relay output. Do not treat it as proof that the login request came from
91
- * Circle: bind the login with the application's own OAuth `state` and its
92
- * authenticated session with its backend.
81
+ * Single-use nonce the application supplies to the social provider. The SDK
82
+ * reaches DAA through the application's own backend and does not
83
+ * authenticate this value, so it is unauthenticated relay output. Do not
84
+ * treat it as proof that the login request came from Circle: bind the login
85
+ * with the application's own OAuth `state` and its authenticated session
86
+ * with its backend.
93
87
  */
94
88
  readonly oidcNonce: string
95
89
 
96
90
  /**
97
91
  * DAA correlation to bind inside or alongside the application's own OAuth
98
92
  * CSRF state. Per the contract it "must not replace app-owned redirect
99
- * protection". The receipt does not bind it: DAA signs no state claim, so it
100
- * is unauthenticated whether or not a trust anchor is pinned. The
101
- * application's own `state` is the primary binding for the provider redirect.
93
+ * protection". The SDK does not authenticate it either. The application's own
94
+ * `state` is the primary binding for the provider redirect.
102
95
  */
103
96
  readonly oidcState: string
104
97
 
105
- /**
106
- * The DAA-signed Prepare receipt, verified before this object exists. Null
107
- * when no trust anchor is pinned for the environment, which is every
108
- * environment in this release: the SDK then ignores any receipt the service
109
- * sends, and does not hand on one it has not checked.
110
- */
111
- readonly prepareReceiptJws: string | null
112
-
113
98
  /**
114
99
  * When the login request expires, as ISO-8601 text. The contract declares that
115
100
  * string form and the running service sends epoch milliseconds, so the decoder
@@ -123,6 +108,8 @@ export class PreparedSocialLogin {
123
108
  readonly #idempotencyKey: string
124
109
  readonly #transport: DaaTransport
125
110
  readonly #resolveAuthKey: (clientEntityId: string) => Promise<OwnerAuthKey>
111
+ readonly #hasRegisteredAuthKey: (clientEntityId: string) => Promise<boolean>
112
+ readonly #addDeviceApproval: boolean
126
113
  #sessionConsumed = false
127
114
 
128
115
  /** @internal Constructed only by `AuthClient.prepareSocialLogin`. */
@@ -130,24 +117,26 @@ export class PreparedSocialLogin {
130
117
  readonly loginRequestId: string
131
118
  readonly oidcNonce: string
132
119
  readonly oidcState: string
133
- readonly prepareReceiptJws: string | null
134
120
  readonly expiresAt: string
135
121
  readonly registrationCodeVerifier: string
136
122
  readonly registrationFlowKey: RegistrationFlowKey
137
123
  readonly idempotencyKey: string
138
124
  readonly transport: DaaTransport
139
125
  readonly resolveAuthKey: (clientEntityId: string) => Promise<OwnerAuthKey>
126
+ readonly hasRegisteredAuthKey: (clientEntityId: string) => Promise<boolean>
127
+ readonly addDeviceApproval: boolean
140
128
  }) {
141
129
  this.loginRequestId = fields.loginRequestId
142
130
  this.oidcNonce = fields.oidcNonce
143
131
  this.oidcState = fields.oidcState
144
- this.prepareReceiptJws = fields.prepareReceiptJws
145
132
  this.expiresAt = fields.expiresAt
146
133
  this.#registrationCodeVerifier = fields.registrationCodeVerifier
147
134
  this.#registrationFlowKey = fields.registrationFlowKey
148
135
  this.#idempotencyKey = fields.idempotencyKey
149
136
  this.#transport = fields.transport
150
137
  this.#resolveAuthKey = fields.resolveAuthKey
138
+ this.#hasRegisteredAuthKey = fields.hasRegisteredAuthKey
139
+ this.#addDeviceApproval = fields.addDeviceApproval
151
140
  Object.freeze(this)
152
141
  }
153
142
 
@@ -157,6 +146,11 @@ export class PreparedSocialLogin {
157
146
  *
158
147
  * AuthKey selection happens only after a successful response, then the
159
148
  * returned `PendingDeviceRegistration` can call Device Registration Complete.
149
+ * With `addDeviceApproval` on, when DAA says a new device would wait for
150
+ * approval and this device has no registered AuthKey for the end user, no key
151
+ * is selected or created here: the result has `confirmationRequired: true`,
152
+ * and `complete({ confirmAddDevice: true })` creates the key once the user
153
+ * confirms (see `PendingDeviceRegistration`).
160
154
  *
161
155
  * `clientEntityId` is required, and there is no resolve-or-create fallback
162
156
  * behind it: the service refuses a Session that omits it. The value names an
@@ -255,18 +249,33 @@ export class PreparedSocialLogin {
255
249
  // because the service is what validates and binds that value; it is the
256
250
  // server-confirmed identity the rest of the ceremony, and every later
257
251
  // `forUser` re-resolution, is checked against.
258
- const authKey = await this.#resolveAuthKey(pending.clientEntityId)
252
+ const boundEntityId = pending.clientEntityId
253
+ const resolveAuthKey = () => this.#resolveAuthKey(boundEntityId)
254
+ // A new device that would wait for approval: ask the user before a key
255
+ // exists. Without a registered key here, `complete()` creates one only
256
+ // once the app passes the user's confirmation. A registered key (active,
257
+ // or approved and in its cool-down) is resolved now as before, and DAA's
258
+ // registration answer decides. With the switch off the hint is ignored,
259
+ // as `codeSeal` is.
260
+ const confirmationRequired =
261
+ this.#addDeviceApproval &&
262
+ pending.deviceApproval?.required === true &&
263
+ !(await this.#hasRegisteredAuthKey(boundEntityId))
259
264
  return new PendingDeviceRegistration({
260
265
  registrationHandle: pending.registrationHandle,
261
266
  // The service's own echo of the bound entity, decoded from the response,
262
267
  // not the argument this method was handed. The response field is what the
263
268
  // rest of the ceremony is checked against, so it stays the one source.
264
- clientEntityId: pending.clientEntityId,
269
+ clientEntityId: boundEntityId,
265
270
  expiresAt: pending.expiresAt,
271
+ deviceApproval: pending.deviceApproval,
272
+ confirmationRequired,
266
273
  transport: this.#transport,
267
274
  registrationCodeVerifier: this.#registrationCodeVerifier,
268
275
  registrationFlowKey: this.#registrationFlowKey,
269
- authKey,
276
+ authKey: confirmationRequired ? null : await resolveAuthKey(),
277
+ resolveAuthKey,
278
+ addDeviceApproval: this.#addDeviceApproval,
270
279
  })
271
280
  } catch (error) {
272
281
  await releaseQuietly(this.#registrationFlowKey)
@@ -277,8 +286,9 @@ export class PreparedSocialLogin {
277
286
  /**
278
287
  * Drop the native registration-flow key for this attempt.
279
288
  *
280
- * Call this when the user backs out of provider login. The JS handle going out
281
- * of scope does not clear the native process cache. Safe to call more than
289
+ * Call this when the user backs out of provider login, or declines adding
290
+ * this device after `completeSocialSession` (`confirmationRequired`). The JS
291
+ * handle going out of scope does not clear the native process cache. Safe to call more than
282
292
  * once. After this, the attempt cannot proceed to Registration Complete.
283
293
  */
284
294
  async abandon(): Promise<void> {
@@ -28,6 +28,8 @@ import { REDACTED } from './redaction'
28
28
  // `GET /v1/accounts/transactions`. Unlike `Transfer`, a transaction leg may be
29
29
  // a fiat rail (`wire`/`ach`), and both `source` and `destination` are optional
30
30
  // ("present when available"). `status` adds `returned` over the transfer set.
31
+ // A `contract_execution` row also carries a bounded `contractExecution`
32
+ // summary; every other row has none.
31
33
 
32
34
  /**
33
35
  * Where a transaction is in its lifecycle (OpenAPI `TransactionStatus`).
@@ -56,6 +58,7 @@ export type TransactionType =
56
58
  | { readonly kind: 'fx' }
57
59
  | { readonly kind: 'fee' }
58
60
  | { readonly kind: 'credit' }
61
+ | { readonly kind: 'contract_execution' }
59
62
  | { readonly kind: 'other' }
60
63
  | { readonly kind: 'unrecognized'; readonly rawValue: string | null }
61
64
 
@@ -158,6 +161,69 @@ export type TransactionLocation =
158
161
  | TransactionFiatLocation
159
162
  | { readonly kind: 'unrecognized'; readonly rawValue: string | null }
160
163
 
164
+ /** The redacted shape `JSON.stringify`/`toString` produce for a contract-execution summary. */
165
+ export type TransactionContractExecutionRendering = {
166
+ readonly id: string
167
+ readonly blockchain: string
168
+ readonly contractAddress: string
169
+ readonly functionSelector: string | null
170
+ }
171
+
172
+ /**
173
+ * The bounded contract-execution summary on a `contract_execution` activity row
174
+ * (OpenAPI `ContractExecutionActivityDetails`). Full ABI parameters and raw
175
+ * calldata are not part of the activity row; read them with
176
+ * `ContractExecutionsClient.get(id)`.
177
+ *
178
+ * `id`, `blockchain`, and `contractAddress` are required once the summary is
179
+ * present; `functionSelector` (`0x` plus eight hex digits) is optional and
180
+ * decodes to `null` when absent. `blockchain` is a closed set on the service,
181
+ * but it is read as a string here, the same way a blockchain leg's `chain` is,
182
+ * so a chain added later does not fail the row.
183
+ *
184
+ * `contractAddress` is redacted the same way a blockchain leg's `address` is.
185
+ */
186
+ export class TransactionContractExecution {
187
+ readonly id: string
188
+ readonly blockchain: string
189
+ readonly functionSelector: string | null
190
+ readonly #contractAddress: string
191
+
192
+ /** @internal Constructed only by the SDK's response decoder. */
193
+ constructor(fields: {
194
+ id: string
195
+ blockchain: string
196
+ contractAddress: string
197
+ functionSelector: string | null
198
+ }) {
199
+ this.id = fields.id
200
+ this.blockchain = fields.blockchain
201
+ this.functionSelector = fields.functionSelector
202
+ this.#contractAddress = fields.contractAddress
203
+ Object.freeze(this)
204
+ }
205
+
206
+ get contractAddress(): string {
207
+ return this.#contractAddress
208
+ }
209
+
210
+ toJSON(): TransactionContractExecutionRendering {
211
+ return {
212
+ id: this.id,
213
+ blockchain: this.blockchain,
214
+ contractAddress: REDACTED,
215
+ functionSelector: this.functionSelector,
216
+ }
217
+ }
218
+
219
+ toString(): string {
220
+ return (
221
+ `TransactionContractExecution(id=${this.id}, blockchain=${this.blockchain}, ` +
222
+ `contractAddress=${REDACTED}, functionSelector=${this.functionSelector ?? 'null'})`
223
+ )
224
+ }
225
+ }
226
+
161
227
  /** The redacted shape `JSON.stringify(transaction)` produces. */
162
228
  export type TransactionRendering = {
163
229
  readonly id: string
@@ -166,6 +232,7 @@ export type TransactionRendering = {
166
232
  readonly amount: { readonly amount: string; readonly currency: string }
167
233
  readonly source: TransactionLocation | null
168
234
  readonly destination: TransactionLocation | null
235
+ readonly contractExecution: TransactionContractExecutionRendering | null
169
236
  readonly createDate: string
170
237
  readonly updateDate: string
171
238
  }
@@ -180,11 +247,15 @@ export type TransactionRendering = {
180
247
  * `updateDate`. Those six are marked required, and every service path that
181
248
  * produces a transaction always sets them. `source` and `destination` are
182
249
  * documented "when available", and the service omits an absent leg rather than
183
- * sending JSON `null`.
250
+ * sending JSON `null`. `contractExecution` is present only on a
251
+ * `contract_execution` row (the service sends it on no other type) and is
252
+ * `null` when absent; on such a row
253
+ * `amount` is the requested native value, which may be `"0"`.
184
254
  *
185
255
  * **`amount` does not appear in any default rendering.** It sits behind a
186
256
  * prototype accessor, so `Object.keys`, `JSON.stringify`, spread, `for...in`,
187
- * and `console.log` do not reach it. A blockchain leg redacts its own address.
257
+ * and `console.log` do not reach it. A blockchain leg redacts its own address,
258
+ * and a contract-execution summary redacts its contract address.
188
259
  *
189
260
  * Not constructible by a consumer: exported from `index.ts` as a type only,
190
261
  * and the `#amount` field makes the type nominal.
@@ -195,6 +266,7 @@ export class Transaction {
195
266
  readonly status: TransactionStatus
196
267
  readonly source: TransactionLocation | null
197
268
  readonly destination: TransactionLocation | null
269
+ readonly contractExecution: TransactionContractExecution | null
198
270
  readonly createDate: string
199
271
  readonly updateDate: string
200
272
  readonly #amount: Money
@@ -207,6 +279,7 @@ export class Transaction {
207
279
  readonly amount: Money
208
280
  readonly source: TransactionLocation | null
209
281
  readonly destination: TransactionLocation | null
282
+ readonly contractExecution: TransactionContractExecution | null
210
283
  readonly createDate: string
211
284
  readonly updateDate: string
212
285
  }) {
@@ -215,6 +288,7 @@ export class Transaction {
215
288
  this.status = fields.status
216
289
  this.source = fields.source
217
290
  this.destination = fields.destination
291
+ this.contractExecution = fields.contractExecution
218
292
  this.createDate = fields.createDate
219
293
  this.updateDate = fields.updateDate
220
294
  this.#amount = fields.amount
@@ -233,6 +307,7 @@ export class Transaction {
233
307
  amount: this.#amount.toJSON(),
234
308
  source: this.source,
235
309
  destination: this.destination,
310
+ contractExecution: this.contractExecution === null ? null : this.contractExecution.toJSON(),
236
311
  createDate: this.createDate,
237
312
  updateDate: this.updateDate,
238
313
  }