@v3finance/core-sdk 0.4.0 → 0.6.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 (175) hide show
  1. package/CHANGELOG.md +185 -0
  2. package/README.md +18 -14
  3. package/dist/cjs/client.d.ts +30 -34
  4. package/dist/cjs/client.d.ts.map +1 -1
  5. package/dist/cjs/client.js +71 -0
  6. package/dist/cjs/client.js.map +1 -1
  7. package/dist/cjs/core/gated.d.ts +12 -10
  8. package/dist/cjs/core/gated.d.ts.map +1 -1
  9. package/dist/cjs/core/gated.js +12 -10
  10. package/dist/cjs/core/gated.js.map +1 -1
  11. package/dist/cjs/core/http.d.ts +18 -0
  12. package/dist/cjs/core/http.d.ts.map +1 -1
  13. package/dist/cjs/core/http.js +11 -1
  14. package/dist/cjs/core/http.js.map +1 -1
  15. package/dist/cjs/core/pagination.d.ts +11 -9
  16. package/dist/cjs/core/pagination.d.ts.map +1 -1
  17. package/dist/cjs/core/pagination.js +11 -9
  18. package/dist/cjs/core/pagination.js.map +1 -1
  19. package/dist/cjs/generated/operations.d.ts +250 -2
  20. package/dist/cjs/generated/operations.d.ts.map +1 -1
  21. package/dist/cjs/generated/operations.js +252 -4
  22. package/dist/cjs/generated/operations.js.map +1 -1
  23. package/dist/cjs/generated/types.d.ts +1137 -113
  24. package/dist/cjs/generated/types.d.ts.map +1 -1
  25. package/dist/cjs/index.d.ts +7 -6
  26. package/dist/cjs/index.d.ts.map +1 -1
  27. package/dist/cjs/index.js +3 -1
  28. package/dist/cjs/index.js.map +1 -1
  29. package/dist/cjs/resources/addresses.d.ts +91 -4
  30. package/dist/cjs/resources/addresses.d.ts.map +1 -1
  31. package/dist/cjs/resources/addresses.js +55 -3
  32. package/dist/cjs/resources/addresses.js.map +1 -1
  33. package/dist/cjs/resources/admin.d.ts +32 -1
  34. package/dist/cjs/resources/admin.d.ts.map +1 -1
  35. package/dist/cjs/resources/admin.js +45 -0
  36. package/dist/cjs/resources/admin.js.map +1 -1
  37. package/dist/cjs/resources/aml.d.ts +56 -0
  38. package/dist/cjs/resources/aml.d.ts.map +1 -0
  39. package/dist/cjs/resources/aml.js +71 -0
  40. package/dist/cjs/resources/aml.js.map +1 -0
  41. package/dist/cjs/resources/approvals.d.ts +30 -2
  42. package/dist/cjs/resources/approvals.d.ts.map +1 -1
  43. package/dist/cjs/resources/approvals.js.map +1 -1
  44. package/dist/cjs/resources/balances.d.ts +14 -7
  45. package/dist/cjs/resources/balances.d.ts.map +1 -1
  46. package/dist/cjs/resources/balances.js +10 -4
  47. package/dist/cjs/resources/balances.js.map +1 -1
  48. package/dist/cjs/resources/categories.d.ts +20 -6
  49. package/dist/cjs/resources/categories.d.ts.map +1 -1
  50. package/dist/cjs/resources/categories.js +19 -7
  51. package/dist/cjs/resources/categories.js.map +1 -1
  52. package/dist/cjs/resources/counterparties.d.ts +52 -6
  53. package/dist/cjs/resources/counterparties.d.ts.map +1 -1
  54. package/dist/cjs/resources/counterparties.js +24 -0
  55. package/dist/cjs/resources/counterparties.js.map +1 -1
  56. package/dist/cjs/resources/history.d.ts +227 -26
  57. package/dist/cjs/resources/history.d.ts.map +1 -1
  58. package/dist/cjs/resources/history.js +46 -0
  59. package/dist/cjs/resources/history.js.map +1 -1
  60. package/dist/cjs/resources/me.d.ts +17 -1
  61. package/dist/cjs/resources/me.d.ts.map +1 -1
  62. package/dist/cjs/resources/me.js +19 -0
  63. package/dist/cjs/resources/me.js.map +1 -1
  64. package/dist/cjs/resources/members.d.ts +21 -1
  65. package/dist/cjs/resources/members.d.ts.map +1 -1
  66. package/dist/cjs/resources/members.js +15 -0
  67. package/dist/cjs/resources/members.js.map +1 -1
  68. package/dist/cjs/resources/operations.d.ts +179 -4
  69. package/dist/cjs/resources/operations.d.ts.map +1 -1
  70. package/dist/cjs/resources/operations.js +192 -2
  71. package/dist/cjs/resources/operations.js.map +1 -1
  72. package/dist/cjs/resources/registries.d.ts +28 -2
  73. package/dist/cjs/resources/registries.d.ts.map +1 -1
  74. package/dist/cjs/resources/registries.js +27 -0
  75. package/dist/cjs/resources/registries.js.map +1 -1
  76. package/dist/cjs/version.d.ts +1 -1
  77. package/dist/cjs/version.js +1 -1
  78. package/dist/esm/client.d.ts +30 -34
  79. package/dist/esm/client.d.ts.map +1 -1
  80. package/dist/esm/client.js +71 -0
  81. package/dist/esm/client.js.map +1 -1
  82. package/dist/esm/core/gated.d.ts +12 -10
  83. package/dist/esm/core/gated.d.ts.map +1 -1
  84. package/dist/esm/core/gated.js +12 -10
  85. package/dist/esm/core/gated.js.map +1 -1
  86. package/dist/esm/core/http.d.ts +18 -0
  87. package/dist/esm/core/http.d.ts.map +1 -1
  88. package/dist/esm/core/http.js +11 -1
  89. package/dist/esm/core/http.js.map +1 -1
  90. package/dist/esm/core/pagination.d.ts +11 -9
  91. package/dist/esm/core/pagination.d.ts.map +1 -1
  92. package/dist/esm/core/pagination.js +11 -9
  93. package/dist/esm/core/pagination.js.map +1 -1
  94. package/dist/esm/generated/operations.d.ts +250 -2
  95. package/dist/esm/generated/operations.d.ts.map +1 -1
  96. package/dist/esm/generated/operations.js +252 -4
  97. package/dist/esm/generated/operations.js.map +1 -1
  98. package/dist/esm/generated/types.d.ts +1137 -113
  99. package/dist/esm/generated/types.d.ts.map +1 -1
  100. package/dist/esm/index.d.ts +7 -6
  101. package/dist/esm/index.d.ts.map +1 -1
  102. package/dist/esm/index.js +1 -0
  103. package/dist/esm/index.js.map +1 -1
  104. package/dist/esm/resources/addresses.d.ts +91 -4
  105. package/dist/esm/resources/addresses.d.ts.map +1 -1
  106. package/dist/esm/resources/addresses.js +55 -3
  107. package/dist/esm/resources/addresses.js.map +1 -1
  108. package/dist/esm/resources/admin.d.ts +32 -1
  109. package/dist/esm/resources/admin.d.ts.map +1 -1
  110. package/dist/esm/resources/admin.js +45 -0
  111. package/dist/esm/resources/admin.js.map +1 -1
  112. package/dist/esm/resources/aml.d.ts +56 -0
  113. package/dist/esm/resources/aml.d.ts.map +1 -0
  114. package/dist/esm/resources/aml.js +67 -0
  115. package/dist/esm/resources/aml.js.map +1 -0
  116. package/dist/esm/resources/approvals.d.ts +30 -2
  117. package/dist/esm/resources/approvals.d.ts.map +1 -1
  118. package/dist/esm/resources/approvals.js.map +1 -1
  119. package/dist/esm/resources/balances.d.ts +14 -7
  120. package/dist/esm/resources/balances.d.ts.map +1 -1
  121. package/dist/esm/resources/balances.js +10 -4
  122. package/dist/esm/resources/balances.js.map +1 -1
  123. package/dist/esm/resources/categories.d.ts +20 -6
  124. package/dist/esm/resources/categories.d.ts.map +1 -1
  125. package/dist/esm/resources/categories.js +19 -7
  126. package/dist/esm/resources/categories.js.map +1 -1
  127. package/dist/esm/resources/counterparties.d.ts +52 -6
  128. package/dist/esm/resources/counterparties.d.ts.map +1 -1
  129. package/dist/esm/resources/counterparties.js +24 -0
  130. package/dist/esm/resources/counterparties.js.map +1 -1
  131. package/dist/esm/resources/history.d.ts +227 -26
  132. package/dist/esm/resources/history.d.ts.map +1 -1
  133. package/dist/esm/resources/history.js +46 -0
  134. package/dist/esm/resources/history.js.map +1 -1
  135. package/dist/esm/resources/me.d.ts +17 -1
  136. package/dist/esm/resources/me.d.ts.map +1 -1
  137. package/dist/esm/resources/me.js +19 -0
  138. package/dist/esm/resources/me.js.map +1 -1
  139. package/dist/esm/resources/members.d.ts +21 -1
  140. package/dist/esm/resources/members.d.ts.map +1 -1
  141. package/dist/esm/resources/members.js +15 -0
  142. package/dist/esm/resources/members.js.map +1 -1
  143. package/dist/esm/resources/operations.d.ts +179 -4
  144. package/dist/esm/resources/operations.d.ts.map +1 -1
  145. package/dist/esm/resources/operations.js +192 -2
  146. package/dist/esm/resources/operations.js.map +1 -1
  147. package/dist/esm/resources/registries.d.ts +28 -2
  148. package/dist/esm/resources/registries.d.ts.map +1 -1
  149. package/dist/esm/resources/registries.js +27 -0
  150. package/dist/esm/resources/registries.js.map +1 -1
  151. package/dist/esm/version.d.ts +1 -1
  152. package/dist/esm/version.js +1 -1
  153. package/docs/concepts.md +13 -11
  154. package/docs/errors.md +76 -5
  155. package/package.json +1 -1
  156. package/src/client.ts +44 -0
  157. package/src/core/gated.ts +12 -10
  158. package/src/core/http.ts +30 -1
  159. package/src/core/pagination.ts +11 -9
  160. package/src/generated/operations.ts +252 -4
  161. package/src/generated/types.ts +1173 -95
  162. package/src/index.ts +16 -1
  163. package/src/resources/addresses.ts +102 -4
  164. package/src/resources/admin.ts +59 -0
  165. package/src/resources/aml.ts +76 -0
  166. package/src/resources/approvals.ts +30 -2
  167. package/src/resources/balances.ts +14 -7
  168. package/src/resources/categories.ts +19 -5
  169. package/src/resources/counterparties.ts +59 -5
  170. package/src/resources/history.ts +238 -27
  171. package/src/resources/me.ts +22 -0
  172. package/src/resources/members.ts +30 -0
  173. package/src/resources/operations.ts +264 -5
  174. package/src/resources/registries.ts +39 -3
  175. package/src/version.ts +1 -1
