@v3finance/core-sdk 0.2.4 → 0.3.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 (87) hide show
  1. package/CHANGELOG.md +74 -0
  2. package/README.md +9 -2
  3. package/dist/cjs/client.d.ts +2 -0
  4. package/dist/cjs/client.d.ts.map +1 -1
  5. package/dist/cjs/client.js +2 -0
  6. package/dist/cjs/client.js.map +1 -1
  7. package/dist/cjs/core/gated.d.ts +6 -5
  8. package/dist/cjs/core/gated.d.ts.map +1 -1
  9. package/dist/cjs/core/gated.js +6 -5
  10. package/dist/cjs/core/gated.js.map +1 -1
  11. package/dist/cjs/core/pagination.d.ts +4 -3
  12. package/dist/cjs/core/pagination.d.ts.map +1 -1
  13. package/dist/cjs/core/pagination.js +4 -3
  14. package/dist/cjs/core/pagination.js.map +1 -1
  15. package/dist/cjs/generated/operations.d.ts +40 -0
  16. package/dist/cjs/generated/operations.d.ts.map +1 -1
  17. package/dist/cjs/generated/operations.js +42 -2
  18. package/dist/cjs/generated/operations.js.map +1 -1
  19. package/dist/cjs/generated/types.d.ts +51 -2
  20. package/dist/cjs/generated/types.d.ts.map +1 -1
  21. package/dist/cjs/index.d.ts +1 -0
  22. package/dist/cjs/index.d.ts.map +1 -1
  23. package/dist/cjs/index.js +3 -1
  24. package/dist/cjs/index.js.map +1 -1
  25. package/dist/cjs/resources/approvals.d.ts +11 -1
  26. package/dist/cjs/resources/approvals.d.ts.map +1 -1
  27. package/dist/cjs/resources/approvals.js +11 -1
  28. package/dist/cjs/resources/approvals.js.map +1 -1
  29. package/dist/cjs/resources/transferDrafts.d.ts +119 -0
  30. package/dist/cjs/resources/transferDrafts.d.ts.map +1 -0
  31. package/dist/cjs/resources/transferDrafts.js +128 -0
  32. package/dist/cjs/resources/transferDrafts.js.map +1 -0
  33. package/dist/cjs/resources/transfers.d.ts +18 -2
  34. package/dist/cjs/resources/transfers.d.ts.map +1 -1
  35. package/dist/cjs/resources/transfers.js +18 -2
  36. package/dist/cjs/resources/transfers.js.map +1 -1
  37. package/dist/cjs/version.d.ts +1 -1
  38. package/dist/cjs/version.js +1 -1
  39. package/dist/esm/client.d.ts +2 -0
  40. package/dist/esm/client.d.ts.map +1 -1
  41. package/dist/esm/client.js +2 -0
  42. package/dist/esm/client.js.map +1 -1
  43. package/dist/esm/core/gated.d.ts +6 -5
  44. package/dist/esm/core/gated.d.ts.map +1 -1
  45. package/dist/esm/core/gated.js +6 -5
  46. package/dist/esm/core/gated.js.map +1 -1
  47. package/dist/esm/core/pagination.d.ts +4 -3
  48. package/dist/esm/core/pagination.d.ts.map +1 -1
  49. package/dist/esm/core/pagination.js +4 -3
  50. package/dist/esm/core/pagination.js.map +1 -1
  51. package/dist/esm/generated/operations.d.ts +40 -0
  52. package/dist/esm/generated/operations.d.ts.map +1 -1
  53. package/dist/esm/generated/operations.js +42 -2
  54. package/dist/esm/generated/operations.js.map +1 -1
  55. package/dist/esm/generated/types.d.ts +51 -2
  56. package/dist/esm/generated/types.d.ts.map +1 -1
  57. package/dist/esm/index.d.ts +1 -0
  58. package/dist/esm/index.d.ts.map +1 -1
  59. package/dist/esm/index.js +1 -0
  60. package/dist/esm/index.js.map +1 -1
  61. package/dist/esm/resources/approvals.d.ts +11 -1
  62. package/dist/esm/resources/approvals.d.ts.map +1 -1
  63. package/dist/esm/resources/approvals.js +11 -1
  64. package/dist/esm/resources/approvals.js.map +1 -1
  65. package/dist/esm/resources/transferDrafts.d.ts +119 -0
  66. package/dist/esm/resources/transferDrafts.d.ts.map +1 -0
  67. package/dist/esm/resources/transferDrafts.js +124 -0
  68. package/dist/esm/resources/transferDrafts.js.map +1 -0
  69. package/dist/esm/resources/transfers.d.ts +18 -2
  70. package/dist/esm/resources/transfers.d.ts.map +1 -1
  71. package/dist/esm/resources/transfers.js +18 -2
  72. package/dist/esm/resources/transfers.js.map +1 -1
  73. package/dist/esm/version.d.ts +1 -1
  74. package/dist/esm/version.js +1 -1
  75. package/docs/concepts.md +14 -2
  76. package/docs/errors.md +22 -5
  77. package/package.json +1 -1
  78. package/src/client.ts +3 -0
  79. package/src/core/gated.ts +6 -5
  80. package/src/core/pagination.ts +4 -3
  81. package/src/generated/operations.ts +42 -2
  82. package/src/generated/types.ts +55 -2
  83. package/src/index.ts +5 -0
  84. package/src/resources/approvals.ts +11 -1
  85. package/src/resources/transferDrafts.ts +157 -0
  86. package/src/resources/transfers.ts +18 -2
  87. package/src/version.ts +1 -1
