@v3finance/core-sdk 0.7.0 → 0.8.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.
@@ -1,6 +1,16 @@
1
1
  import { seg, type HttpClient } from '../core/http.js'
2
2
  import { toGated, type Gated } from '../core/gated.js'
3
3
  import type {
4
+ AddAmlStopListBody,
5
+ AmlDepositReview,
6
+ AmlRule,
7
+ AmlRuleEvaluateBody,
8
+ AmlRuleEvaluation,
9
+ AmlRules,
10
+ AmlStopList,
11
+ AmlStopListEntry,
12
+ CreateAmlRuleBody,
13
+ PatchAmlRuleBody,
4
14
  AmlCheck,
5
15
  AmlOfficers,
6
16
  AmlRecheckBody,
@@ -166,4 +176,77 @@ export class AmlResource {
166
176
  return toGated<AmlCheck, ApprovalRequestCreated>(res.status, res.data)
167
177
  }
168
178
 
179
+
180
+ // ---------- AML rules (A3) ----------
181
+
182
+ /**
183
+ * The vault's AML rules. A rule applies to the WHOLE vault, admins
184
+ * included, after the policies: it only ADDS — a block (`AML_BLOCKED`) or
185
+ * an AML officer's approval. It never allows what policies denied and never
186
+ * drops their approvals. Unknown risk leads to an officer, never to a
187
+ * block or a pass. Admins and officers only.
188
+ */
189
+ rules(): Promise<AmlRules> {
190
+ return this.#http.request<AmlRules>('GET', `${this.#base}/rules`)
191
+ }
192
+
193
+ /**
194
+ * Creates a rule. `scope` — which transfers (transfer selectors plus
195
+ * `destinationPattern`, the derivation path of OUR recipient address);
196
+ * `risk` — on what risk (`null` — always); `subject: 'provenance'` judges
197
+ * where the sender's funds came from instead of the recipient. A condition
198
+ * the provider cannot serve is a 400 `AML_PROVIDER_CAPABILITY`.
199
+ */
200
+ createRule(input: CreateAmlRuleBody): Promise<AmlRule> {
201
+ return this.#http.request<AmlRule>('POST', `${this.#base}/rules`, { body: input })
202
+ }
203
+
204
+ getRule(ruleId: string): Promise<AmlRule> {
205
+ return this.#http.request<AmlRule>('GET', `${this.#base}/rules/${seg(ruleId)}`)
206
+ }
207
+
208
+ /** Absent fields stay; the RESULTING rule is validated. Every change is a new `version`. */
209
+ updateRule(ruleId: string, patch: PatchAmlRuleBody): Promise<AmlRule> {
210
+ return this.#http.request<AmlRule>('PATCH', `${this.#base}/rules/${seg(ruleId)}`, { body: patch })
211
+ }
212
+
213
+ /**
214
+ * Dry run of the AML rules only (not the caller's policies) for a transfer
215
+ * from `fromAddressId` to `address`. `ruleIds` runs exactly those rules,
216
+ * DISABLED ones included — to see a rule before switching it on. `amount`
217
+ * is a decimal string, as in `transfers.create`.
218
+ */
219
+ evaluateRules(input: AmlRuleEvaluateBody): Promise<AmlRuleEvaluation> {
220
+ return this.#http.request<AmlRuleEvaluation>('POST', `${this.#base}/rules/evaluate`, { body: input })
221
+ }
222
+
223
+ // ---------- Stop list (A3) ----------
224
+
225
+ /** Addresses the vault considers unacceptable. Acts only through a rule with a `stopList` leaf. */
226
+ stopList(params: { includeRevoked?: boolean | undefined } = {}): Promise<AmlStopList> {
227
+ return this.#http.request<AmlStopList>('GET', `${this.#base}/stop-list`, { query: { ...params } })
228
+ }
229
+
230
+ /** Idempotent: the same address again updates the reason or brings it back. EVM — stored lowercase. */
231
+ addToStopList(input: AddAmlStopListBody): Promise<AmlStopListEntry> {
232
+ return this.#http.request<AmlStopListEntry>('POST', `${this.#base}/stop-list`, { body: input })
233
+ }
234
+
235
+ /** Soft; repeating it is not an error. */
236
+ removeFromStopList(entryId: string): Promise<AmlStopListEntry> {
237
+ return this.#http.request<AmlStopListEntry>('DELETE', `${this.#base}/stop-list/${seg(entryId)}`)
238
+ }
239
+
240
+ /**
241
+ * An AML officer marks a past deposit as reviewed: it stops being a source
242
+ * of risk for provenance rules (they have no time window). AML officers
243
+ * only, and only from the PHONE — web sessions get 403
244
+ * `WEB_SESSION_CANNOT_SIGN`. One mark per deposit; a repeat returns it.
245
+ */
246
+ markDepositReviewed(depositId: string, comment: string): Promise<AmlDepositReview> {
247
+ return this.#http.request<AmlDepositReview>('POST', `${this.#base}/deposits/${seg(depositId)}/reviewed`, {
248
+ body: { comment },
249
+ })
250
+ }
251
+
169
252
  }
package/src/version.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /** SDK version, sent in the `user-agent` header. */
2
- export const SDK_VERSION = '0.7.0'
2
+ export const SDK_VERSION = '0.8.0'
3
3
 
4
4
  /** Default API base URL. */
5
5
  export const DEFAULT_BASE_URL = 'https://policy-engine-rest.ezig.workers.dev'