package/CHANGELOG.md CHANGED
@@ -3,6 +3,191 @@
3
3
  All notable changes to this package are documented in this file. The format is based on
4
4
  [Keep a Changelog](https://keepachangelog.com), and this project adheres to [Semantic Versioning](https://semver.org).
5
5
 
6
+ ## 0.6.0 — 2026-11-24
7
+
8
+ AML v2, first step: AML checks in a typed model, with a record of what was known at the moment of
9
+ each operation. Spec snapshot refreshed from the live API (commit `66f2e93`,
10
+ [v3-finance/policy-engine#39](https://github.com/v3-finance/policy-engine/pull/39)). Five
11
+ operations were added (208 in all, three of them administrator-only), none removed. Everything is
12
+ additive: no existing shape lost or changed a field.
13
+
14
+ ### Added
15
+
16
+ - `vault(code).aml` — the vault's AML checks (`AmlResource`):
17
+ - `check(address, { provider })` — `GET /vaults/{code}/aml/checks`: a check younger than 24 h is
18
+ returned as stored (`cached: true`), otherwise the provider is called and a new record written.
19
+ What comes back depends on the caller and `view` says which: `summary` for a member (level,
20
+ score in the provider's own scale, `riskIndex` 0..100, categories counted by UNIQUE addresses),
21
+ `links` for a vault or platform admin (plus the top 50 links per side);
22
+ - `recheck({ address, provider })` — `POST …/checks`, always a provider call, admins only;
23
+ - `getCheck(id)` — one record whole (`view: full`, with `native`, the provider's response typed).
24
+ Pass an operation's `amlCheckId` to open what was known when it happened;
25
+ - `rawCheck(id)` — the provider's response byte for byte, as a `Response`.
26
+ - `registries.amlProviders()` — `GET /aml/providers`: the providers and their `capabilities`.
27
+ Scorechain has no shares of funds, no entity of the address itself and no separate sanction
28
+ authorities — `share` and `amountUsd` are always `null` for it ("no data", not "0 %").
29
+ - `amlCheckId` on `TransactionDetail`, `IncomingTransactionDetail`, `HistoryInItem` and
30
+ `HistoryOutItem`: the check record the operation's snapshot was taken from. `null` for operations
31
+ before AML v2.
32
+ - Generated types: `AmlCheck`, `AmlLink`, `AmlLinks`, `AmlLinkCategory`, `AmlLevel`,
33
+ `AmlScoreScale`, `AmlNative`, `ScorechainNative`, `ScorechainLinkNative`, `AmlProvider`,
34
+ `AmlProviders`, `AmlRecheckBody`.
35
+ - Error codes `AML_CHECK_NOT_FOUND`, `AML_RAW_NOT_FOUND`, `AML_ARCHIVE_DISABLED` in `docs/errors.md`.
36
+
37
+ ## 0.5.0 — 2026-11-23
38
+
39
+ Catches up with eight releases of the API: summaries and facets, a much richer operation feed,
40
+ attachments, the counterparty of an operation chosen by hand, idempotent address creation, fiat
41
+ rates, logos fetched through the API. Spec snapshot refreshed from the live API (commit `f25db15`,
42
+ [v3-finance/policy-engine#30](https://github.com/v3-finance/policy-engine/pull/30) through
43
+ [#37](https://github.com/v3-finance/policy-engine/pull/37)). 26 operations were added (203 in all,
44
+ three more of them administrator-only), none removed. Most of what changed is additive, but a
45
+ number of generated shapes gained REQUIRED fields and one method now returns `Gated` — see
46
+ **Breaking** under Changed before upgrading.
47
+
48
+ ### Added
49
+
50
+ - `history.summary(params)` — `GET /history/summary`: for the same scope and filters as
51
+ `history.list()`, how many operations, amounts per asset and direction (raw and decimal), the USD
52
+ total with `pricedCount`/`unpricedCount`, and counters per value of the requested `facets`. Over
53
+ 25 000 operations after filtering is 422 `HISTORY_SUMMARY_TOO_BROAD`.
54
+ - `history.list()` takes the API's new filters: several values per filter (an array goes out as one
55
+ comma-separated value) and `<name>Not` exclusions for status, asset, token, network, address,
56
+ folder, counterparty, counterparty group, category, decision policy, initiator, AML level and tag;
57
+ `initiatorId`, `amlLevel` (with `unchecked` — not "clean"), `hasTxHash`, `hasFee`,
58
+ `hasCounterparty`, `hasCategory`, `hasRelations`, `hasUsd`, `relationType`, `dateBasis`, the
59
+ category filters `categoryKey`, `categoryField`, `categoryFieldRange`, `categoryFieldEmpty`, the
60
+ amount bounds `minimumAmount`/`maximumAmount` (in the operation's own token) and
61
+ `minimumUsd`/`maximumUsd`, and the order: `sort` (`createdAt`, `confirmedAt`, `amount`, `usd`) and
62
+ `order`. Types `HistoryFilters`, `HistorySummaryParams`, `HistoryFacet`, `HistoryAmlLevelFilter`,
63
+ `OperationRelationType`.
64
+ - `addresses.summary(params)` and `counterparties.summary(params)` — totals and facets of the two
65
+ listings (tags with counts, networks, folders, owners; tags, kinds, groups). Types
66
+ `AddressFilters`, `AddressesSummaryParams`, `AddressFacet`, `CounterpartyFilters`,
67
+ `CounterpartiesSummaryParams`, `CounterpartyFacet`.
68
+ - `addresses.list()` filters `network`, `tag`, `ownerId` (several values each) and `sort`
69
+ (`createdAt` or `lastActivity`); `counterparties.list()` filters `network` and `tag`.
70
+ - `operations.setCounterparty(kind, id, counterpartyId | null)` and
71
+ `operations.resetCounterparty(kind, id)` — `PUT`/`DELETE …/counterparty`: choose an operation's
72
+ counterparty by hand (`null` is "none"), or hand it back to the automatic match, which runs again
73
+ at once. Neither the automatic match nor the retro-match overwrites a manual choice. A transfer
74
+ awaiting signatures is 409 `OPERATION_AWAITING_APPROVAL`.
75
+ - `operations.attachments()`, `uploadAttachment()`, `downloadAttachment()`, `deleteAttachment()` —
76
+ files attached to an operation (PDF, PNG, JPEG, WebP by their bytes; at most 20 per operation).
77
+ An upload takes a `Blob`/`File`, `ArrayBuffer` or `Uint8Array` (sent as the raw body, up to 10 MB)
78
+ or a `FormData` (multipart, up to 5 MB — React Native's way); a download returns the untouched
79
+ `Response`. Types `AttachmentFile`, `UploadAttachmentOptions`.
80
+ - `operations.deleteRelation(relationId)` — `DELETE /operation-relations/{id}`, by its creator or an
81
+ administrator.
82
+ - `members.policyDirectory(params)` — `GET /policy-directory`: every policy of the vault by name,
83
+ effect and group, without rules — open to any member. Type `PolicyDirectoryParams`.
84
+ - `me.sessions(params)` — `GET /me/sessions`: where I am signed in, without tokens or IP addresses,
85
+ open to any session (web and Mac included).
86
+ - `core.logo(logoPath)` — a network's, a token's or an address's logo fetched through the API, from
87
+ the `logoPath` the record carries (`logoPath` is new on networks, tokens and addresses). Refuses,
88
+ without a request, anything that is not one of the three logo paths.
89
+ - `registries.rates({ base })` — rates in a fiat currency (`FiatCurrency`), converted through the
90
+ dollar at the Bank of Russia's official rate (`fx`). Without `base` the answer is as before.
91
+ - `approvals.list()` filters `vote` (with `approverId`), `order` (`newest`/`oldest`), `includeTotal`
92
+ (adds `total`) and several statuses at once.
93
+ - `categories.removeAssignment(type, id, assignmentId, { baseVersion })` — the same optimistic lock
94
+ as `updateAssignment()`'s `baseVersion` (in `EditAssignmentBody`).
95
+ - `admin.addresses.shared()`, `admin.legacyMetadata.reconcile(body)`,
96
+ `admin.vault(code).rebuildSearchIndex()` — platform administrators only: on-chain addresses that
97
+ exist in several vaults, carrying the older metadata table into the `general` category, and
98
+ computing missing amount sort keys of the feed by hand.
99
+ - The transport sends a file: `RequestOptions.rawBody` (type `RawBody`) with `contentType`, beside
100
+ the JSON `body`.
101
+ - `idempotencyKey` on `CreateAddressBody`, `note` (the initiator's comment) on `CreateTransferBody`
102
+ and `CreateTransferDraftBody` (generated).
103
+ - Generated: `HistorySummary`, `AddressesSummary`, `CounterpartiesSummary`, `Facet`, `FacetValue`,
104
+ `HistoryCategory`, `OperationAttachment`, `OperationAttachmentsList`, `OperationCounterparty`,
105
+ `PolicyDirectoryItem`, `PolicyDirectoryPage`, `MySession`, `MySessionList`, `RegistryNetwork`,
106
+ `FiatCurrency`, `FxQuote`, `FolderAccess`, `FolderRole`, `InternalDepositLink`,
107
+ `SourceTransferLink`, `TrxAmount`, `TransferCostItem`, `ReportingOperation`, the admin results,
108
+ and the better-auth shapes the API now documents (`AuthSession`, `DeviceCodeResponse`, …).
109
+ - `docs/errors.md`: 41 codes — attachments, logos, idempotent address creation,
110
+ `NETWORK_NOT_MONITORED`, `ADDRESS_DERIVATION_COLLISION`, the relation and counterparty-choice
111
+ codes, the feed's `TOO_MANY_VALUES`, `INVALID_FILTER_VALUE`, `SORT_REQUIRES_SINGLE_ASSET`,
112
+ `INVALID_CURSOR`, `CROSS_SITE_REQUEST_REFUSED`, `CATEGORY_KEY_RESERVED`,
113
+ `GENERAL_CATEGORY_CONFLICT` and more; new sections on logos, attachments and list filters.
114
+
115
+ ### Changed
116
+
117
+ - `addresses.create()` — with an `idempotencyKey`, a retry with the same key and body answers 200
118
+ with the address of that attempt, now labelled `outcome: 'replayed'` (it used to be impossible),
119
+ or 202 with the same pending request. New 409s `IDEMPOTENCY_KEY_REUSED`,
120
+ `IDEMPOTENCY_KEY_IN_PROGRESS`, `IDEMPOTENCY_KEY_CLOSED`; an address on a network without deposit
121
+ monitoring (anything but TRON) is 400 `NETWORK_NOT_MONITORED`.
122
+ - `operations.createRelation()` — idempotent: an identical repeat answers 200 with the existing
123
+ relation, the same (type, source, target) with other values is 409 `OPERATION_RELATION_EXISTS`.
124
+ Still returns the relation directly: both outcomes mean it exists exactly as asked.
125
+ - Every 202 "went for approval" carries the full request card (`ApprovalRequestDetail`: initiator,
126
+ signers as cards, steps, events), where it carried `ApprovalRequestWithApprovers` — a strict
127
+ subset, now marked deprecated by the API.
128
+ - The feed and the ledger: an administrator of THIS vault (`VaultMembership.role = admin`) now sees
129
+ the whole vault there, as a platform administrator does. `AddressAccess.isAdmin` means a platform
130
+ administrator only; a vault administrator's oversight shows as `supervisor`, and so do folders
131
+ seen that way.
132
+ - `balances.entries({ addressId })` — an address you cannot reach is 404 `ADDRESS_NOT_FOUND`
133
+ instead of an empty page; members see the entries of addresses shared with them too.
134
+ - `fee` on transfers is deprecated by the API (a raw value of the signing service, not money): use
135
+ `networkFee` (burnt on chain; `null` on new transfers, the server no longer reads the chain) and
136
+ `resourceCost` (administrators only).
137
+ - A changing request from a page of an untrusted site is refused with 403
138
+ `CROSS_SITE_REQUEST_REFUSED`.
139
+
140
+ #### Breaking
141
+
142
+ - `operations.setMetadata()` returns `Gated<OperationMetadata, ApprovalRequestCreated>` instead of
143
+ `OperationMetadata`. The metadata is now a facade over the system category `general`, and when an
144
+ administrator sets that category's approval the API answers 202 with a request and writes nothing
145
+ — returned directly, that body would have been typed as the metadata. Read `result.data` after
146
+ checking `result.outcome`.
147
+ - A field is now REQUIRED in a generated shape — it always arrives, so reading code is unaffected,
148
+ but an object literal or a test fixture typed as the shape stops compiling until it has it:
149
+ - `AddressAccess.supervisor`; `AddressListItem` and `AddressDetail`: `logoPath`,
150
+ `lastActivityAt`, `folderIds`;
151
+ - `AddressGroupDetail`: `access` and `sharing` (were optional), `myRole`, `supervisor`;
152
+ - `HistoryOutItem`: `categories`, `relations`, `tokenDecimals`, `counterpartySource`, `note`,
153
+ `internalDeposit`, `networkFee`, `resourceCost`, `metadata.references`;
154
+ `HistoryInItem`: `categories`, `relations`, `tokenDecimals`, `counterpartySource`,
155
+ `sourceTransfer`, `metadata.references`;
156
+ - `TransactionDetail`: `note`, `tokenDecimals`, `counterpartySource`, `counterpartySetById`,
157
+ `counterpartySetAt`, `internalDeposit`, `networkFee`, `resourceCost`, `costs`;
158
+ `IncomingTransactionDetail`: `tokenDecimals`, `counterpartySource`, `counterpartySetById`,
159
+ `counterpartySetAt`, `sourceTransfer`; `CreateTransactionResult.transaction.note`;
160
+ `OutgoingTxSummary` and `IncomingTxSummary`: `tokenDecimals`;
161
+ - `ApprovalRequestApprover.requestId`; `ApprovalTransferBrief.note`; `decisionPolicyVersionId` on
162
+ `ApprovalRequest`, `ApprovalRequestDetail`, `ApprovalRequestWithApprovers` and the items of
163
+ `ApprovalRequestsPage`;
164
+ - `CounterpartyDetail` and the items of `CounterpartiesPage`: `groupIds`, `operationsCount`;
165
+ - `TokenWithNetwork.logoPath`; `OperationCategoryField.maxLength`; `TransferDraft.note`.
166
+ - A field changed type:
167
+ - `HistoryOutItem.status` — `string` → `'awaiting_approval' | 'pending' | 'submitted' |
168
+ 'confirmed' | 'failed' | 'rejected' | 'cancelled'`. A fixture that sets it from a `string`
169
+ stops compiling;
170
+ - `ApprovalRequestStep.action` and `StepProgress.action` — `string` → `string | null`: `null` is
171
+ a gate step, a second signature requirement with no operation of its own. Code that reads
172
+ `action` as a string has to handle it;
173
+ - `RatesResponse.base` — `'USD'` → `FiatCurrency`. It is still `'USD'` without `?base=`;
174
+ - `DrilldownResponse.items` (what `reports.queryOperations()` returns) — a bag of
175
+ `Record<string, unknown>` → `ReportingOperation[]`. A key the schema does not declare no longer
176
+ compiles; `idempotencyKey` is not in the answer.
177
+ - Return types made wider, compatible with existing callers: `history.list()` answers
178
+ `HistoryResponse` (a page plus the optional `scanTruncated` and `sortIncomplete` flags) and
179
+ `registries.networks()` answers `RegistryNetwork[]` (`Network` plus `logoPath`).
180
+
181
+ ### Fixed
182
+
183
+ - `ListCounterpartiesParams.archived` — the note said that leaving it out returns active and
184
+ archived entries alike. The API returns only active ones unless `archived: true`.
185
+ - `categories.updateAssignment()` — the note said there was no optimistic lock on the direct path;
186
+ there is one now, with `baseVersion`, and the note says how to use it.
187
+ - `docs/errors.md` — `ASSIGNMENT_STALE` named an `expectVersion` field that does not exist (it is
188
+ `baseVersion`); `OPERATION_RELATION_INVALID` and `MONITORING_FAILED` describe their current
189
+ causes.
190
+
6
191
  ## 0.4.0 — 2026-11-19
7
192
 
8
193
  A phone can ask the server which client a login code belongs to before approving it. Spec snapshot
package/README.md CHANGED
@@ -163,36 +163,40 @@ Scoped to a vault — `core.vault(code).…`:
163
163
 
164
164
  | Resource | What it covers |
165
165
  | --- | --- |
166
- | `addresses` | list, detail, create (gated), edit metadata |
166
+ | `addresses` | list, totals and facets, detail, create (gated, idempotent), edit metadata |
167
167
  | `transfers` | send (gated), detail, vote, cancel, reconcile (admin) |
168
168
  | `transferDrafts` | create, list, detail, discard; send (gated) — from the mobile app only |
169
- | `history` | the unified feed of operations; direction is a filter, not an endpoint |
169
+ | `history` | the unified feed of operations, its totals and facets; direction is a filter, not an endpoint |
170
170
  | `balances` | balances, a point in time, the raw ledger |
171
171
  | `approvals` | requests, detail, vote, cancel, composite chains |
172
- | `counterparties`, `counterpartyGroups` | the directory and its groups — every mutation is gated |
172
+ | `counterparties`, `counterpartyGroups` | the directory, its totals and facets, and its groups — every mutation is gated |
173
173
  | `sharing` | sharing an address, participants, shared by me and with me |
174
174
  | `folders` | address folders, their grants and participants |
175
- | `members` | the directory, resolve by username, user groups |
175
+ | `members` | the directory, resolve by username, user groups, the policy directory |
176
176
  | `categories` | the labelling schema and the values on operations |
177
- | `operations` | metadata, links, status history, deposits, approval relations |
177
+ | `operations` | metadata (gated), links, the counterparty chosen by hand, attachments, status history, deposits, approval relations |
178
178
  | `reports` | reports, templates, snapshots, exports |
179
179
 
180
180
  At the root — `core.…`:
181
181
 
182
182
  | Resource | What it covers |
183
183
  | --- | --- |
184
- | `me` | profile, email binding, push tokens, allowed segments |
184
+ | `me` | profile, email binding, push tokens, allowed segments, where I am signed in |
185
185
  | `vaults` | list, detail, create, derivation-path build and parse |
186
- | `registries` | networks, tokens, rates, policy preflight, AML |
187
- | `auth` | request a magic link |
188
- | `admin` | policies, policy groups, users, invitations, visibility grants, seats |
186
+ | `registries` | networks, tokens, rates (in USD or a fiat currency), policy preflight, AML |
187
+ | `auth` | request a magic link, look up a login code before approving it |
188
+ | `admin` | policies, policy groups, users, invitations, visibility grants, seats, maintenance |
189
+ | `logo(logoPath)` | a network's, token's or address's logo, fetched through the API |
189
190
  | `health()` | liveness, no authentication |
190
191
 
191
- Fourteen of the API's 176 operations are deliberately absent. Two are not a client's business:
192
+ Twenty-two of the API's 203 operations are deliberately absent. Two are not a client's business:
192
193
  `/welcome` is a browser landing page the API redirects to, and `/webhooks/wallet` is the inbound
193
- channel for the wallet service. The other twelve are the `/address-groups/*` paths — the older
194
- prefix of the endpoints `folders` already serves under `/address-folders`. One entity, two
195
- prefixes; see [docs/concepts.md](./docs/concepts.md#5-shared-access-roles-out-flags-in).
194
+ channel for the wallet service. Twelve are the `/address-groups/*` paths — the older prefix of the
195
+ endpoints `folders` already serves under `/address-folders`. One entity, two prefixes; see
196
+ [docs/concepts.md](./docs/concepts.md#5-shared-access-roles-out-flags-in). The last eight are
197
+ better-auth's own `/api/auth/*` endpoints the API documents — verifying a link, the device-code
198
+ login, reading and ending a session: the package stops at requesting a magic link, and the rest
199
+ belongs to better-auth's client on each platform.
196
200
 
197
201
  ## Amounts
198
202
 
@@ -279,7 +283,7 @@ useQuery({
279
283
 
280
284
  ## TypeScript
281
285
 
282
- Every **named** model of the API is exported — all 262 schemas of its OpenAPI document, generated
286
+ Every **named** model of the API is exported — all 310 schemas of its OpenAPI document, generated
283
287
  rather than retyped, so a shape the resources do not surface yet is still reachable by name. Where
284
288
  the package presents a name of its own (`Address`, `Transaction`, `PersonCard`) it is an alias of
285
289
  the generated schema, not a parallel definition. The deliberate exceptions narrow a generated
@@ -10,6 +10,7 @@ import { CategoriesResource } from './resources/categories.js';
10
10
  import { FoldersResource } from './resources/folders.js';
11
11
  import { HistoryResource } from './resources/history.js';
12
12
  import { MembersResource } from './resources/members.js';
13
+ import { AmlResource } from './resources/aml.js';
13
14
  import { OperationsResource } from './resources/operations.js';
14
15
  import { RegistriesResource } from './resources/registries.js';
15
16
  import { ReportsResource } from './resources/reports.js';
@@ -17,40 +18,6 @@ import { SharingResource } from './resources/sharing.js';
17
18
  import { MeResource } from './resources/me.js';
18
19
  import { TransferDraftsResource } from './resources/transferDrafts.js';
19
20
  import { TransfersResource } from './resources/transfers.js';
20
- /**
21
- * Client for the V3 Finance Core API.
22
- *
23
- * CALL SHAPE: `core.vault(code).addresses.list()`.
24
- *
25
- * `vault(code)` is an EXPRESSION, not state. There is deliberately no
26
- * "current vault" that you set once and forget:
27
- *
28
- * • the vault code is visible on every call site, so reading the code does
29
- * not require scrolling up to find which vault is in effect;
30
- * • an administrator works with several vaults at once, and two scopes side
31
- * by side cannot interfere — there is no shared mutable field;
32
- * • in the mobile app and on the web the active vault changes at runtime,
33
- * and a remembered scope would mean requests to the wrong vault after a
34
- * switch.
35
- *
36
- * A scope is cheap: it is a pair of small objects over the shared HTTP
37
- * client, so creating one per call is fine.
38
- *
39
- * Cross-vault and registry endpoints live at the root: `core.vaults`, `core.me`.
40
- *
41
- * @example
42
- * ```ts
43
- * import { CoreClient } from '@v3finance/core-sdk'
44
- *
45
- * const core = new CoreClient({
46
- * getAuthHeaders: () => ({ Authorization: `Bearer ${sessionToken}` }),
47
- * onTokenRotated: (token) => save(token),
48
- * onUnauthorized: () => signOut(),
49
- * })
50
- *
51
- * const page = await core.vault('my-vault').addresses.list({ limit: 20 })
52
- * ```
53
- */
54
21
  export interface VaultScope {
55
22
  readonly code: string;
56
23
  readonly addresses: AddressesResource;
@@ -67,6 +34,8 @@ export interface VaultScope {
67
34
  readonly categories: CategoriesResource;
68
35
  readonly reports: ReportsResource;
69
36
  readonly operations: OperationsResource;
37
+ /** AML checks in the typed model; what you see depends on your role. */
38
+ readonly aml: AmlResource;
70
39
  }
71
40
  /**
72
41
  * A vault as `vaults.list()` returns it.
@@ -152,6 +121,33 @@ export declare class CoreClient {
152
121
  * reachable. Use a real read for that.
153
122
  */
154
123
  health(): Promise<Health>;
124
+ /**
125
+ * A logo, fetched through the API: the image of a network, a token or an
126
+ * address, read from the `logoPath` its record carries. Returns the
127
+ * untouched `Response` — read it with `.blob()`.
128
+ *
129
+ * Why not `logoUri`: the server fetches the picture, so the image's host
130
+ * sees neither the person's IP nor what they opened. Pass `logoPath` WHOLE,
131
+ * as the API returned it — its `?v=` is the version of the link, and a new
132
+ * `logoUri` gives a new path, so a client's day-long cache of the old one
133
+ * does not get in the way. `null` there means there is nothing to fetch;
134
+ * a path is not a promise of an image either (502 `LOGO_UNAVAILABLE` when
135
+ * the source does not deliver one, 404 `LOGO_NOT_FOUND` when there is none
136
+ * to fetch).
137
+ *
138
+ * An address's logo is seen by whoever sees the address card. Its
139
+ * `logoUri` is chosen by the address's owner and fetched at the moment of
140
+ * VIEWING, so a unique link to their own host tells them that — and
141
+ * roughly from where — someone opened the address (never the viewer's IP).
142
+ * A cautious client loads the logos of other people's addresses only on an
143
+ * explicit action.
144
+ *
145
+ * Throws, without a request, for a path that is not one of the three logo
146
+ * paths: this is not a general-purpose GET.
147
+ */
148
+ logo(logoPath: string, options?: {
149
+ signal?: AbortSignal | undefined;
150
+ }): Promise<Response>;
155
151
  /** The caller's own profile, devices and permissions. */
156
152
  readonly me: MeResource;
157
153
  /** Networks, tokens, rates, policy preflight and AML. Not vault-scoped. */
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAO,KAAK,aAAa,EAAE,MAAM,gBAAgB,CAAA;AACpE,OAAO,KAAK,EACV,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,MAAM,EACN,aAAa,EACb,kBAAkB,EAClB,WAAW,EACX,WAAW,EACX,aAAa,EACd,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,EACL,sBAAsB,EACtB,0BAA0B,EAC3B,MAAM,+BAA+B,CAAA;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAE,kBAAk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;;;;;;;;;;;;WAgBG;QACH,mBAAmB,SAAS,MAAM,QAAQ,aAAa,KAAG,OAAO,CAAC,iBAAiB,CAAC;QAOpF;;;;;;WAMG;QACH,mBAAmB,SAAS,MAAM,QAAQ,aAAa,KAAG,OAAO,CAAC,kBAAkB,CAAC;MAMtF;IAED;;;;;;OAMG;IACH,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,CAExB;IAED;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE;QAAE,MAAM,CAAC,EAAE,WAAW,GAAG,SAAS,CAAA;KAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAO5F;IAED,yDAAyD;IACzD,QAAQ,CAAC,EAAE,EAAE,UAAU,CAAA;IAEvB,2EAA2E;IAC3E,QAAQ,CAAC,UAAU,EAAE,kBAAkB,CAAA;IAEvC,qFAAqF;IACrF,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAA;IAE7B,sEAAsE;IACtE,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAA;CAC5B"}
@@ -12,6 +12,7 @@ const categories_js_1 = require("./resources/categories.js");
12
12
  const folders_js_1 = require("./resources/folders.js");
13
13
  const history_js_1 = require("./resources/history.js");
14
14
  const members_js_1 = require("./resources/members.js");
15
+ const aml_js_1 = require("./resources/aml.js");
15
16
  const operations_js_1 = require("./resources/operations.js");
16
17
  const registries_js_1 = require("./resources/registries.js");
17
18
  const reports_js_1 = require("./resources/reports.js");
@@ -20,6 +21,45 @@ const me_js_1 = require("./resources/me.js");
20
21
  const transferDrafts_js_1 = require("./resources/transferDrafts.js");
21
22
  const transfers_js_1 = require("./resources/transfers.js");
22
23
  const version_js_1 = require("./version.js");
24
+ /**
25
+ * Client for the V3 Finance Core API.
26
+ *
27
+ * CALL SHAPE: `core.vault(code).addresses.list()`.
28
+ *
29
+ * `vault(code)` is an EXPRESSION, not state. There is deliberately no
30
+ * "current vault" that you set once and forget:
31
+ *
32
+ * • the vault code is visible on every call site, so reading the code does
33
+ * not require scrolling up to find which vault is in effect;
34
+ * • an administrator works with several vaults at once, and two scopes side
35
+ * by side cannot interfere — there is no shared mutable field;
36
+ * • in the mobile app and on the web the active vault changes at runtime,
37
+ * and a remembered scope would mean requests to the wrong vault after a
38
+ * switch.
39
+ *
40
+ * A scope is cheap: it is a pair of small objects over the shared HTTP
41
+ * client, so creating one per call is fine.
42
+ *
43
+ * Cross-vault and registry endpoints live at the root: `core.vaults`, `core.me`.
44
+ *
45
+ * @example
46
+ * ```ts
47
+ * import { CoreClient } from '@v3finance/core-sdk'
48
+ *
49
+ * const core = new CoreClient({
50
+ * getAuthHeaders: () => ({ Authorization: `Bearer ${sessionToken}` }),
51
+ * onTokenRotated: (token) => save(token),
52
+ * onUnauthorized: () => signOut(),
53
+ * })
54
+ *
55
+ * const page = await core.vault('my-vault').addresses.list({ limit: 20 })
56
+ * ```
57
+ */
58
+ /**
59
+ * The three shapes of `logoPath`: a network's or a token's under `/logos`, an
60
+ * address's under its vault. The query (`?v=…`) is kept as it came.
61
+ */
62
+ const LOGO_PATH = /^\/api\/v1\/(?:logos\/(?:networks|tokens)\/[^/?#]+|vaults\/[^/?#]+\/addresses\/[^/?#]+\/logo)(?:\?[^#]*)?$/;
23
63
  class CoreClient {
24
64
  /** Low-level access for endpoints the resources do not cover yet. */
25
65
  http;
@@ -50,6 +90,7 @@ class CoreClient {
50
90
  categories: new categories_js_1.CategoriesResource(this.http, code),
51
91
  reports: new reports_js_1.ReportsResource(this.http, code),
52
92
  operations: new operations_js_1.OperationsResource(this.http, code),
93
+ aml: new aml_js_1.AmlResource(this.http, code),
53
94
  };
54
95
  }
55
96
  vaults = {
@@ -108,6 +149,36 @@ class CoreClient {
108
149
  health() {
109
150
  return this.http.request('GET', '/');
110
151
  }
152
+ /**
153
+ * A logo, fetched through the API: the image of a network, a token or an
154
+ * address, read from the `logoPath` its record carries. Returns the
155
+ * untouched `Response` — read it with `.blob()`.
156
+ *
157
+ * Why not `logoUri`: the server fetches the picture, so the image's host
158
+ * sees neither the person's IP nor what they opened. Pass `logoPath` WHOLE,
159
+ * as the API returned it — its `?v=` is the version of the link, and a new
160
+ * `logoUri` gives a new path, so a client's day-long cache of the old one
161
+ * does not get in the way. `null` there means there is nothing to fetch;
162
+ * a path is not a promise of an image either (502 `LOGO_UNAVAILABLE` when
163
+ * the source does not deliver one, 404 `LOGO_NOT_FOUND` when there is none
164
+ * to fetch).
165
+ *
166
+ * An address's logo is seen by whoever sees the address card. Its
167
+ * `logoUri` is chosen by the address's owner and fetched at the moment of
168
+ * VIEWING, so a unique link to their own host tells them that — and
169
+ * roughly from where — someone opened the address (never the viewer's IP).
170
+ * A cautious client loads the logos of other people's addresses only on an
171
+ * explicit action.
172
+ *
173
+ * Throws, without a request, for a path that is not one of the three logo
174
+ * paths: this is not a general-purpose GET.
175
+ */
176
+ logo(logoPath, options = {}) {
177
+ if (!LOGO_PATH.test(logoPath)) {
178
+ return Promise.reject(new Error(`@v3finance/core-sdk: not a logoPath the API returns: ${logoPath}`));
179
+ }
180
+ return this.http.fetchRaw('GET', logoPath, { signal: options.signal });
181
+ }
111
182
  /** The caller's own profile, devices and permissions. */
112
183
  me;
113
184
  /** Networks, tokens, rates, policy preflight and AML. Not vault-scoped. */
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":";;;AAAA,4CAAoE;AAYpE,2DAA4D;AAC5D,2DAA4D;AAC5D,yDAA0D;AAC1D,qEAGsC;AACtC,mDAAoD;AACpD,iDAAkD;AAClD,6DAA8D;AAC9D,uDAAwD;AACxD,uDAAwD;AACxD,uDAAwD;AACxD,6DAA8D;AAC9D,6DAA8D;AAC9D,uDAAwD;AACxD,uDAAwD;AACxD,6CAA8C;AAC9C,qEAAsE;AACtE,2DAA4D;AAC5D,6CAA+C;AAiF/C;IACE,qEAAqE;IAC5D,IAAI,CAAY;IAEzB,YAAY,OAAO,G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AC9C,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,IAAI,CAAC,QAAgB,EAAE,OAAO,GAAyC,EAAE;QACvE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC9B,OAAO,OAAO,CAAC,MAAM,CACnB,IAAI,KAAK,CAAC,wDAAwD,QAAQ,EAAE,CAAC,CAC9E,CAAA;QACH,CAAC;QACD,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAA;IACxE,CAAC;IAED,yDAAyD;IAChD,EAAE,CAAY;IAEvB,2EAA2E;IAClE,UAAU,CAAoB;IAEvC,qFAAqF;IAC5E,KAAK,CAAe;IAE7B,sEAAsE;IAC7D,IAAI,CAAc;CAC5B"}
@@ -4,10 +4,11 @@
4
4
  *
5
5
  * 201 — applied immediately (policy allowed it without signatures);
6
6
  * 202 — queued for approval, funds are reserved, nothing has moved yet;
7
- * 200 — on a transfer: a replay of the same idempotency key, nothing
8
- * happened now and the existing operation came back (no second
9
- * broadcast). Everywhere else: an ordinary applied success, because
10
- * an edit is not a creation and answers 200 (see `replayOn200`).
7
+ * 200 — on a transfer or an address: a replay of the same idempotency
8
+ * key, nothing happened now and the existing operation came back (no
9
+ * second broadcast, no second address). Everywhere else: an ordinary
10
+ * applied success, because an edit is not a creation and answers 200
11
+ * (see `replayOn200`).
11
12
  *
12
13
  * The body can be identical: a transfer returns `{transaction}` in all three.
13
14
  * A client that reads only the body will say "sent" where the truth is
@@ -54,12 +55,13 @@ export type Gated<TApplied, TPending = TApplied> = {
54
55
  * of the two it is instead of the helper guessing.
55
56
  *
56
57
  * Which also means `outcome: 'replayed'` is UNREACHABLE for every gated
57
- * method other than `transfers.send` and `transferDrafts.send`: replay
58
- * protection needs an idempotency key, and the API has one only on a
59
- * transfer — taken from the transfer body, or derived from the draft when a
60
- * draft is sent. The three-way `switch` in `docs/concepts.md` is right for a
61
- * transfer; beside a counterparty edit its `case 'replayed'` is dead, and it
62
- * is not evidence that such an edit can come back as a replay.
58
+ * method other than `transfers.send`, `transferDrafts.send` and
59
+ * `addresses.create`: replay protection needs an idempotency key, and the API
60
+ * has one only on a transfer — taken from the transfer body, or derived from
61
+ * the draft when a draft is sent — and on the creation of an address, where
62
+ * it is optional. The three-way `switch` in `docs/concepts.md` is right for
63
+ * those; beside a counterparty edit its `case 'replayed'` is dead, and it is
64
+ * not evidence that such an edit can come back as a replay.
63
65
  */
64
66
  export declare function toGated<TApplied, TPending>(status: number, data: unknown, options?: {
65
67
  replayOn200?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"gated.d.ts","sourceRoot":"","sources":["../../../src/core/gated.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,SAAS,GAAG,UAAU,CAAA;AAE7D;;;;;;;;GAQG;AACH,MAAM,MAAM,KAAK,CAAC,QAAQ,EAAE,QAAQ,GAAG,QAAQ,IAC3C;IAAE,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,GAAG,GAAG,GAAG,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAA;CAAE,GACpF;IAAE,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAA;CAAE,GAC/E;IAAE,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAA;AAElF;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,OAAO,CAAC,QAAQ,EAAE,QAAQ,EACx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AE,SAAS,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAA;AAElF;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,OAAO,CAAC,QAAQ,EAAE,QAAQ,EACxC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,OAAO,EACb,OAAO,GAAE;IAAE,WAAW,CAAC,EAAE,OAAO,CAAA;CAAO,GACtC,KAAK,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAgB3B;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,CAAC,EAC5B,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,GACb,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE;IAAE,OAAO,EAAE,SAAS,GAAG,UAAU,CAAA;CAAE,CAAC,CAEhE;AAED,yEAAyE;AACzE,wBAAgB,SAAS,CAAC,CAAC,EAAE,CAAC,EAC5B,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,GACb,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE;IAAE,OAAO,EAAE,SAAS,CAAA;CAAE,CAAC,CAEnD"}
@@ -5,10 +5,11 @@
5
5
  *
6
6
  * 201 — applied immediately (policy allowed it without signatures);
7
7
  * 202 — queued for approval, funds are reserved, nothing has moved yet;
8
- * 200 — on a transfer: a replay of the same idempotency key, nothing
9
- * happened now and the existing operation came back (no second
10
- * broadcast). Everywhere else: an ordinary applied success, because
11
- * an edit is not a creation and answers 200 (see `replayOn200`).
8
+ * 200 — on a transfer or an address: a replay of the same idempotency
9
+ * key, nothing happened now and the existing operation came back (no
10
+ * second broadcast, no second address). Everywhere else: an ordinary
11
+ * applied success, because an edit is not a creation and answers 200
12
+ * (see `replayOn200`).
12
13
  *
13
14
  * The body can be identical: a transfer returns `{transaction}` in all three.
14
15
  * A client that reads only the body will say "sent" where the truth is
@@ -36,12 +37,13 @@ exports.isPending = isPending;
36
37
  * of the two it is instead of the helper guessing.
37
38
  *
38
39
  * Which also means `outcome: 'replayed'` is UNREACHABLE for every gated
39
- * method other than `transfers.send` and `transferDrafts.send`: replay
40
- * protection needs an idempotency key, and the API has one only on a
41
- * transfer — taken from the transfer body, or derived from the draft when a
42
- * draft is sent. The three-way `switch` in `docs/concepts.md` is right for a
43
- * transfer; beside a counterparty edit its `case 'replayed'` is dead, and it
44
- * is not evidence that such an edit can come back as a replay.
40
+ * method other than `transfers.send`, `transferDrafts.send` and
41
+ * `addresses.create`: replay protection needs an idempotency key, and the API
42
+ * has one only on a transfer — taken from the transfer body, or derived from
43
+ * the draft when a draft is sent — and on the creation of an address, where
44
+ * it is optional. The three-way `switch` in `docs/concepts.md` is right for
45
+ * those; beside a counterparty edit its `case 'replayed'` is dead, and it is
46
+ * not evidence that such an edit can come back as a replay.
45
47
  */
46
48
  function toGated(status, data, options = {}) {
47
49
  switch (status) {
@@ -1 +1 @@
1
- {"version":3,"file":"gated.js","sourceRoot":"","sources":["../../../src/core/gated.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;;;;;AAkBH;;;;;;;;;;;;;;;;;GAiBG;AACH,iBACE,MAAc,EACd,IAAa,EACb,OAAO,GAA8B,EAAE;IAEvC,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,GAAG;YACN,OAAO,OAAO,CAAC,WAAW;gBACxB,CAAC,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,IAAgB,EAAE;gBAC9D,CAAC,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,IAAgB,EAAE,CAAA;QACjE,KAAK,GAAG;YACN,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,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MAAM,IAAI;gBAC1D,yDAAyD,CAC5D,CAAA;IACL,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,mBACE,CAAc;IAEd,OAAO,CAAC,CAAC,OAAO,KAAK,SAAS,IAAI,CAAC,CAAC,OAAO,KAAK,UAAU,CAAA;AAC5D,CAAC;AAED,yEAAyE;AACzE,mBACE,CAAc;IAEd,OAAO,CAAC,CAAC,OAAO,KAAK,SAAS,CAAA;AAChC,CAAC"}
@@ -33,9 +33,27 @@ export interface ClientOptions {
33
33
  /** Headers added to every request. */
34
34
  headers?: Record<string, string>;
35
35
  }
36
+ /**
37
+ * A body sent as it is instead of as JSON: a file.
38
+ *
39
+ * `fetch` writes `Content-Length` itself for every one of these — the API
40
+ * requires it on a raw upload (411 without it) — and the multipart boundary for
41
+ * a `FormData`. A stream is deliberately not accepted: its length is unknown
42
+ * up front, so fetch would send it chunked and the upload would be refused.
43
+ */
44
+ export type RawBody = Blob | ArrayBuffer | Uint8Array | FormData;
36
45
  export interface RequestOptions {
37
46
  query?: Query | undefined;
47
+ /** Serialised with `JSON.stringify` and sent as `application/json`. */
38
48
  body?: unknown;
49
+ /**
50
+ * Sent untouched — for the endpoints that take a FILE. Mutually exclusive
51
+ * with `body`. Set `contentType` for a binary body; leave it unset for a
52
+ * `FormData`, whose `Content-Type` carries a boundary only fetch knows.
53
+ */
54
+ rawBody?: RawBody | undefined;
55
+ /** `Content-Type` of `rawBody`. Ignored without one. */
56
+ contentType?: string | undefined;
39
57
  signal?: AbortSignal | undefined;
40
58
  timeoutMs?: number | undefined;
41
59
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../src/core/http.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,SAAS,EACf,MAAM,aAAa,CAAA;AAwBpB,MAAM,MAAM,UAAU,GAClB,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,SAAS,GACT,SAAS,CAAC,MAAM,GAAG,MAAM,GA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