@@ -8,8 +8,8 @@
8
8
  // resource method calls an operation that exists, and that a new endpoint in
9
9
  // the API does not slip in unclassified.
10
10
  //
11
- // Operations: 171 · admin: 40 · both: 1 · member: 127 · service: 3
12
- // Spec sha256: 1f2a93f5a31a423e3301b4bfa103ad3db26723285cae060d2e8a904a2b3bffe0
11
+ // Operations: 176 · admin: 40 · both: 1 · member: 132 · service: 3
12
+ // Spec sha256: faff9c53076b1b6460bc4dbae0a7c37816deeb332bb805cab84fc847419ec4f7
13
13
 
14
14
  export type Audience = 'member' | 'admin' | 'service' | 'both' | 'unknown'
15
15
 
@@ -160,6 +160,14 @@ export const OPERATIONS = {
160
160
  "summary": "Отказаться от доступа, который мне выдали",
161
161
  "audience": "member"
162
162
  },
163
+ "DELETE /api/v1/vaults/{code}/transfer-drafts/{id}": {
164
+ "method": "delete",
165
+ "path": "/api/v1/vaults/{code}/transfer-drafts/{id}",
166
+ "operationId": "deleteApiV1VaultsByCodeTransferDraftsById",
167
+ "tag": "Transfer drafts",
168
+ "summary": "Удалить черновик",
169
+ "audience": "member"
170
+ },
163
171
  "DELETE /api/v1/vaults/{code}/visibility-grants/{id}": {
164
172
  "method": "delete",
165
173
  "path": "/api/v1/vaults/{code}/visibility-grants/{id}",
@@ -792,6 +800,22 @@ export const OPERATIONS = {
792
800
  "summary": "Адреса, расшаренные мне (прямые гранты на адрес)",
793
801
  "audience": "member"
794
802
  },
803
+ "GET /api/v1/vaults/{code}/transfer-drafts": {
804
+ "method": "get",
805
+ "path": "/api/v1/vaults/{code}/transfer-drafts",
806
+ "operationId": "getApiV1VaultsByCodeTransferDrafts",
807
+ "tag": "Transfer drafts",
808
+ "summary": "Мои черновики переводов",
809
+ "audience": "member"
810
+ },
811
+ "GET /api/v1/vaults/{code}/transfer-drafts/{id}": {
812
+ "method": "get",
813
+ "path": "/api/v1/vaults/{code}/transfer-drafts/{id}",
814
+ "operationId": "getApiV1VaultsByCodeTransferDraftsById",
815
+ "tag": "Transfer drafts",
816
+ "summary": "Черновик перевода",
817
+ "audience": "member"
818
+ },
795
819
  "GET /api/v1/vaults/{code}/transfers/{id}": {
796
820
  "method": "get",
797
821
  "path": "/api/v1/vaults/{code}/transfers/{id}",
@@ -1344,6 +1368,22 @@ export const OPERATIONS = {
1344
1368
  "summary": "Создать место (приглашение по ссылке)",
1345
1369
  "audience": "admin"
1346
1370
  },
1371
+ "POST /api/v1/vaults/{code}/transfer-drafts": {
1372
+ "method": "post",
1373
+ "path": "/api/v1/vaults/{code}/transfer-drafts",
1374
+ "operationId": "postApiV1VaultsByCodeTransferDrafts",
1375
+ "tag": "Transfer drafts",
1376
+ "summary": "Создать черновик перевода",
1377
+ "audience": "member"
1378
+ },
1379
+ "POST /api/v1/vaults/{code}/transfer-drafts/{id}/send": {
1380
+ "method": "post",
1381
+ "path": "/api/v1/vaults/{code}/transfer-drafts/{id}/send",
1382
+ "operationId": "postApiV1VaultsByCodeTransferDraftsByIdSend",
1383
+ "tag": "Transfer drafts",
1384
+ "summary": "Отправить черновик (только из мобильного приложения)",
1385
+ "audience": "member"
1386
+ },
1347
1387
  "POST /api/v1/vaults/{code}/transfers": {
1348
1388
  "method": "post",
1349
1389
  "path": "/api/v1/vaults/{code}/transfers",
@@ -982,6 +982,8 @@ export interface OperationCategoryAssignment {
982
982
  }
983
983
  /** Ключи скрытых (sensitive) полей, недоступных вызывающему */
984
984
  redactedFields: string[]
985
+ /** Может ли вызывающий менять (PATCH) и снимать (DELETE) это назначение. false — только просмотр: кнопку правки не показывать, PATCH ответит 403. Из redactedFields это не выводится: пустой список бывает и у того, кто только смотрит. true не обещает правки сразу — при approvalScope edit/assign_and_edit PATCH уйдёт в заявку (202) */
986
+ canEdit: boolean
985
987
  /** range: -9007199254740991..9007199254740991 */
986
988
  version: number
987
989
  status: "active" | "removed"
@@ -1748,13 +1750,25 @@ export interface CreateTransferBody {
1748
1750
  amount: string
1749
1751
  asset: string
1750
1752
  /**
1751
- * Уникальный ключ попытки перевода (рекомендуется: uuid). Повторный запрос с тем же ключом и теми же параметрами вернёт 200 с существующим переводом — без второго broadcast, без повторной оценки политик. Тот же ключ с другими параметрами — 409 IDEMPOTENCY_KEY_REUSED. Для новой попытки после failed — новый ключ.
1753
+ * Уникальный ключ попытки перевода (рекомендуется: uuid). Повторный запрос с тем же ключом и теми же параметрами вернёт 200 с существующим переводом — без второго broadcast, без повторной оценки политик. Тот же ключ с другими параметрами — 409 IDEMPOTENCY_KEY_REUSED. Для новой попытки после failed — новый ключ. Префикс `draft:` зарезервирован за отправкой черновиков — такой ключ отвергается (400).
1752
1754
  *
1753
1755
  * length: 8..128
1754
1756
  */
1755
1757
  idempotencyKey?: string
1756
1758
  }
1757
1759
 
1760
+ /** Параметры будущего перевода. Ключа идемпотентности нет: повтор создаёт второй черновик (лишний удаляется). Контрагент не хранится — его подбирают по адресу получателя при отправке, как у обычного перевода */
1761
+ export interface CreateTransferDraftBody {
1762
+ /** Адрес-отправитель: нужен доступ на перевод с него (владелец / admin / грант) */
1763
+ fromAddressId: string
1764
+ /** Адрес получателя. Формат проверяется по типу сети адреса-отправителя, как у POST /transfers: не подошёл — 400 INVALID_DESTINATION_ADDRESS. Строка хранится как есть */
1765
+ toAddress: string
1766
+ /** DECIMAL строка, как у POST /transfers — хранится в минимальных единицах токена */
1767
+ amount: string
1768
+ /** Код токена (Token.code) */
1769
+ asset: string
1770
+ }
1771
+
1758
1772
  export interface CreateVaultBody {
1759
1773
  vault: {
1760
1774
  code: string
@@ -1787,7 +1801,7 @@ export interface CreateVisibilityGrantBody {
1787
1801
  export type VisibilityScope = "self" | "group" | "vault"
1788
1802
 
1789
1803
  export interface EditAssignmentBody {
1790
- /** Патч значений (мерджится; null очищает ключ). required остаётся обязательным */
1804
+ /** Патч значений (мерджится; null очищает ключ). required остаётся обязательным. Значение архивного поля прислать нельзя (CATEGORY_FIELD_ARCHIVED); если оно осталось с прошлых версий и в патче его нет — переносится как есть */
1791
1805
  values: {
1792
1806
  [key: string]: unknown
1793
1807
  }
@@ -3444,6 +3458,45 @@ export interface TransferApprover {
3444
3458
  user: UserCard | null
3445
3459
  }
3446
3460
 
3461
+ export interface TransferDraftResult {
3462
+ draft: TransferDraft
3463
+ }
3464
+
3465
+ export interface TransferDraft {
3466
+ /** cuid */
3467
+ id: string
3468
+ /** draft — ждёт отправки из приложения; sent — перевод создан (его исход — в transactionId: `sent` НЕ значит «деньги ушли»); discarded — удалён, перевод по нему не создавался */
3469
+ status: "draft" | "sent" | "discarded"
3470
+ fromAddress: {
3471
+ /** cuid */
3472
+ id: string
3473
+ address: string
3474
+ label: string | null
3475
+ /** Network.slug — сеть перевода */
3476
+ network: string
3477
+ }
3478
+ toAddress: string
3479
+ /** raw smallest units */
3480
+ amount: string
3481
+ /** Сумма по decimals токена; null — токена нет в реестре */
3482
+ amountDecimal: string | null
3483
+ /** Token.code */
3484
+ asset: string
3485
+ /** Символ токена; null — токена нет в реестре */
3486
+ assetSymbol: string | null
3487
+ /** Перевод, созданный отправкой (у sent); иначе null */
3488
+ transactionId: string | null
3489
+ /** format: date-time */
3490
+ createdAt: string
3491
+ sentAt: string | null
3492
+ discardedAt: string | null
3493
+ }
3494
+
3495
+ export interface TransferDraftsPage {
3496
+ items: TransferDraft[]
3497
+ nextCursor: string | null
3498
+ }
3499
+
3447
3500
  export interface UserGroupDetail {
3448
3501
  id: string
3449
3502
  name: string
package/src/index.ts CHANGED
@@ -89,6 +89,11 @@ export {
89
89
  } from './resources/addresses.js'
90
90
 
91
91
  export { TransfersResource, type VoteInput } from './resources/transfers.js'
92
+ export {
93
+ TransferDraftsResource,
94
+ type ListTransferDraftsParams,
95
+ type TransferDraftStatus,
96
+ } from './resources/transferDrafts.js'
92
97
  export {
93
98
  HistoryResource,
94
99
  type HistoryParams,
@@ -101,6 +101,12 @@ export class ApprovalsResource {
101
101
  * an earlier call left undone (it recorded the vote and broke off) — a veto,
102
102
  * or an approval once the threshold is met — instead of 409
103
103
  * `ALREADY_VOTED`.
104
+ *
105
+ * Signatures are given from the mobile app; from a browser only by a
106
+ * platform administrator; from a web login by nobody (the table is on
107
+ * `TransferDraftsResource`). Any other session gets 403
108
+ * `WEB_SESSION_CANNOT_SIGN` here, on a request of any kind. `cancel()` of
109
+ * your own request is open to any session.
104
110
  */
105
111
  vote(requestId: string, input: VoteBody): Promise<RequestVoteResult> {
106
112
  return this.#http.request<RequestVoteResult>(
@@ -115,7 +121,11 @@ export class ApprovalsResource {
115
121
  *
116
122
  * Only while the request is `PENDING`, and only as its initiator or as an
117
123
  * admin — the admin case exists so a request whose initiator is gone can
118
- * still be cleared instead of holding the reserve forever.
124
+ * still be cleared instead of holding the reserve forever. Cancelling
125
+ * someone else's is a "no" like a veto, so only from a session that may
126
+ * sign: an administrator from the mobile app, a platform administrator also
127
+ * from a browser. Otherwise 403 `NOT_INITIATOR`. Your own is cancelled from
128
+ * any session.
119
129
  *
120
130
  * @param reason IGNORED BY THE SERVER, and no longer sent. The endpoint
121
131
  * declares no request body and the handler never reads one, so the reason
@@ -0,0 +1,157 @@
1
+ import { seg, type HttpClient } from '../core/http.js'
2
+ import type { PageParams } from '../core/pagination.js'
3
+ import { toGated, type Gated } from '../core/gated.js'
4
+ import type {
5
+ CreateTransactionResult,
6
+ CreateTransferDraftBody,
7
+ TransferDraft,
8
+ TransferDraftResult,
9
+ TransferDraftsPage,
10
+ } from '../generated/types.js'
11
+
12
+ /**
13
+ * `draft` — waiting to be sent from the mobile app; `sent` — a transfer was
14
+ * created from it, which is NOT the same as "the money left" (read the
15
+ * transfer by `transactionId`); `discarded` — deleted, no transfer was created.
16
+ */
17
+ export type TransferDraftStatus = TransferDraft['status']
18
+
19
+ export interface ListTransferDraftsParams extends PageParams {
20
+ /** One status. Omitted — every draft of yours, discarded ones included. */
21
+ status?: TransferDraftStatus | undefined
22
+ }
23
+
24
+ /**
25
+ * Transfer drafts: how a transfer is prepared in a web session.
26
+ *
27
+ * Money is sent and signatures are given from the mobile app. Who may depends
28
+ * on how the session was obtained:
29
+ *
30
+ * mobile app — anyone (an older session, issued before the API told
31
+ * sessions apart, counts as one);
32
+ * browser — signed in by the email link, as the admin panel is: a
33
+ * platform administrator only;
34
+ * web login — nobody, a platform administrator included.
35
+ *
36
+ * A session that may not is refused with 403 `WEB_SESSION_CANNOT_SIGN` on
37
+ * `transfers.send`, `transfers.vote`, `transfers.reconcile`, `approvals.vote`
38
+ * and `send` below — the refusal is the server's, so hiding a button in a web
39
+ * client is not what enforces it. What a web session can do is create a
40
+ * draft: the API pushes it to the author's mobile devices, and the author
41
+ * sends it from there. Cancelling your OWN transfer or request is open to any
42
+ * session.
43
+ *
44
+ * A draft is seen and touched ONLY by its author — an administrator included.
45
+ * Anyone else's draft, a missing one and one from another vault all answer
46
+ * the same 404 `TRANSFER_DRAFT_NOT_FOUND`.
47
+ *
48
+ * A draft is immutable: for other parameters create a new one and discard the
49
+ * old.
50
+ */
51
+ export class TransferDraftsResource {
52
+ readonly #http: HttpClient
53
+ readonly #base: string
54
+
55
+ constructor(http: HttpClient, vaultCode: string) {
56
+ this.#http = http
57
+ this.#base = `/api/v1/vaults/${seg(vaultCode)}/transfer-drafts`
58
+ }
59
+
60
+ /**
61
+ * Creates a draft. Allowed in a web session — that is what it is for.
62
+ *
63
+ * Checked as `transfers.send` checks, with the same codes: the address
64
+ * (404 `ADDRESS_NOT_FOUND`, 400 `ADDRESS_NOT_IN_VAULT`), the right to
65
+ * transfer from it (403 `ADDRESS_TRANSFER_FORBIDDEN`), the token (400
66
+ * `TOKEN_NOT_FOUND`, `TOKEN_NETWORK_MISMATCH`), the amount (400
67
+ * `INVALID_AMOUNT`) and the recipient's format (400
68
+ * `INVALID_DESTINATION_ADDRESS`). AML, policies and the balance are NOT
69
+ * checked here: they are decided when the draft is sent.
70
+ *
71
+ * `amount` is a decimal string, as in `transfers.send`; the draft keeps it
72
+ * in smallest units (`draft.amount`) beside `amountDecimal`.
73
+ *
74
+ * There is no idempotency key: a retry creates a second draft. After
75
+ * creation the author gets a push on their mobile devices (`data.type` is
76
+ * `transfer_draft_created`, with `draftId`); a failed push does not fail
77
+ * the call.
78
+ */
79
+ create(input: CreateTransferDraftBody): Promise<TransferDraftResult> {
80
+ return this.#http.request<TransferDraftResult>('POST', this.#base, { body: input })
81
+ }
82
+
83
+ /** Your own drafts, newest first. Keyset-paginated: `{items, nextCursor}`. */
84
+ list(params: ListTransferDraftsParams = {}): Promise<TransferDraftsPage> {
85
+ return this.#http.request<TransferDraftsPage>('GET', this.#base, { query: { ...params } })
86
+ }
87
+
88
+ get(draftId: string): Promise<TransferDraftResult> {
89
+ return this.#http.request<TransferDraftResult>('GET', `${this.#base}/${seg(draftId)}`)
90
+ }
91
+
92
+ /**
93
+ * Deletes a draft — softly: `draft` becomes `discarded`, and it can no
94
+ * longer be sent. Discarding one already discarded answers 200 with the
95
+ * same draft. Allowed in a web session.
96
+ *
97
+ * A draft a transfer was created from is 409 `TRANSFER_DRAFT_ALREADY_SENT`,
98
+ * with `details.transactionId`: discarding it does not undo the transfer.
99
+ * A transfer still awaiting signatures is withdrawn with
100
+ * `transfers.cancel()`. The same 409 comes back when the transfer exists
101
+ * but the draft is not marked `sent` yet — it is being sent from a phone
102
+ * right now, or that send broke off — and the mark is written then.
103
+ */
104
+ discard(draftId: string): Promise<TransferDraftResult> {
105
+ return this.#http.request<TransferDraftResult>('DELETE', `${this.#base}/${seg(draftId)}`)
106
+ }
107
+
108
+ /**
109
+ * Sends a draft: creates the transfer the same way `transfers.send` does —
110
+ * address right, token, amount, recipient, AML, policies, limits,
111
+ * signatures, reserve. Only the author can, and only from a session that may
112
+ * send money (see the class): a web login, or a browser of anyone but a
113
+ * platform administrator, gets 403 `WEB_SESSION_CANNOT_SIGN`. There is no
114
+ * body; the parameters come from the draft alone.
115
+ *
116
+ * The answer is exactly that of `transfers.send`, and so are its errors:
117
+ * `applied` (201), `pending` (202 — waiting for signatures, funds
118
+ * reserved) or `replayed` (200). Read the TSDoc of `TransfersResource` on
119
+ * what each means; the timeout caveats of a money path apply here too.
120
+ *
121
+ * A DRAFT IS SENT ONCE. The transfer's idempotency key is derived from the
122
+ * draft, so a repeated send — a double tap, a second phone, a retry after a
123
+ * broken connection — returns the SAME transfer as `replayed`, as it stands
124
+ * now, and never a second one. That holds after `failed` too: a transfer
125
+ * from a draft is not sent again; a new attempt is an ordinary transfer.
126
+ * `replayed` does not mean the money left — read
127
+ * `data.transaction.status`.
128
+ *
129
+ * A refusal before the transfer exists (policy, balance, unsatisfiable
130
+ * approval, token) leaves the draft a `draft`, to send later or discard.
131
+ * Once the transfer exists — `failed` after the gas station and 502
132
+ * `TRANSFER_OUTCOME_UNKNOWN` included — the draft is `sent` with
133
+ * `transactionId`. A discarded draft with no transfer is 409
134
+ * `TRANSFER_DRAFT_DISCARDED`.
135
+ *
136
+ * The token is resolved before the replay: if the draft's token was
137
+ * disabled after it was sent, a repeated send answers 400
138
+ * `TOKEN_NOT_FOUND` instead of the transfer. No new transfer is created
139
+ * either way; read it by the draft's `transactionId`.
140
+ */
141
+ async send(
142
+ draftId: string,
143
+ options: { signal?: AbortSignal; timeoutMs?: number } = {},
144
+ ): Promise<Gated<CreateTransactionResult>> {
145
+ const res = await this.#http.requestRaw<CreateTransactionResult>(
146
+ 'POST',
147
+ `${this.#base}/${seg(draftId)}/send`,
148
+ {
149
+ ...(options.signal === undefined ? {} : { signal: options.signal }),
150
+ ...(options.timeoutMs === undefined ? {} : { timeoutMs: options.timeoutMs }),
151
+ },
152
+ )
153
+ return toGated<CreateTransactionResult, CreateTransactionResult>(res.status, res.data, {
154
+ replayOn200: true,
155
+ })
156
+ }
157
+ }
@@ -43,6 +43,14 @@ export interface VoteInput {
43
43
  * administrator reconciles it;
44
44
  * failed, rejected,
45
45
  * cancelled — it did not leave.
46
+ *
47
+ * `send`, `vote` and `reconcile` move money or give a signature, and they are
48
+ * refused with 403 `WEB_SESSION_CANNOT_SIGN` to a session that may not: money
49
+ * is sent and signatures are given from the mobile app; from a browser only
50
+ * by a platform administrator; from a web login by nobody (the table is on
51
+ * `TransferDraftsResource`). A web client prepares a transfer with
52
+ * `transferDrafts.create()` instead. `cancel` of your own transfer is open to
53
+ * any session.
46
54
  */
47
55
  export class TransfersResource {
48
56
  readonly #http: HttpClient
@@ -65,6 +73,9 @@ export class TransfersResource {
65
73
  * transfer stays `pending` with its funds reserved (`details.transactionId`).
66
74
  * Retry it only with the SAME key — that returns the transfer without
67
75
  * executing it again; a new key can send the money twice.
76
+ *
77
+ * A key beginning with `draft:` is refused with 400 `BAD_REQUEST`: the
78
+ * prefix is reserved for the transfers `transferDrafts.send()` creates.
68
79
  */
69
80
  async send(
70
81
  input: CreateTransferBody,
@@ -142,7 +153,10 @@ export class TransfersResource {
142
153
  * Cancels your own transfer that is awaiting signatures and releases the
143
154
  * reserve. A transfer already broadcast cannot be cancelled; administrators
144
155
  * may cancel somebody else's, so a stuck request is not hostage to an
145
- * absent initiator.
156
+ * absent initiator — but cancelling someone else's is a "no" like a veto,
157
+ * so only from a session that may sign: an administrator from the mobile
158
+ * app, a platform administrator also from a browser. Otherwise 403
159
+ * `NOT_INITIATOR`. Your own is cancelled from any session.
146
160
  *
147
161
  * The resulting status is its own value, `cancelled` — not the `rejected`
148
162
  * of a veto and not `failed`. Worth keeping apart in the interface: "you
@@ -157,7 +171,9 @@ export class TransfersResource {
157
171
  }
158
172
 
159
173
  /**
160
- * Settles a transfer nothing else can close. Administrators only.
174
+ * Settles a transfer nothing else can close. Platform administrators only,
175
+ * and not from a web-login session: 403 `WEB_SESSION_CANNOT_SIGN` (a browser
176
+ * or the mobile app is fine).
161
177
  *
162
178
  * pending — execution died, or its outcome is unknown (the
163
179
  * send answered 502 `TRANSFER_OUTCOME_UNKNOWN`);
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.2.4'
2
+ export const SDK_VERSION = '0.3.0'
3
3
 
4
4
  /** Default API base URL. */
5
5
  export const DEFAULT_BASE_URL = 'https://policy-engine-rest.ezig.workers.dev'