@v3finance/core-sdk 0.7.0 → 0.9.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/CHANGELOG.md +51 -0
- package/dist/cjs/generated/operations.d.ts +72 -0
- package/dist/cjs/generated/operations.d.ts.map +1 -1
- package/dist/cjs/generated/operations.js +74 -2
- package/dist/cjs/generated/operations.js.map +1 -1
- package/dist/cjs/generated/types.d.ts +228 -4
- package/dist/cjs/generated/types.d.ts.map +1 -1
- package/dist/cjs/resources/aml.d.ts +46 -1
- package/dist/cjs/resources/aml.d.ts.map +1 -1
- package/dist/cjs/resources/aml.js +65 -0
- package/dist/cjs/resources/aml.js.map +1 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/generated/operations.d.ts +72 -0
- package/dist/esm/generated/operations.d.ts.map +1 -1
- package/dist/esm/generated/operations.js +74 -2
- package/dist/esm/generated/operations.js.map +1 -1
- package/dist/esm/generated/types.d.ts +228 -4
- package/dist/esm/generated/types.d.ts.map +1 -1
- package/dist/esm/resources/aml.d.ts +46 -1
- package/dist/esm/resources/aml.d.ts.map +1 -1
- package/dist/esm/resources/aml.js +65 -0
- package/dist/esm/resources/aml.js.map +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/docs/errors.md +9 -0
- package/package.json +1 -1
- package/src/generated/operations.ts +74 -2
- package/src/generated/types.ts +241 -4
- package/src/resources/aml.ts +87 -0
- package/src/version.ts +1 -1
package/src/generated/types.ts
CHANGED
|
@@ -667,7 +667,21 @@ export interface AmlOfficers {
|
|
|
667
667
|
items: AmlOfficer[]
|
|
668
668
|
}
|
|
669
669
|
|
|
670
|
-
|
|
670
|
+
export interface AmlRuleTrace {
|
|
671
|
+
ruleId: string
|
|
672
|
+
ruleCode: string
|
|
673
|
+
ruleName: string
|
|
674
|
+
/** range: -9007199254740991..9007199254740991 */
|
|
675
|
+
version: number
|
|
676
|
+
/** skipped — не по этой операции; clear — риск не совпал; fired — сработало */
|
|
677
|
+
result: "skipped" | "clear" | "fired"
|
|
678
|
+
/** match — риск совпал; unknown — проверки нет или нечем вычислить (→ подпись офицера) */
|
|
679
|
+
why?: "match" | "unknown"
|
|
680
|
+
outcome?: "block" | "officer"
|
|
681
|
+
detail?: string
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
/** УСТАРЕЛО: новые политики с этим селектором не принимаются (400) — риск задаётся AML-правилами Vault'а (/vaults/{code}/aml/rules). Риск второй стороны по данным AML-провайдера. ВАЖНО: уровень на операции — СНИМОК на момент решения, а не живая ссылка; текущий риск берётся отдельно через GET /aml/score */
|
|
671
685
|
export interface AmlValue {
|
|
672
686
|
/** Порог «не ниже чем» по УРОВНЮ риска второй стороны (у перевода — получателя). Уровень, а не числовой score: score калибруется провайдером и приходит вместе со своими thresholds, поэтому политика, написанная в числах, поехала бы вместе с их калибровкой */
|
|
673
687
|
minLevel: "critical" | "high" | "medium" | "low" | "minimal"
|
|
@@ -1825,11 +1839,11 @@ export interface RuleInput {
|
|
|
1825
1839
|
|
|
1826
1840
|
/**
|
|
1827
1841
|
* Атомарное условие. Валидность типа зависит от actionType политики (селектор вне своей строки → 400 при создании):
|
|
1828
|
-
* - transfer → senderPattern | destination | counterparty | counterpartyGroup | amount | token
|
|
1842
|
+
* - transfer → senderPattern | destination | counterparty | counterpartyGroup | amount | token
|
|
1829
1843
|
* - create_address → senderPattern
|
|
1830
1844
|
* - counterparty_* / counterparty_group_* → actorRole
|
|
1831
1845
|
*
|
|
1832
|
-
* Ретайрнуты: actorType (был no-op — единственный фактический тип инициатора «user», миграция 0043), signers (мультиподписи нет, контекст не заполнялся и селектор никогда бы не совпал)
|
|
1846
|
+
* Снят: aml (AML v2) — риск теперь условие AML-правил Vault'а (/vaults/{code}/aml/rules); в схеме остаётся, чтобы отказ (400) объяснял, куда он переехал. Ретайрнуты: actorType (был no-op — единственный фактический тип инициатора «user», миграция 0043), signers (мультиподписи нет, контекст не заполнялся и селектор никогда бы не совпал)
|
|
1833
1847
|
*/
|
|
1834
1848
|
export type SelectorInput = {
|
|
1835
1849
|
type: "senderPattern"
|
|
@@ -2155,11 +2169,13 @@ export interface EvaluationRequest {
|
|
|
2155
2169
|
context: EvaluationContext
|
|
2156
2170
|
}
|
|
2157
2171
|
|
|
2158
|
-
/** Решение движка. Порядок резолюции (Ф2): block → нарушенный лимит (отказ или эскалация в подпись) → требования подписи → allow → default-deny. requireApproval — это РЕШЕНИЕ движка, а не эффект
|
|
2172
|
+
/** Решение движка. Порядок резолюции (Ф2): block → нарушенный лимит (отказ или эскалация в подпись) → требования подписи → allow → default-deny. requireApproval — это РЕШЕНИЕ движка, а не эффект политики. После политик — AML-правила Vault'а (AML v2): только добавляют запрет (AML_BLOCKED) или требование подписи AML-офицера (policyCode aml:<code> в requirements[]); разрешить запрещённое они не могут */
|
|
2159
2173
|
export type EvaluationResult = {
|
|
2160
2174
|
decision: "allow"
|
|
2161
2175
|
matchedPolicyIds: string[]
|
|
2162
2176
|
trace?: PolicyTrace[]
|
|
2177
|
+
/** AML-правила Vault'а на этой операции — при ?explain=true и если правила есть */
|
|
2178
|
+
amlRules?: AmlRuleTrace[]
|
|
2163
2179
|
} | {
|
|
2164
2180
|
decision: "block"
|
|
2165
2181
|
reason: string
|
|
@@ -2170,7 +2186,11 @@ export type EvaluationResult = {
|
|
|
2170
2186
|
policyVersionId: string | null
|
|
2171
2187
|
/** Для лимита — «потрачено X из Y»; у явного block отсутствует */
|
|
2172
2188
|
detail?: string
|
|
2189
|
+
/** Запрет поставило AML-правило Vault'а (reason AML_BLOCKED, policyId — id правила, policyCode — aml:<code>), а не политика группы */
|
|
2190
|
+
amlRuleId?: string
|
|
2173
2191
|
trace?: PolicyTrace[]
|
|
2192
|
+
/** AML-правила Vault'а на этой операции — при ?explain=true и если правила есть */
|
|
2193
|
+
amlRules?: AmlRuleTrace[]
|
|
2174
2194
|
} | {
|
|
2175
2195
|
decision: "requireApproval"
|
|
2176
2196
|
/** ИСТОЧНИК ИСТИНЫ: ВСЕ требования подписи от применимых политик. Их может быть несколько («CFO И комплаенс»), и каждое набирает свой порог отдельно. Поля ниже дублируют лишь САМОЕ СТРОГОЕ требование ради совместимости — показывать пользователю только их значит занизить, сколько подписей ему предстоит собрать */
|
|
@@ -2189,11 +2209,15 @@ export type EvaluationResult = {
|
|
|
2189
2209
|
/** Инициатор остаётся среди approvers и может голосовать */
|
|
2190
2210
|
allowInitiatorApproval: boolean
|
|
2191
2211
|
trace?: PolicyTrace[]
|
|
2212
|
+
/** AML-правила Vault'а на этой операции — при ?explain=true и если правила есть */
|
|
2213
|
+
amlRules?: AmlRuleTrace[]
|
|
2192
2214
|
} | {
|
|
2193
2215
|
decision: "deny"
|
|
2194
2216
|
reason: "no_applicable_policies"
|
|
2195
2217
|
/** При ?explain=true — почему не применилась ни одна политика */
|
|
2196
2218
|
trace?: PolicyTrace[]
|
|
2219
|
+
/** AML-правила Vault'а на этой операции — при ?explain=true и если правила есть */
|
|
2220
|
+
amlRules?: AmlRuleTrace[]
|
|
2197
2221
|
}
|
|
2198
2222
|
|
|
2199
2223
|
export interface PolicyTrace {
|
|
@@ -5855,6 +5879,15 @@ export interface ReportTemplate {
|
|
|
5855
5879
|
updatedAt: string
|
|
5856
5880
|
}
|
|
5857
5881
|
|
|
5882
|
+
export interface AddAmlStopListBody {
|
|
5883
|
+
/** length: 1..∞ */
|
|
5884
|
+
address: string
|
|
5885
|
+
/** По умолчанию — по формату адреса */
|
|
5886
|
+
network?: "tron" | "ethereum"
|
|
5887
|
+
/** length: 0..500 */
|
|
5888
|
+
reason?: string
|
|
5889
|
+
}
|
|
5890
|
+
|
|
5858
5891
|
export interface AmlCheck {
|
|
5859
5892
|
/** Запись проверки (неизменяемая). null — запись не сохранилась, ответ провайдера при этом валиден */
|
|
5860
5893
|
id: string | null
|
|
@@ -5878,6 +5911,8 @@ export interface AmlCheck {
|
|
|
5878
5911
|
categories: AmlLinkCategory[]
|
|
5879
5912
|
/** Категории вне известного списка провайдера: метку переименовали или завели новую */
|
|
5880
5913
|
unrecognizedCategories: string[]
|
|
5914
|
+
/** Часть связей провайдер прислал битыми: «категории нет» тогда не ответ, а «неизвестно» */
|
|
5915
|
+
linksIncomplete?: boolean
|
|
5881
5916
|
/** Есть при view = links | full. null у стороны — её нет в ответе провайдера */
|
|
5882
5917
|
links?: {
|
|
5883
5918
|
incoming: AmlLinks | null
|
|
@@ -5921,6 +5956,19 @@ export interface AmlLinkCategory {
|
|
|
5921
5956
|
* range: -9007199254740991..9007199254740991
|
|
5922
5957
|
*/
|
|
5923
5958
|
count: number
|
|
5959
|
+
/** Связей категории по уровням. Нет у проверок, снятых до AML-правил (A3) */
|
|
5960
|
+
countByLevel?: {
|
|
5961
|
+
/** range: -9007199254740991..9007199254740991 */
|
|
5962
|
+
critical?: number
|
|
5963
|
+
/** range: -9007199254740991..9007199254740991 */
|
|
5964
|
+
high?: number
|
|
5965
|
+
/** range: -9007199254740991..9007199254740991 */
|
|
5966
|
+
medium?: number
|
|
5967
|
+
/** range: -9007199254740991..9007199254740991 */
|
|
5968
|
+
low?: number
|
|
5969
|
+
/** range: -9007199254740991..9007199254740991 */
|
|
5970
|
+
minimal?: number
|
|
5971
|
+
}
|
|
5924
5972
|
/** Самый высокий уровень среди связей категории */
|
|
5925
5973
|
maxLevel: AmlLevel | null
|
|
5926
5974
|
share: number | null
|
|
@@ -6011,6 +6059,25 @@ export interface ScorechainLinkNative {
|
|
|
6011
6059
|
address: string
|
|
6012
6060
|
}
|
|
6013
6061
|
|
|
6062
|
+
export interface AmlDepositReviewBody {
|
|
6063
|
+
/**
|
|
6064
|
+
* Почему депозит признан проверенным
|
|
6065
|
+
*
|
|
6066
|
+
* length: 1..1000
|
|
6067
|
+
*/
|
|
6068
|
+
comment: string
|
|
6069
|
+
}
|
|
6070
|
+
|
|
6071
|
+
export interface AmlDepositReview {
|
|
6072
|
+
id: string
|
|
6073
|
+
vaultId: string
|
|
6074
|
+
depositId: string
|
|
6075
|
+
reviewedById: string
|
|
6076
|
+
comment: string
|
|
6077
|
+
/** format: date-time */
|
|
6078
|
+
createdAt: string
|
|
6079
|
+
}
|
|
6080
|
+
|
|
6014
6081
|
export interface AmlInternalCheckBody {
|
|
6015
6082
|
/**
|
|
6016
6083
|
* Наш адрес Vault'а
|
|
@@ -6050,6 +6117,118 @@ export interface AmlRecheckBody {
|
|
|
6050
6117
|
provider?: "scorechain"
|
|
6051
6118
|
}
|
|
6052
6119
|
|
|
6120
|
+
/** При каком риске срабатывает правило: {and}|{or}|{not}|лист {selector,value}. Листья: level {min}; score {op: gte|lte, value} в родной шкале провайдера; category {categories[], side?: incoming|outgoing|any, minCount?, minLinkLevel?} — все ограничители необязательны; unknown — проверки нет (→ подпись офицера, не запрет; под not — тоже); stopList — адрес в стоп-листе Vault'а; unrecognizedCategory — у провайдера незнакомая категория. Лист, которого провайдер не умеет (доли, сущность адреса, санкционные органы), отвергается при записи. Вычисляется в трёхзначной логике: «неизвестно» ведёт к подписи AML-офицера, а не к запрету */
|
|
6121
|
+
export type AmlRiskCondition = {
|
|
6122
|
+
and: AmlRiskCondition[]
|
|
6123
|
+
} | {
|
|
6124
|
+
or: AmlRiskCondition[]
|
|
6125
|
+
} | {
|
|
6126
|
+
not: AmlRiskCondition
|
|
6127
|
+
} | {
|
|
6128
|
+
selector: "level" | "score" | "category" | "sanctions" | "unknown" | "stopList" | "unrecognizedCategory"
|
|
6129
|
+
value?: unknown
|
|
6130
|
+
}
|
|
6131
|
+
|
|
6132
|
+
export interface AmlRuleEvaluateBody {
|
|
6133
|
+
/** Что прогоняем; по умолчанию transfer. Для правок справочника `address` — адрес контрагента, сеть — `network`, `fromAddressId`/`amount`/`asset` не нужны */
|
|
6134
|
+
action?: "transfer" | "counterparty_address_add" | "counterparty_group_add"
|
|
6135
|
+
/**
|
|
6136
|
+
* Получатель перевода или адрес контрагента
|
|
6137
|
+
*
|
|
6138
|
+
* length: 1..∞
|
|
6139
|
+
*/
|
|
6140
|
+
address: string
|
|
6141
|
+
/**
|
|
6142
|
+
* Наш адрес-отправитель (для senderPattern и сети). Обязателен для transfer
|
|
6143
|
+
*
|
|
6144
|
+
* length: 1..∞
|
|
6145
|
+
*/
|
|
6146
|
+
fromAddressId?: string
|
|
6147
|
+
/**
|
|
6148
|
+
* Сеть адреса контрагента (Network.slug). Обязательна для правок справочника
|
|
6149
|
+
*
|
|
6150
|
+
* length: 1..∞
|
|
6151
|
+
*/
|
|
6152
|
+
network?: string
|
|
6153
|
+
/** DECIMAL строка, как в POST /transfers (для селектора amount) */
|
|
6154
|
+
amount?: string
|
|
6155
|
+
/** Код токена; по умолчанию — токен адреса */
|
|
6156
|
+
asset?: string
|
|
6157
|
+
/**
|
|
6158
|
+
* Прогнать ровно эти правила — в том числе ВЫКЛЮЧЕННЫЕ: так правило видно до включения. Без поля — все включённые правила Vault'а
|
|
6159
|
+
*
|
|
6160
|
+
* items: 0..50
|
|
6161
|
+
*/
|
|
6162
|
+
ruleIds?: string[]
|
|
6163
|
+
}
|
|
6164
|
+
|
|
6165
|
+
export interface AmlRuleEvaluation {
|
|
6166
|
+
/** Итог только по AML-правилам: clear — ни одно не сработало */
|
|
6167
|
+
decision: "clear" | "officer" | "block"
|
|
6168
|
+
/** Проверка получателя, по которой считали; null — не удалась */
|
|
6169
|
+
check: AmlCheck | null
|
|
6170
|
+
rules: Array<{
|
|
6171
|
+
ruleId: string
|
|
6172
|
+
ruleCode: string
|
|
6173
|
+
ruleName: string
|
|
6174
|
+
/** range: -9007199254740991..9007199254740991 */
|
|
6175
|
+
version: number
|
|
6176
|
+
result: "skipped" | "clear" | "fired"
|
|
6177
|
+
why?: "match" | "unknown"
|
|
6178
|
+
outcome?: "block" | "officer"
|
|
6179
|
+
detail?: string
|
|
6180
|
+
/** Правки справочника: адрес, на котором сработало */
|
|
6181
|
+
address?: string
|
|
6182
|
+
}>
|
|
6183
|
+
}
|
|
6184
|
+
|
|
6185
|
+
export interface AmlRule {
|
|
6186
|
+
id: string
|
|
6187
|
+
vaultId: string
|
|
6188
|
+
code: string
|
|
6189
|
+
name: string
|
|
6190
|
+
description: string | null
|
|
6191
|
+
enabled: boolean
|
|
6192
|
+
enabledAt: string | null
|
|
6193
|
+
/**
|
|
6194
|
+
* Растёт на каждой правке
|
|
6195
|
+
*
|
|
6196
|
+
* range: -9007199254740991..9007199254740991
|
|
6197
|
+
*/
|
|
6198
|
+
version: number
|
|
6199
|
+
provider: "scorechain"
|
|
6200
|
+
/** Где стоит правило: transfer — перевод; counterparty_address_add — новый адрес контрагента (создание с адресами, правка, отдельная ручка адреса); counterparty_group_add — контрагент в группу (проверяются ВСЕ его адреса). Белый список стоит на контрагенте, поэтому эти правки расширяют круг получателей */
|
|
6201
|
+
appliesTo: Array<"transfer" | "counterparty_address_add" | "counterparty_group_add">
|
|
6202
|
+
/** К каким операциям: селекторы перевода (senderPattern, destination, counterparty, counterpartyGroup, amount perTx, token) и destinationPattern — путь деривации НАШЕГО адреса-получателя. null — ко всем. Только у переводов: правило на правках справочника обязано иметь null */
|
|
6203
|
+
scope: PolicyCondition | null
|
|
6204
|
+
/** Чей риск: counterparty — получателя перевода; provenance — источников средств адреса-отправителя (внешние депозиты за всю историю, через внутренние переводы до provenance.depth); совпадение хотя бы одного источника — срабатывание */
|
|
6205
|
+
subject: "counterparty" | "provenance"
|
|
6206
|
+
/** null — срабатывает всегда */
|
|
6207
|
+
risk: AmlRiskCondition | null
|
|
6208
|
+
/** Только для subject = provenance */
|
|
6209
|
+
provenance: {
|
|
6210
|
+
/**
|
|
6211
|
+
* 0..3 внутренних перевода назад
|
|
6212
|
+
*
|
|
6213
|
+
* range: -9007199254740991..9007199254740991
|
|
6214
|
+
*/
|
|
6215
|
+
depth: number
|
|
6216
|
+
} | null
|
|
6217
|
+
outcome: "block" | "officer"
|
|
6218
|
+
/** Может ли офицер подтвердить собственный перевод (по умолчанию нет) */
|
|
6219
|
+
allowInitiatorApproval: boolean
|
|
6220
|
+
createdById: string
|
|
6221
|
+
updatedById: string | null
|
|
6222
|
+
/** format: date-time */
|
|
6223
|
+
createdAt: string
|
|
6224
|
+
/** format: date-time */
|
|
6225
|
+
updatedAt: string
|
|
6226
|
+
}
|
|
6227
|
+
|
|
6228
|
+
export interface AmlRules {
|
|
6229
|
+
items: AmlRule[]
|
|
6230
|
+
}
|
|
6231
|
+
|
|
6053
6232
|
export interface AmlSettings {
|
|
6054
6233
|
/** Что видит ЛЮБОЙ участник Vault'а без гранта. Гранты только расширяют */
|
|
6055
6234
|
memberDefaultView: AmlView
|
|
@@ -6074,6 +6253,26 @@ export interface VaultAmlProvider {
|
|
|
6074
6253
|
maxAgeSeconds: number
|
|
6075
6254
|
}
|
|
6076
6255
|
|
|
6256
|
+
export interface AmlStopListEntry {
|
|
6257
|
+
id: string
|
|
6258
|
+
vaultId: string
|
|
6259
|
+
network: string
|
|
6260
|
+
address: string
|
|
6261
|
+
reason: string | null
|
|
6262
|
+
addedById: string
|
|
6263
|
+
status: "active" | "revoked"
|
|
6264
|
+
revokedAt: string | null
|
|
6265
|
+
revokedById: string | null
|
|
6266
|
+
/** format: date-time */
|
|
6267
|
+
createdAt: string
|
|
6268
|
+
/** format: date-time */
|
|
6269
|
+
updatedAt: string
|
|
6270
|
+
}
|
|
6271
|
+
|
|
6272
|
+
export interface AmlStopList {
|
|
6273
|
+
items: AmlStopListEntry[]
|
|
6274
|
+
}
|
|
6275
|
+
|
|
6077
6276
|
export interface AmlVisibilityGrant {
|
|
6078
6277
|
id: string
|
|
6079
6278
|
vaultId: string
|
|
@@ -6099,6 +6298,26 @@ export interface AmlVisibilityGrants {
|
|
|
6099
6298
|
items: AmlVisibilityGrant[]
|
|
6100
6299
|
}
|
|
6101
6300
|
|
|
6301
|
+
export interface CreateAmlRuleBody {
|
|
6302
|
+
/** length: 1..∞ */
|
|
6303
|
+
code: string
|
|
6304
|
+
/** length: 1..∞ */
|
|
6305
|
+
name: string
|
|
6306
|
+
description?: string | null
|
|
6307
|
+
enabled?: boolean
|
|
6308
|
+
provider?: "scorechain"
|
|
6309
|
+
appliesTo?: string[]
|
|
6310
|
+
scope?: PolicyCondition | null
|
|
6311
|
+
subject?: string
|
|
6312
|
+
risk?: AmlRiskCondition | null
|
|
6313
|
+
provenance?: {
|
|
6314
|
+
/** range: -9007199254740991..9007199254740991 */
|
|
6315
|
+
depth?: number
|
|
6316
|
+
} | null
|
|
6317
|
+
outcome: "block" | "officer"
|
|
6318
|
+
allowInitiatorApproval?: boolean
|
|
6319
|
+
}
|
|
6320
|
+
|
|
6102
6321
|
export interface CreateAmlVisibilityGrantBody {
|
|
6103
6322
|
subjectType: "user" | "group"
|
|
6104
6323
|
/** length: 1..∞ */
|
|
@@ -6108,6 +6327,24 @@ export interface CreateAmlVisibilityGrantBody {
|
|
|
6108
6327
|
role: "links" | "full"
|
|
6109
6328
|
}
|
|
6110
6329
|
|
|
6330
|
+
export interface PatchAmlRuleBody {
|
|
6331
|
+
/** length: 1..∞ */
|
|
6332
|
+
name?: string
|
|
6333
|
+
description?: string | null
|
|
6334
|
+
enabled?: boolean
|
|
6335
|
+
provider?: "scorechain"
|
|
6336
|
+
appliesTo?: string[]
|
|
6337
|
+
scope?: PolicyCondition | null
|
|
6338
|
+
subject?: string
|
|
6339
|
+
risk?: AmlRiskCondition | null
|
|
6340
|
+
provenance?: {
|
|
6341
|
+
/** range: -9007199254740991..9007199254740991 */
|
|
6342
|
+
depth?: number
|
|
6343
|
+
} | null
|
|
6344
|
+
outcome?: "block" | "officer"
|
|
6345
|
+
allowInitiatorApproval?: boolean
|
|
6346
|
+
}
|
|
6347
|
+
|
|
6111
6348
|
export interface UpdateAmlSettingsBody {
|
|
6112
6349
|
memberDefaultView?: AmlView
|
|
6113
6350
|
providers?: Array<{
|
package/src/resources/aml.ts
CHANGED
|
@@ -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,81 @@ 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
|
+
* With `action: "counterparty_address_add" | "counterparty_group_add"` it
|
|
220
|
+
* runs the rules on counterparty-directory edits instead: `address` is the
|
|
221
|
+
* counterparty's address and `network` is required; `fromAddressId` is not.
|
|
222
|
+
*/
|
|
223
|
+
evaluateRules(input: AmlRuleEvaluateBody): Promise<AmlRuleEvaluation> {
|
|
224
|
+
return this.#http.request<AmlRuleEvaluation>('POST', `${this.#base}/rules/evaluate`, { body: input })
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// ---------- Stop list (A3) ----------
|
|
228
|
+
|
|
229
|
+
/** Addresses the vault considers unacceptable. Acts only through a rule with a `stopList` leaf. */
|
|
230
|
+
stopList(params: { includeRevoked?: boolean | undefined } = {}): Promise<AmlStopList> {
|
|
231
|
+
return this.#http.request<AmlStopList>('GET', `${this.#base}/stop-list`, { query: { ...params } })
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/** Idempotent: the same address again updates the reason or brings it back. EVM — stored lowercase. */
|
|
235
|
+
addToStopList(input: AddAmlStopListBody): Promise<AmlStopListEntry> {
|
|
236
|
+
return this.#http.request<AmlStopListEntry>('POST', `${this.#base}/stop-list`, { body: input })
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/** Soft; repeating it is not an error. */
|
|
240
|
+
removeFromStopList(entryId: string): Promise<AmlStopListEntry> {
|
|
241
|
+
return this.#http.request<AmlStopListEntry>('DELETE', `${this.#base}/stop-list/${seg(entryId)}`)
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* An AML officer marks a past deposit as reviewed: it stops being a source
|
|
246
|
+
* of risk for provenance rules (they have no time window). AML officers
|
|
247
|
+
* only, and only from the PHONE — web sessions get 403
|
|
248
|
+
* `WEB_SESSION_CANNOT_SIGN`. One mark per deposit; a repeat returns it.
|
|
249
|
+
*/
|
|
250
|
+
markDepositReviewed(depositId: string, comment: string): Promise<AmlDepositReview> {
|
|
251
|
+
return this.#http.request<AmlDepositReview>('POST', `${this.#base}/deposits/${seg(depositId)}/reviewed`, {
|
|
252
|
+
body: { comment },
|
|
253
|
+
})
|
|
254
|
+
}
|
|
255
|
+
|
|
169
256
|
}
|
package/src/version.ts
CHANGED