@andco/protocol 0.1.0-ti.1 → 0.1.0-ti.3

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.
@@ -5,7 +5,7 @@ import { InvalidCursor } from "./accounts.js";
5
5
  import { AndcoAPIError, errors } from "./api-error.js";
6
6
  import { connection, cursorlessConnection, ForwardPageQuery, InsufficientAuthorization, InvalidIdentifier, InvalidOrigin, InvalidRequest, InvalidToken, NotFound, PayloadTooLarge, ServerError, TemporarilyUnavailable, UnsupportedMediaType, UnsupportedVersion, } from "./common.js";
7
7
  import { http } from "./http.js";
8
- import { AmountOutOfGrant, ApprovalRequiredUseIntents, BankConnectionUnavailable, BankRefused, BankRejected, BankReviewRequired, ExpiredSignedInstruction, IdempotencyConflict, IdempotencyKeyNotAllowed, InsufficientFunds, IntentInteractionRequired, InvalidDestination, InvalidSignedInstruction, InvalidSource, NotImplemented, TransferSenderIdentityUnavailable, } from "./intents.js";
8
+ import { AmountOutOfGrant, BankConnectionUnavailable, BankRefused, BankRejected, BankReviewRequired, ExpiredSignedInstruction, IdempotencyConflict, IdempotencyKeyNotAllowed, InsufficientFunds, IntentInteractionRequired, InvalidDestination, InvalidSignedInstruction, InvalidSource, NotImplemented, TransferSenderIdentityUnavailable, } from "./intents.js";
9
9
  import { SIGNED_TRANSFER_MEDIA_TYPE } from "./signatures.js";
10
10
  export { SIGNED_TRANSFER_MEDIA_TYPE };
11
11
  const uuid = /* @__PURE__ */ v.pipe(v.string(), v.uuid());
@@ -66,8 +66,8 @@ export const Transfer = /* @__PURE__ */ v.pipe(v.strictObject({
66
66
  sender: v.pipe(TransferPartySchema, v.description("The Remitente: the account the money leaves and its holder.")),
67
67
  receiver: v.pipe(TransferPartySchema, v.description("The Receptor: the account the money lands on and its holder.")),
68
68
  comment: v.pipe(v.nullable(v.string()), v.description("The Nota de operación, at most 60 bytes of UTF-8, or null when there is none.")),
69
- intent_id: v.pipe(v.nullable(uuid), v.description("The Intent this Transfer came from. Null for origin `emisor` (no request came first) and for a signed transfer with `approved: true` (its signature approved it, so there was no request).")),
70
- jti: v.pipe(v.nullable(SignedTransferJtiSchema), v.description("The `jti` of the signed transfer with `approved: true` that submitted it, a UUID in lowercase. Null for any other Transfer: the `jti` of a signed Intent stays on the Intent. `GET /transfers?jti=` finds only a Transfer that has one.")),
69
+ intent_id: v.pipe(v.nullable(uuid), v.description("The Intent this Transfer came from. Null for origin `emisor` (no request came first) and for a signed transfer submitted through `POST /transfers` (approved when it was submitted, so there was no request).")),
70
+ jti: v.pipe(v.nullable(SignedTransferJtiSchema), v.description("The `jti` of the signed transfer that submitted it through `POST /transfers`, a UUID in lowercase. Null for any other Transfer: the `jti` of a signed Intent stays on the Intent, even after it is approved. `GET /transfers?jti=` finds only a Transfer that has one.")),
71
71
  transaction_id: v.pipe(v.nullable(v.string()), v.description("The ledger id of the debit once the Transfer succeeded, else null. A Movement carries the same id.")),
72
72
  created_at: v.pipe(dateTime, v.description("When the Transfer came to exist.")),
73
73
  }), v.description("A Transfer, with one shape for every origin. `sender` and `receiver` have the same fields, and `amount` and `currency` sit on the Transfer. It has no `approved` and no deadline: the decision belongs to the Intent."));
@@ -78,12 +78,12 @@ export const createTransfer = /* @__PURE__ */ oc
78
78
  method: "POST",
79
79
  path: "/transfers",
80
80
  summary: "Submit a signed transfer",
81
- description: "Submits one Transfer as a Signed Instruction: a `SignedTransferEnvelope`, a JWS in the General JSON Serialization sent as `application/jose+json`, whose payload is `SignedTransferClaims`. Every value the operation uses comes from the verified claims; the envelope is kept unchanged. Any other `Content-Type` answers `415 unsupported_media_type`, and an `Idempotency-Key` header `400 idempotency_key_not_allowed`: the `jti` is the idempotency-key.\n\nThe signature is the approval: the claims must have `approved: true`, and the Transfer exists as soon as it is submitted, with no decision to wait for. A signed transfer with `approved: false` answers `400 approval_required_use_intents` and nothing is stored: send it to `POST /intents`, which creates an Intent that waits for a decision.\n\nBefore anything is stored: the token's Grant must hold `bank_transfer` `create` (`403 insufficient_authorization`). The envelope must have its shape and at least one signature, each with a protected header of `typ` `transfer.v1+jwt` (`400 invalid_signed_instruction` with `reason` `malformed_assertion` and its `issues`, or `missing_signature`). Every signature must verify, each with a key registered under a Project of the holder, the Grant's subject: `unknown_key` (a `kid` that is no key of the holder's Projects, a key of another holder included), `revoked_key`, `expired_key`, `unusable_key`, `disallowed_algorithm` or `invalid_signature`. `unusable_key` means that the key is registered, but AndCo could not load it to check this signature: its person registers a new key and revokes this one, then you sign again. The claims must be `SignedTransferClaims` (`invalid_claims` with `issues`; the `jti` must be a UUID in lowercase) and `iss` the presenting client (`wrong_issuer`); an `exp` that passed answers `401 expired_signed_instruction`, and the `exp` of a new `jti` less than 15 minutes after the submission `400 invalid_signed_instruction` with `reason` `expiration_too_soon` (nothing is stored), so sign with an `exp` at least 15 minutes ahead (`bank-sdk` signs 30 minutes ahead). The floor applies only to a new `jti`: the same instruction sent again (same `jti`, same content) is never refused for it, however little of its `exp` is left, and answers or releases the same Transfer as before. That is how a stored Transfer is released after `409 interaction_required` or `503 temporarily_unavailable`. A client that lost the answer can also read the Transfer with `GET /transfers?jti=`, which finds it even after its `exp`. The `sender` must be an AndCo account of the holder that the Grant's `sources` cover (`422 invalid_source`, found by its `account_number`) and must match it (`422 sender_mismatch`; `422 transfer_sender_identity_unavailable` while AndCo knows no RUT for the holder). The Grant's `destinations` must cover the `receiver` (`422 invalid_destination`) and its limits the amount (`422 amount_out_of_grant`). The signed transfer needs `bank_transfer` `approve` within its maximum: `403 insufficient_authorization` otherwise, never a transfer that waits silently.\n\nThe same `jti` with the same claims answers the same Transfer and never moves money twice; the same `jti` with any other content, `exp` included, answers `409 idempotency_conflict`. To sign again with a new `exp`, use a new `jti`.\n\nA key that AndCo does not accept yet for signed transfers answers `unsynced_key`.\n\nA transfer between two accounts of the same holder works where AndCo serves that rail (otherwise `501 not_implemented` with `code: own_account_transfer_not_implemented`): it is released at once with nobody present and answers `processing` or `succeeded`, or the release's refusals of `POST /intents/{intent_id}/approve` (`409 interaction_required` with `bank_connection_*` when the web session that acts for the holder needs its person; sending the same instruction again once they acted releases it). A transfer that leaves its holder answers `501 not_implemented` with `code: signed_outgoing_transfer_not_implemented` while AndCo does not serve that rail, and nothing is created; otherwise it is sent at once with nobody present: no web AndPass and no SMS code, because the signature itself authorizes it. It is still screened. It answers `processing` once AndCo accepts it, and later `succeeded`; it answers `failed` with its `status_detail` when the screening refuses it (`fraud_rejected`), when the signature is refused (`unknown_key`, `revoked_key`, `invalid_signature`, `expired_signed_instruction`, `sender_mismatch`) or when the bank refuses the request (`bank_refused`). A signature that needs a proof only a person can give fails too: send the same transfer as an Intent that a person confirms. On either rail, a key that signed it and is revoked or expired when the Transfer executes fails it with `expired_key` or `revoked_key`, even if the key was valid at submission, and nothing is sent; so does a key AndCo no longer holds, with `unknown_key`, for one that leaves its holder. While no final answer is known it reads `processing`: read it later with `GET /transfers/{transfer_id}`, or send the same envelope again, which never moves money twice. `503 temporarily_unavailable` means it was stored and not sent, because the sender account already had two transfer evaluations in the last minute (the `message` says until when): send the same envelope again after that. `409 interaction_required` with `bank_connection_*` means the web session that acts for the holder needs its person, and nothing was created.",
81
+ description: "Submits one Transfer as a Signed Instruction: a `SignedTransferEnvelope`, a JWS in the General JSON Serialization sent as `application/jose+json`, whose payload is `SignedTransferClaims`. Every value the operation uses comes from the verified claims; the envelope is kept unchanged. Any other `Content-Type` answers `415 unsupported_media_type`, and an `Idempotency-Key` header `400 idempotency_key_not_allowed`: the `jti` is the idempotency-key.\n\nThis route is the approval: the claims carry no `approved` (an envelope that still carries it is refused with `invalid_claims`), and submitting here approves the transfer now, so the Transfer exists as soon as it is submitted, with no decision to wait for. To have a member of the holder decide first in AndCo (dual control), send the same kind of envelope to `POST /intents` instead.\n\nBefore anything is stored: the token's Grant must hold `bank_transfer` `create` (`403 insufficient_authorization`). The envelope must have its shape and at least one signature, each with a protected header of `typ` `transfer.v1+jwt` (`400 invalid_signed_instruction` with `reason` `malformed_assertion` and its `issues`, or `missing_signature`). Every signature must verify, each with a key of a person who may sign for the holder, the Grant's subject (a key belongs to a person, who registers it in her own settings): `unknown_key` (a `kid` that is no key of such a person, a key of another person included), `revoked_key`, `expired_key`, `unusable_key`, `disallowed_algorithm` or `invalid_signature`. `unusable_key` means that the key is registered, but AndCo could not load it to check this signature: its person registers a new key and revokes this one, then you sign again. The claims must be `SignedTransferClaims` (`invalid_claims` with `issues`; the `jti` must be a UUID in lowercase) and `iss` the presenting client (`wrong_issuer`); an `exp` that passed answers `401 expired_signed_instruction`, and the `exp` of a new `jti` less than 15 minutes after the submission `400 invalid_signed_instruction` with `reason` `expiration_too_soon` (nothing is stored), so sign with an `exp` at least 15 minutes ahead (`bank-sdk` signs 30 minutes ahead). The floor applies only to a new `jti`: the same instruction sent again (same `jti`, same content) is never refused for it, however little of its `exp` is left, and answers or releases the same Transfer as before. That is how a stored Transfer is released after `409 interaction_required` or `503 temporarily_unavailable`. A client that lost the answer can also read the Transfer with `GET /transfers?jti=`, which finds it even after its `exp`. The `sender` must be an AndCo account of the holder that the Grant's `sources` cover (`422 invalid_source`, found by its `account_number`) and must match it (`422 sender_mismatch`; `422 transfer_sender_identity_unavailable` while AndCo knows no RUT for the holder). The Grant's `destinations` must cover the `receiver` (`422 invalid_destination`) and its limits the amount (`422 amount_out_of_grant`). The signed transfer needs `bank_transfer` `approve` within its maximum: `403 insufficient_authorization` otherwise, never a transfer that waits silently.\n\nThe same `jti` with the same claims answers the same Transfer and never moves money twice; the same `jti` with any other content, `exp` included, answers `409 idempotency_conflict`. To sign again with a new `exp`, use a new `jti`.\n\n`unsynced_key`: a key that signed the transfer is not active for transfers yet. The person who registered it activates it in her settings, with one AndCo verification. Then send the same envelope again.\n\nA transfer between two accounts of the same holder works where AndCo serves that rail (otherwise `501 not_implemented` with `code: own_account_transfer_not_implemented`): it is released at once with nobody present and answers `processing` or `succeeded`, or the release's refusals of `POST /intents/{intent_id}/approve` (`409 interaction_required` with `bank_connection_*` when the web session that acts for the holder needs its person; sending the same instruction again once they acted releases it). A transfer that leaves its holder answers `501 not_implemented` with `code: signed_outgoing_transfer_not_implemented` while AndCo does not serve that rail, and nothing is created; otherwise it is sent at once with nobody present: no web AndPass and no SMS code, because the signature itself authorizes it. It is still screened. It answers `processing` once AndCo accepts it, and later `succeeded`; it answers `failed` with its `status_detail` when the screening refuses it (`fraud_rejected`), when the signature is refused (`unknown_key`, `revoked_key`, `invalid_signature`, `expired_signed_instruction`, `sender_mismatch`) or when the bank refuses the request (`bank_refused`). A signature that needs a proof only a person can give fails too: send the same transfer as an Intent that a person confirms. On either rail, a key that signed it and is revoked or expired when the Transfer executes fails it with `expired_key` or `revoked_key`, even if the key was valid at submission, and nothing is sent; so does a key AndCo no longer holds, with `unknown_key`, for one that leaves its holder. While no final answer is known it reads `processing`: read it later with `GET /transfers/{transfer_id}`, or send the same envelope again, which never moves money twice. `503 temporarily_unavailable` means it was stored and not sent, because the sender account already had two transfer evaluations in the last minute (the `message` says until when): send the same envelope again after that. `409 interaction_required` with `bank_connection_*` means the web session that acts for the holder needs its person, and nothing was created.",
82
82
  successStatus: 201,
83
83
  successDescription: "The Transfer submitted, or the same one from a repeated instruction",
84
84
  spec: servedAsSignedTransfer,
85
85
  }))
86
- .errors(errors(InvalidRequest, IdempotencyKeyNotAllowed, ApprovalRequiredUseIntents, InvalidSignedInstruction, InvalidToken, ExpiredSignedInstruction, InvalidOrigin, InsufficientAuthorization, UnsupportedVersion, ServerError, IdempotencyConflict, IntentInteractionRequired, PayloadTooLarge, UnsupportedMediaType, SenderMismatch, TransferSenderIdentityUnavailable, AmountOutOfGrant, InvalidSource, InvalidDestination, BankConnectionUnavailable, BankRefused, InsufficientFunds, BankRejected, BankReviewRequired, NotImplemented, TemporarilyUnavailable))
86
+ .errors(errors(InvalidRequest, IdempotencyKeyNotAllowed, InvalidSignedInstruction, InvalidToken, ExpiredSignedInstruction, InvalidOrigin, InsufficientAuthorization, UnsupportedVersion, ServerError, IdempotencyConflict, IntentInteractionRequired, PayloadTooLarge, UnsupportedMediaType, SenderMismatch, TransferSenderIdentityUnavailable, AmountOutOfGrant, InvalidSource, InvalidDestination, BankConnectionUnavailable, BankRefused, InsufficientFunds, BankRejected, BankReviewRequired, NotImplemented, TemporarilyUnavailable))
87
87
  .input(SignedTransferEnvelopeSchema)
88
88
  .output(Transfer);
89
89
  /** Reads one Transfer the Grant may read. */
@@ -112,7 +112,7 @@ export const listTransfers = /* @__PURE__ */ oc
112
112
  method: "GET",
113
113
  path: "/transfers",
114
114
  summary: "Find a Transfer by the jti of its signed instruction",
115
- description: "It finds one Transfer by the `jti` of the signed transfer with `approved: true` that submitted it, and `jti` is required (`400 invalid_request` when it is missing or is not a UUID in lowercase). The answer is a collection of zero or one Transfer, with the reach of `GET /transfers/{transfer_id}`. A `jti` belongs to the client and the Grant's subject, across the client's Grants: a `jti` that another client or another subject used finds nothing, and so does the `jti` of a signed Intent, which stays on the Intent. The collection is empty in those cases, so no answer tells them apart. It finds a Transfer whose `exp` has passed, which is its purpose: after a lost answer to `POST /transfers`, read by `jti` before signing again. To list the Transfers of an account, use `GET /accounts/{bank_account_id}/transfers`.",
115
+ description: "It finds one Transfer by the `jti` of the signed transfer that submitted it through `POST /transfers`, and `jti` is required (`400 invalid_request` when it is missing or is not a UUID in lowercase). The answer is a collection of zero or one Transfer, with the reach of `GET /transfers/{transfer_id}`. A `jti` belongs to the client and the Grant's subject, across the client's Grants: a `jti` that another client or another subject used finds nothing, and so does the `jti` of a signed Intent, which stays on the Intent even after it is approved. The collection is empty in those cases, so no answer tells them apart. It finds a Transfer whose `exp` has passed, which is its purpose: after a lost answer to `POST /transfers`, read by `jti` before signing again. To list the Transfers of an account, use `GET /accounts/{bank_account_id}/transfers`.",
116
116
  successDescription: "The Transfers found: zero or one",
117
117
  }))
118
118
  .errors(errors(InvalidRequest, InvalidToken, InvalidOrigin, UnsupportedVersion, ServerError, TemporarilyUnavailable))
@@ -182,19 +182,21 @@ export type TransferParty = v.InferOutput<typeof TransferPartySchema>;
182
182
  export declare const SignedTransferJtiSchema: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.UuidAction<string, undefined>, v.RegexAction<string, "jti must be a lowercase UUID">, v.DescriptionAction<string, "A UUID in lowercase. It names the Transfer: it is its idempotency-key. The same `jti` with other content is a conflict.">]>;
183
183
  /**
184
184
  * The claims of a signed transfer, version 2: `sender`, `receiver` and `comment`, signed, plus the
185
- * envelope (`iss`, `aud`, `jti`, `exp`) and `approved`. `metadata` is the signer's own data, kept as
186
- * it arrives and read by nothing that decides; there is no `expires_at`, `iat` or `nbf`, because the
187
- * deadline is `exp`. The API verifies the signature and executes the payload as signed, so nothing
188
- * here names an Account Key or an AndCo account id, and an unknown claim is refused.
185
+ * envelope (`iss`, `aud`, `jti`, `exp`). `metadata` is the signer's own data, kept as it arrives and
186
+ * read by nothing that decides; there is no `expires_at`, `iat` or `nbf`, because the deadline is
187
+ * `exp`. The API verifies the signature and executes the payload as signed, so nothing here names an
188
+ * Account Key or an AndCo account id, and an unknown claim is refused.
189
189
  *
190
190
  * - `jti` is a lowercase UUID: it names the Transfer and is its idempotency-key.
191
191
  * - `exp` bounds execution, and is part of what the `jti` names.
192
- * - `approved: true` orders the transfer sent as soon as it is submitted; it needs `bank_transfer`
193
- * `approve` in the Project's Grant.
192
+ * - There is no `approved`: the approval travels outside the signature, and the route decides it.
193
+ * `POST /transfers` sends the transfer now (the Grant needs `bank_transfer` `approve`); `POST /intents`
194
+ * makes it an Intent that waits for a member's approval in AndCo until `min(exp, 24 h)`, and on
195
+ * approval AndCo sends this same signed instruction. Claims that carry `approved` are refused.
194
196
  *
195
197
  * @example
196
198
  * const claims: SignedTransferClaims = {
197
- * iss: clientId, aud: "https://api.andco.com", jti: crypto.randomUUID(), exp: 1795000000, approved: true,
199
+ * iss: clientId, aud: "https://api.andco.com", jti: crypto.randomUUID(), exp: 1795000000,
198
200
  * sender, receiver, comment: "Factura 42",
199
201
  * };
200
202
  */
@@ -203,7 +205,6 @@ export declare const SignedTransferClaimsSchema: v.SchemaWithPipe<readonly [v.St
203
205
  readonly aud: v.LiteralSchema<"https://api.andco.com", undefined>;
204
206
  readonly jti: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.UuidAction<string, undefined>, v.RegexAction<string, "jti must be a lowercase UUID">, v.DescriptionAction<string, "A UUID in lowercase. It names the Transfer: it is its idempotency-key. The same `jti` with other content is a conflict.">]>;
205
207
  readonly exp: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.DescriptionAction<number, "Unix seconds after which the transfer is refused.">]>;
206
- readonly approved: v.SchemaWithPipe<readonly [v.BooleanSchema<undefined>, v.DescriptionAction<boolean, "`true` orders the transfer sent as soon as it is submitted, which needs `bank_transfer` `approve` in the Grant.">]>;
207
208
  readonly sender: v.SchemaWithPipe<readonly [v.VariantSchema<"country", [v.StrictObjectSchema<{
208
209
  country: v.LiteralSchema<"CL", undefined>;
209
210
  bank_code: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>, v.DescriptionAction<string, "The bank's four-digit code, as `GET /catalogs/banks` lists it. AndCo is `0739`.">]>;
@@ -253,7 +254,6 @@ export declare const SignedTransferClaimsSchema: v.SchemaWithPipe<readonly [v.St
253
254
  aud: "https://api.andco.com";
254
255
  jti: string;
255
256
  exp: number;
256
- approved: boolean;
257
257
  sender: {
258
258
  country: "CL";
259
259
  bank_code: string;
@@ -279,7 +279,7 @@ export declare const SignedTransferClaimsSchema: v.SchemaWithPipe<readonly [v.St
279
279
  metadata?: {
280
280
  [x: string]: unknown;
281
281
  } | undefined;
282
- }, "The claims of a signed transfer (`typ` `transfer.v1+jwt`): `sender`, `receiver` and `comment` (with an optional `metadata`) plus `iss`, `aud`, `jti`, `exp` and `approved`. Strict: an unknown claim, country or document is refused, nothing names an Account Key or an AndCo account id, and the only deadline is `exp`.">]>;
282
+ }, "The claims of a signed transfer (`typ` `transfer.v1+jwt`): `sender`, `receiver` and `comment` (with an optional `metadata`) plus `iss`, `aud`, `jti` and `exp`. There is no `approved`: the route decides it (`POST /transfers` sends the transfer now, `POST /intents` makes it an Intent that waits for a decision). Strict: an unknown claim (`approved` included), country or document is refused, nothing names an Account Key or an AndCo account id, and the only deadline is `exp`.">]>;
283
283
  /** The claims of a signed transfer, version 2. */
284
284
  export type SignedTransferClaims = v.InferOutput<typeof SignedTransferClaimsSchema>;
285
285
  /** The most bytes of a transfer's comment, counted in UTF-8. */
@@ -1 +1 @@
1
- {"version":3,"file":"transfer.d.ts","sourceRoot":"","sources":["../src/transfer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAE7B,OAAO,EAAE,KAAK,KAAK,EAAsB,KAAK,WAAW,EAAkB,MAAM,aAAa,CAAC;AAE/F;;;GAGG;AAEH;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,0MAI1B,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmCrB,CAAC;AAEX,mCAAmC;AACnC,eAAO,MAAM,mBAAmB,aAAgB,CAAC;AAEjD;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,sVAQvB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,yBAAyB,qNAGrC,CAAC;AAEF,2CAA2C;AAC3C,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAkClF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;gPAKhC,CAAC;AAEF,mCAAmC;AACnC,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAExE;;;;;;;;;;GAUG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;qLAYlC,CAAC;AAEF,kCAAkC;AAClC,MAAM,MAAM,gBAAg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;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;8NAoBxC,CAAC;AAEF,gFAAgF;AAChF,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,4BAA4B,CAAC,CAAC;AAaxF;;;;;;;;;;;;;GAaG;AACH,wBAAgB,4BAA4B,CAAC,QAAQ,EAAE,sBAAsB,GAAG,KAAK,EAAE,CAetF;AAED;;;;;;;;GAQG;AACH,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,OAAO,GAAG,WAAW,CAAC,sBAAsB,CAAC,CAE/F"}
package/dist/transfer.js CHANGED
@@ -152,19 +152,21 @@ export const TransferPartySchema = /* @__PURE__ */ v.pipe(v.strictObject({
152
152
  export const SignedTransferJtiSchema = /* @__PURE__ */ v.pipe(v.string(), v.uuid(), v.regex(/^[0-9a-f-]{36}$/, "jti must be a lowercase UUID"), v.description("A UUID in lowercase. It names the Transfer: it is its idempotency-key. The same `jti` with other content is a conflict."));
153
153
  /**
154
154
  * The claims of a signed transfer, version 2: `sender`, `receiver` and `comment`, signed, plus the
155
- * envelope (`iss`, `aud`, `jti`, `exp`) and `approved`. `metadata` is the signer's own data, kept as
156
- * it arrives and read by nothing that decides; there is no `expires_at`, `iat` or `nbf`, because the
157
- * deadline is `exp`. The API verifies the signature and executes the payload as signed, so nothing
158
- * here names an Account Key or an AndCo account id, and an unknown claim is refused.
155
+ * envelope (`iss`, `aud`, `jti`, `exp`). `metadata` is the signer's own data, kept as it arrives and
156
+ * read by nothing that decides; there is no `expires_at`, `iat` or `nbf`, because the deadline is
157
+ * `exp`. The API verifies the signature and executes the payload as signed, so nothing here names an
158
+ * Account Key or an AndCo account id, and an unknown claim is refused.
159
159
  *
160
160
  * - `jti` is a lowercase UUID: it names the Transfer and is its idempotency-key.
161
161
  * - `exp` bounds execution, and is part of what the `jti` names.
162
- * - `approved: true` orders the transfer sent as soon as it is submitted; it needs `bank_transfer`
163
- * `approve` in the Project's Grant.
162
+ * - There is no `approved`: the approval travels outside the signature, and the route decides it.
163
+ * `POST /transfers` sends the transfer now (the Grant needs `bank_transfer` `approve`); `POST /intents`
164
+ * makes it an Intent that waits for a member's approval in AndCo until `min(exp, 24 h)`, and on
165
+ * approval AndCo sends this same signed instruction. Claims that carry `approved` are refused.
164
166
  *
165
167
  * @example
166
168
  * const claims: SignedTransferClaims = {
167
- * iss: clientId, aud: "https://api.andco.com", jti: crypto.randomUUID(), exp: 1795000000, approved: true,
169
+ * iss: clientId, aud: "https://api.andco.com", jti: crypto.randomUUID(), exp: 1795000000,
168
170
  * sender, receiver, comment: "Factura 42",
169
171
  * };
170
172
  */
@@ -173,12 +175,11 @@ export const SignedTransferClaimsSchema = /* @__PURE__ */ v.pipe(v.strictObject(
173
175
  aud: v.literal(ANDCO_API_ORIGIN),
174
176
  jti: SignedTransferJtiSchema,
175
177
  exp: v.pipe(v.number(), v.integer(), v.description("Unix seconds after which the transfer is refused.")),
176
- approved: v.pipe(v.boolean(), v.description("`true` orders the transfer sent as soon as it is submitted, which needs `bank_transfer` `approve` in the Grant.")),
177
178
  sender: TransferSenderSchema,
178
179
  receiver: TransferReceiverSchema,
179
180
  comment: v.pipe(v.optional(v.string()), v.description("What both sides read next to the movement.")),
180
181
  metadata: v.pipe(v.optional(v.record(v.string(), v.unknown())), v.description("The signer's own data, signed and kept as it arrives. Nothing reads it to decide anything.")),
181
- }), v.description("The claims of a signed transfer (`typ` `transfer.v1+jwt`): `sender`, `receiver` and `comment` (with an optional `metadata`) plus `iss`, `aud`, `jti`, `exp` and `approved`. Strict: an unknown claim, country or document is refused, nothing names an Account Key or an AndCo account id, and the only deadline is `exp`."));
182
+ }), v.description("The claims of a signed transfer (`typ` `transfer.v1+jwt`): `sender`, `receiver` and `comment` (with an optional `metadata`) plus `iss`, `aud`, `jti` and `exp`. There is no `approved`: the route decides it (`POST /transfers` sends the transfer now, `POST /intents` makes it an Intent that waits for a decision). Strict: an unknown claim (`approved` included), country or document is refused, nothing names an Account Key or an AndCo account id, and the only deadline is `exp`."));
182
183
  /** The most bytes of a transfer's comment, counted in UTF-8. */
183
184
  export const TRANSFER_COMMENT_MAX_BYTES = 60;
184
185
  /**
@@ -174,7 +174,9 @@ export interface paths {
174
174
  put?: never;
175
175
  /**
176
176
  * Create an intent under the exact OAuth Grant
177
- * @description The same creation has three representations, and the content type picks between them. An `application/json` body is an Intent born waiting for an Approval. An `application/jwt` body is one Signed Instruction, sent as a compact JWS whose verified payload is `SignedAccountOpeningIntentClaims` or `SignedAccountClosureIntentClaims`, and every value the operation uses comes from those claims and none from the envelope carrying them. An `application/jose+json` body is a signed transfer with `approved: false`: a `SignedTransferEnvelope`, a JWS in the General JSON Serialization, whose payload is `SignedTransferClaims`. It creates a transfer Intent that waits for a decision and answers a TransferIntent with `transfer_id` null. It is verified as `POST /transfers` verifies a signed transfer, with the same rules for the `jti` (a UUID in lowercase, and the only idempotency-key), `exp`, the keys, the `sender` and the `receiver`; the `unusable_key` reason means that the key is registered, but AndCo could not load it to check this signature, so its person registers a new key and revokes this one, then you sign again. A repeat of the same envelope answers the same Intent, and another body under the same `jti` answers `409 idempotency_conflict`. A signed transfer with `approved: true` answers `400 approved_use_transfers` and nothing is recorded: its signature is the approval, so send it to `POST /transfers`. A signed account opening or closure with `approved: true` stays accepted here and is born approved. A string body sent as anything but `application/jwt` answers `415 unsupported_media_type`. A Signed Instruction that does not verify answers `400 invalid_signed_instruction` with its `reason`, and one whose `exp` passed `401 expired_signed_instruction`. A signed account Intent is born approved when the signing client's Grant holds the family's `approve` action (`bank_account`); otherwise it waits, like a proposal, for the person on the hosted screen or for `POST /intents/{intent_id}/approve` by a Grant that holds it. Opening and closing an account fail synchronously with `403 account_key_out_of_grant` when the account_key is outside the Grant's `accounts` patterns and with `409 account_key_taken` when the account_key names an account of the subject (always for a closed one; otherwise unless `upsert`). The new account's number arrives in the `account_opening.succeeded` event as `account: { id, accountKey, number, name }`. Once the request is valid and authorized (a malformed body is still `400 invalid_request` and a Grant without the permission still `403 insufficient_authorization`), an opening and a transfer between two accounts of the same holder work where the bank serves them: the answer is `201` with the Intent `requires_action` and its `authorization_url`, or, for a signed account Intent whose signer also holds the family's `approve`, the Intent born `approved`. Where the deployment's bank does not serve one, the same request answers `501 not_implemented` with `code: account_opening_not_implemented` or `code: own_account_transfer_not_implemented`; a closure always answers `501 not_implemented` with `code: account_closure_not_implemented`. Nothing is created in those cases. A subject without a bank connection to a company cannot open an account: `422 bank_connection_unavailable` with the `intent_id`. A signed account Intent born approved answers the refusals of `POST /intents/{intent_id}/approve`.
177
+ * @description The same creation has three representations, and the content type picks between them. An `application/json` body is an Intent born waiting for an Approval. An `application/jwt` body is one Signed Instruction, sent as a compact JWS whose verified payload is `SignedAccountOpeningIntentClaims` or `SignedAccountClosureIntentClaims`, and every value the operation uses comes from those claims and none from the envelope carrying them. An `application/jose+json` body is a signed transfer: a `SignedTransferEnvelope`, a JWS in the General JSON Serialization, whose payload is `SignedTransferClaims` (no `approved`: this route is the request, `POST /transfers` the submission). It creates a transfer Intent that waits for a member of the holder to approve it in AndCo (dual control) and answers a TransferIntent with `transfer_id` null. The Intent waits until it is decided or until its deadline, `min(exp, 24 hours after its creation)`, passes; on approval AndCo sends that same signed instruction to the bank, so the Transfer is the one the signature describes. It is verified as `POST /transfers` verifies a signed transfer, with the same rules for the `jti` (a UUID in lowercase, and the only idempotency-key), `exp`, the keys, the `sender` and the `receiver`; the `unusable_key` reason means that the key is registered, but AndCo could not load it to check this signature, so its person registers a new key and revokes this one, then you sign again. A repeat of the same envelope answers the same Intent, and another body under the same `jti` answers `409 idempotency_conflict`. A signed account opening or closure with `approved: true` stays accepted here and is born approved. A string body sent as anything but `application/jwt` answers `415 unsupported_media_type`. A Signed Instruction that does not verify answers `400 invalid_signed_instruction` with its `reason`, and one whose `exp` passed `401 expired_signed_instruction`. A signed account Intent is born approved when the signing client's Grant holds the family's `approve` action (`bank_account`); otherwise it waits, like a proposal, for the person on the hosted screen or for `POST /intents/{intent_id}/approve` by a Grant that holds it. Opening and closing an account fail synchronously with `403 account_key_out_of_grant` when the account_key is outside the Grant's `accounts` patterns and with `409 account_key_taken` when the account_key names an account of the subject (always for a closed one; otherwise unless `upsert`). The new account's number arrives in the `account_opening.succeeded` event as `account: { id, accountKey, number, name }`. Once the request is valid and authorized (a malformed body is still `400 invalid_request` and a Grant without the permission still `403 insufficient_authorization`), an opening and a `bank_transfer` proposal between two accounts of the same holder work where the bank serves them: the answer is `201` with the Intent `requires_action` and its `authorization_url`, or, for a signed account Intent whose signer also holds the family's `approve`, the Intent born `approved`. A transfer that `bank_own_account_transfer` covers is released at once instead (below). Where the deployment's bank does not serve one, the same request answers `501 not_implemented` with `code: account_opening_not_implemented` or `code: own_account_transfer_not_implemented`; a closure always answers `501 not_implemented` with `code: account_closure_not_implemented`. Nothing is created in those cases. A subject without a bank connection to a company cannot open an account: `422 bank_connection_unavailable` with the `intent_id`. A signed account Intent born approved answers the refusals of `POST /intents/{intent_id}/approve`.
178
+ *
179
+ * A `transfer` proposal needs `bank_transfer` `create` or `bank_own_account_transfer` `create`. When the Grant holds `bank_own_account_transfer` `create` whose `accounts` cover the named `sender` and `receiver` (two different active accounts of the Grant's subject) and the amount is not `editable`, the answer is a TransferIntent born `approved` with `transfer_id` set: nobody decides it, and it is released at once with nobody present. Its outcome lives on the Transfer, which reads `processing` and then `succeeded` or `failed`, never on the Intent. The same `Idempotency-Key` never names both kinds of transfer (`409 idempotency_conflict`). Any other transfer is a `bank_transfer` proposal, bounded by that detail alone. A Grant that holds no `bank_transfer` `create` refuses what `bank_own_account_transfer` does not cover with nothing created: `422 destination_not_own_account` when the `receiver` is missing or is not an account of the subject, `422 invalid_source` when the `sender` is missing, unusable or outside `accounts`, `422 invalid_destination` when the `receiver` cannot receive (closed, another currency, the `sender` itself) or is outside `accounts`, and `400 invalid_request` with the detail `transfer_amount_not_editable` for an editable amount. Where the deployment's bank does not serve transfers between own accounts, `501 not_implemented` with `code: own_account_transfer_not_implemented`. If the release cannot go on because only a person can, the answer is `409 interaction_required` before anything is stored. If it fails after the Transfer was stored, the same request sent again releases that Transfer again and answers the same Intent. An approved Intent has no client cancel.
178
180
  */
179
181
  post: operations["createIntent"];
180
182
  delete?: never;
@@ -192,7 +194,7 @@ export interface paths {
192
194
  };
193
195
  /**
194
196
  * Find a Transfer by the jti of its signed instruction
195
- * @description It finds one Transfer by the `jti` of the signed transfer with `approved: true` that submitted it, and `jti` is required (`400 invalid_request` when it is missing or is not a UUID in lowercase). The answer is a collection of zero or one Transfer, with the reach of `GET /transfers/{transfer_id}`. A `jti` belongs to the client and the Grant's subject, across the client's Grants: a `jti` that another client or another subject used finds nothing, and so does the `jti` of a signed Intent, which stays on the Intent. The collection is empty in those cases, so no answer tells them apart. It finds a Transfer whose `exp` has passed, which is its purpose: after a lost answer to `POST /transfers`, read by `jti` before signing again. To list the Transfers of an account, use `GET /accounts/{bank_account_id}/transfers`.
197
+ * @description It finds one Transfer by the `jti` of the signed transfer that submitted it through `POST /transfers`, and `jti` is required (`400 invalid_request` when it is missing or is not a UUID in lowercase). The answer is a collection of zero or one Transfer, with the reach of `GET /transfers/{transfer_id}`. A `jti` belongs to the client and the Grant's subject, across the client's Grants: a `jti` that another client or another subject used finds nothing, and so does the `jti` of a signed Intent, which stays on the Intent even after it is approved. The collection is empty in those cases, so no answer tells them apart. It finds a Transfer whose `exp` has passed, which is its purpose: after a lost answer to `POST /transfers`, read by `jti` before signing again. To list the Transfers of an account, use `GET /accounts/{bank_account_id}/transfers`.
196
198
  */
197
199
  get: operations["listTransfers"];
198
200
  put?: never;
@@ -200,13 +202,13 @@ export interface paths {
200
202
  * Submit a signed transfer
201
203
  * @description Submits one Transfer as a Signed Instruction: a `SignedTransferEnvelope`, a JWS in the General JSON Serialization sent as `application/jose+json`, whose payload is `SignedTransferClaims`. Every value the operation uses comes from the verified claims; the envelope is kept unchanged. Any other `Content-Type` answers `415 unsupported_media_type`, and an `Idempotency-Key` header `400 idempotency_key_not_allowed`: the `jti` is the idempotency-key.
202
204
  *
203
- * The signature is the approval: the claims must have `approved: true`, and the Transfer exists as soon as it is submitted, with no decision to wait for. A signed transfer with `approved: false` answers `400 approval_required_use_intents` and nothing is stored: send it to `POST /intents`, which creates an Intent that waits for a decision.
205
+ * This route is the approval: the claims carry no `approved` (an envelope that still carries it is refused with `invalid_claims`), and submitting here approves the transfer now, so the Transfer exists as soon as it is submitted, with no decision to wait for. To have a member of the holder decide first in AndCo (dual control), send the same kind of envelope to `POST /intents` instead.
204
206
  *
205
- * Before anything is stored: the token's Grant must hold `bank_transfer` `create` (`403 insufficient_authorization`). The envelope must have its shape and at least one signature, each with a protected header of `typ` `transfer.v1+jwt` (`400 invalid_signed_instruction` with `reason` `malformed_assertion` and its `issues`, or `missing_signature`). Every signature must verify, each with a key registered under a Project of the holder, the Grant's subject: `unknown_key` (a `kid` that is no key of the holder's Projects, a key of another holder included), `revoked_key`, `expired_key`, `unusable_key`, `disallowed_algorithm` or `invalid_signature`. `unusable_key` means that the key is registered, but AndCo could not load it to check this signature: its person registers a new key and revokes this one, then you sign again. The claims must be `SignedTransferClaims` (`invalid_claims` with `issues`; the `jti` must be a UUID in lowercase) and `iss` the presenting client (`wrong_issuer`); an `exp` that passed answers `401 expired_signed_instruction`, and the `exp` of a new `jti` less than 15 minutes after the submission `400 invalid_signed_instruction` with `reason` `expiration_too_soon` (nothing is stored), so sign with an `exp` at least 15 minutes ahead (`bank-sdk` signs 30 minutes ahead). The floor applies only to a new `jti`: the same instruction sent again (same `jti`, same content) is never refused for it, however little of its `exp` is left, and answers or releases the same Transfer as before. That is how a stored Transfer is released after `409 interaction_required` or `503 temporarily_unavailable`. A client that lost the answer can also read the Transfer with `GET /transfers?jti=`, which finds it even after its `exp`. The `sender` must be an AndCo account of the holder that the Grant's `sources` cover (`422 invalid_source`, found by its `account_number`) and must match it (`422 sender_mismatch`; `422 transfer_sender_identity_unavailable` while AndCo knows no RUT for the holder). The Grant's `destinations` must cover the `receiver` (`422 invalid_destination`) and its limits the amount (`422 amount_out_of_grant`). The signed transfer needs `bank_transfer` `approve` within its maximum: `403 insufficient_authorization` otherwise, never a transfer that waits silently.
207
+ * Before anything is stored: the token's Grant must hold `bank_transfer` `create` (`403 insufficient_authorization`). The envelope must have its shape and at least one signature, each with a protected header of `typ` `transfer.v1+jwt` (`400 invalid_signed_instruction` with `reason` `malformed_assertion` and its `issues`, or `missing_signature`). Every signature must verify, each with a key of a person who may sign for the holder, the Grant's subject (a key belongs to a person, who registers it in her own settings): `unknown_key` (a `kid` that is no key of such a person, a key of another person included), `revoked_key`, `expired_key`, `unusable_key`, `disallowed_algorithm` or `invalid_signature`. `unusable_key` means that the key is registered, but AndCo could not load it to check this signature: its person registers a new key and revokes this one, then you sign again. The claims must be `SignedTransferClaims` (`invalid_claims` with `issues`; the `jti` must be a UUID in lowercase) and `iss` the presenting client (`wrong_issuer`); an `exp` that passed answers `401 expired_signed_instruction`, and the `exp` of a new `jti` less than 15 minutes after the submission `400 invalid_signed_instruction` with `reason` `expiration_too_soon` (nothing is stored), so sign with an `exp` at least 15 minutes ahead (`bank-sdk` signs 30 minutes ahead). The floor applies only to a new `jti`: the same instruction sent again (same `jti`, same content) is never refused for it, however little of its `exp` is left, and answers or releases the same Transfer as before. That is how a stored Transfer is released after `409 interaction_required` or `503 temporarily_unavailable`. A client that lost the answer can also read the Transfer with `GET /transfers?jti=`, which finds it even after its `exp`. The `sender` must be an AndCo account of the holder that the Grant's `sources` cover (`422 invalid_source`, found by its `account_number`) and must match it (`422 sender_mismatch`; `422 transfer_sender_identity_unavailable` while AndCo knows no RUT for the holder). The Grant's `destinations` must cover the `receiver` (`422 invalid_destination`) and its limits the amount (`422 amount_out_of_grant`). The signed transfer needs `bank_transfer` `approve` within its maximum: `403 insufficient_authorization` otherwise, never a transfer that waits silently.
206
208
  *
207
209
  * The same `jti` with the same claims answers the same Transfer and never moves money twice; the same `jti` with any other content, `exp` included, answers `409 idempotency_conflict`. To sign again with a new `exp`, use a new `jti`.
208
210
  *
209
- * A key that AndCo does not accept yet for signed transfers answers `unsynced_key`.
211
+ * `unsynced_key`: a key that signed the transfer is not active for transfers yet. The person who registered it activates it in her settings, with one AndCo verification. Then send the same envelope again.
210
212
  *
211
213
  * A transfer between two accounts of the same holder works where AndCo serves that rail (otherwise `501 not_implemented` with `code: own_account_transfer_not_implemented`): it is released at once with nobody present and answers `processing` or `succeeded`, or the release's refusals of `POST /intents/{intent_id}/approve` (`409 interaction_required` with `bank_connection_*` when the web session that acts for the holder needs its person; sending the same instruction again once they acted releases it). A transfer that leaves its holder answers `501 not_implemented` with `code: signed_outgoing_transfer_not_implemented` while AndCo does not serve that rail, and nothing is created; otherwise it is sent at once with nobody present: no web AndPass and no SMS code, because the signature itself authorizes it. It is still screened. It answers `processing` once AndCo accepts it, and later `succeeded`; it answers `failed` with its `status_detail` when the screening refuses it (`fraud_rejected`), when the signature is refused (`unknown_key`, `revoked_key`, `invalid_signature`, `expired_signed_instruction`, `sender_mismatch`) or when the bank refuses the request (`bank_refused`). A signature that needs a proof only a person can give fails too: send the same transfer as an Intent that a person confirms. On either rail, a key that signed it and is revoked or expired when the Transfer executes fails it with `expired_key` or `revoked_key`, even if the key was valid at submission, and nothing is sent; so does a key AndCo no longer holds, with `unknown_key`, for one that leaves its holder. While no final answer is known it reads `processing`: read it later with `GET /transfers/{transfer_id}`, or send the same envelope again, which never moves money twice. `503 temporarily_unavailable` means it was stored and not sent, because the sender account already had two transfer evaluations in the last minute (the `message` says until when): send the same envelope again after that. `409 interaction_required` with `bank_connection_*` means the web session that acts for the holder needs its person, and nothing was created.
212
214
  */
@@ -561,8 +563,8 @@ export interface paths {
561
563
  get?: never;
562
564
  put?: never;
563
565
  /**
564
- * Verify a Signed Instruction against the OAuth Client's registered keys, without acting on it
565
- * @description Verifies the assertion's signature, `kid`, algorithm, issuer, audience and expiration against the Signing Keys the presenting OAuth Client has registered, and returns its verified claims untouched. Acts on nothing: this is the smallest surface that exercises signing end to end, so an integrator can confirm that the key it registered, the `kid` its SDK derived and the claims it signs all line up before any of them is submitted to create, execute or approve an Intent. Requires only a valid OAuth bearer token, no scope or authorization detail.
566
+ * Verify a Signed Instruction against the keys of a person who may sign for the Grant's holder, without acting on it
567
+ * @description Verifies the assertion's signature, `kid`, algorithm, issuer, audience and expiration against the Signing Keys of a person who may sign for the Grant's holder (a key belongs to a person, who registers it in her own settings), and returns its verified claims untouched. Acts on nothing: this is the smallest surface that exercises signing end to end, so an integrator can confirm that the key registered for it, the `kid` its SDK derived and the claims it signs all line up before any of them is submitted to create, execute or approve an Intent. Requires only a valid OAuth bearer token, no scope or authorization detail.
566
568
  */
567
569
  post: operations["verifySignature"];
568
570
  delete?: never;
@@ -825,7 +827,7 @@ export interface components {
825
827
  payment_type: string | null;
826
828
  reversed: boolean;
827
829
  note: string | null;
828
- /** @description The id of the Transfer that this debit belongs to, only when the Grant may read that Transfer: one this client created for the same subject, or any Transfer of an account that a `bank_transfer` `read` detail covers. Always present. A null never means that no Transfer exists: it means no Transfer that this Grant may read, and it is also null for a credit, for a Movement without a `transaction_id` and for one that AndCo has posted before AndCo recorded the Transfer, which fills on a later read. */
830
+ /** @description The id of the Transfer that this debit belongs to, only when the Grant may read that Transfer: one this client created for the same subject, or any Transfer of an account that a `bank_transfer` `read` detail covers. Always present. A null never means that no Transfer exists: it means no Transfer that this Grant may read, and it is also null for a Movement without a `transaction_id` and for one that AndCo has posted before AndCo recorded the Transfer, which fills on a later read. It is null for a credit too, except the credit leg of an own-account Transfer, which links by the same read rule as the debit. */
829
831
  transfer_id: string | null;
830
832
  };
831
833
  /** @description A connection read live from AndCo, which issues one cursor per page and walks forward only. `pageInfo.endCursor` is that cursor and is null on the last page; `pageInfo.startCursor` is always null and `pageInfo.hasPreviousPage` always false. An edge's `cursor` is null: AndCo names no position inside a page, so a walk resumes from the end of a page, never from one Movement. */
@@ -1344,7 +1346,7 @@ export interface components {
1344
1346
  currency: "CLP";
1345
1347
  value: string;
1346
1348
  };
1347
- /** @description The verified `kid`, algorithm and claims of a Signed Instruction that verified against the presenting OAuth Client's registered keys. `claims` is the decoded JWT payload as signed -- this operation checks only `exp` and `jti` structurally and otherwise passes every claim through untouched, so it never narrows to one Intent family's claim schema. */
1349
+ /** @description The verified `kid`, algorithm and claims of a Signed Instruction that verified against the keys of a person who may sign for the Grant's holder. `claims` is the decoded JWT payload as signed -- this operation checks only `exp` and `jti` structurally and otherwise passes every claim through untouched, so it never narrows to one Intent family's claim schema. */
1348
1350
  SignedInstructionVerification: {
1349
1351
  /** @description RFC 7638 JWK Thumbprint of the Signing Key that verified the assertion. */
1350
1352
  key_id: string;
@@ -1354,7 +1356,7 @@ export interface components {
1354
1356
  [key: string]: unknown;
1355
1357
  };
1356
1358
  };
1357
- /** @description The claims of a signed transfer (`typ` `transfer.v1+jwt`): `sender`, `receiver` and `comment` (with an optional `metadata`) plus `iss`, `aud`, `jti`, `exp` and `approved`. Strict: an unknown claim, country or document is refused, nothing names an Account Key or an AndCo account id, and the only deadline is `exp`. */
1359
+ /** @description The claims of a signed transfer (`typ` `transfer.v1+jwt`): `sender`, `receiver` and `comment` (with an optional `metadata`) plus `iss`, `aud`, `jti` and `exp`. There is no `approved`: the route decides it (`POST /transfers` sends the transfer now, `POST /intents` makes it an Intent that waits for a decision). Strict: an unknown claim (`approved` included), country or document is refused, nothing names an Account Key or an AndCo account id, and the only deadline is `exp`. */
1358
1360
  SignedTransferClaims: {
1359
1361
  /** @description The signing Project's `client_id`. */
1360
1362
  iss: string;
@@ -1367,8 +1369,6 @@ export interface components {
1367
1369
  jti: string;
1368
1370
  /** @description Unix seconds after which the transfer is refused. */
1369
1371
  exp: number;
1370
- /** @description `true` orders the transfer sent as soon as it is submitted, which needs `bank_transfer` `approve` in the Grant. */
1371
- approved: boolean;
1372
1372
  sender: components["schemas"]["TransferSender"];
1373
1373
  receiver: components["schemas"]["TransferReceiver"];
1374
1374
  /** @description What both sides read next to the movement. */
@@ -1470,9 +1470,9 @@ export interface components {
1470
1470
  };
1471
1471
  /** @description The Nota de operación, at most 60 bytes of UTF-8, or null when there is none. */
1472
1472
  comment: string | null;
1473
- /** @description The Intent this Transfer came from. Null for origin `emisor` (no request came first) and for a signed transfer with `approved: true` (its signature approved it, so there was no request). */
1473
+ /** @description The Intent this Transfer came from. Null for origin `emisor` (no request came first) and for a signed transfer submitted through `POST /transfers` (approved when it was submitted, so there was no request). */
1474
1474
  intent_id: string | null;
1475
- /** @description The `jti` of the signed transfer with `approved: true` that submitted it, a UUID in lowercase. Null for any other Transfer: the `jti` of a signed Intent stays on the Intent. `GET /transfers?jti=` finds only a Transfer that has one. */
1475
+ /** @description The `jti` of the signed transfer that submitted it through `POST /transfers`, a UUID in lowercase. Null for any other Transfer: the `jti` of a signed Intent stays on the Intent, even after it is approved. `GET /transfers?jti=` finds only a Transfer that has one. */
1476
1476
  jti: string | null;
1477
1477
  /** @description The ledger id of the debit once the Transfer succeeded, else null. A Movement carries the same id. */
1478
1478
  transaction_id: string | null;
@@ -3973,7 +3973,7 @@ export interface operations {
3973
3973
  "application/json": components["schemas"]["Intent"];
3974
3974
  };
3975
3975
  };
3976
- /** @description `invalid_request`, `idempotency_key_not_allowed`, `approved_use_transfers`, `invalid_signed_instruction` */
3976
+ /** @description `invalid_request`, `idempotency_key_not_allowed`, `invalid_signed_instruction` */
3977
3977
  400: {
3978
3978
  headers: {
3979
3979
  [name: string]: unknown;
@@ -4001,13 +4001,6 @@ export interface operations {
4001
4001
  message?: string;
4002
4002
  /** @description When present, an English sentence suggesting to the developer what to do about the error. Never branch on it and never show it to a person. */
4003
4003
  hint?: string;
4004
- } | {
4005
- /** @constant */
4006
- error: "approved_use_transfers";
4007
- /** @description An English sentence for the developer reading a log. Never branch on it and never show it to a person. */
4008
- message?: string;
4009
- /** @description When present, an English sentence suggesting to the developer what to do about the error. Never branch on it and never show it to a person. */
4010
- hint?: string;
4011
4004
  } | {
4012
4005
  /** @constant */
4013
4006
  error: "invalid_signed_instruction";
@@ -4244,7 +4237,7 @@ export interface operations {
4244
4237
  };
4245
4238
  };
4246
4239
  };
4247
- /** @description `deposit_amount_out_of_bounds`, `deposit_destination_ambiguous`, `amount_out_of_grant`, `invalid_source`, `invalid_destination`, `transfer_sender_identity_unavailable`, `unsupported_bank`, `bank_connection_unavailable`, `bank_account_number_missing`, `bank_authorization_denied`, `bank_holder_without_account`, `bank_account_limit_reached`, `bank_refused`, `insufficient_funds`, `bank_rejected`, `bank_review_required` */
4240
+ /** @description `deposit_amount_out_of_bounds`, `deposit_destination_ambiguous`, `destination_not_own_account`, `amount_out_of_grant`, `invalid_source`, `invalid_destination`, `transfer_sender_identity_unavailable`, `unsupported_bank`, `bank_connection_unavailable`, `bank_account_number_missing`, `bank_authorization_denied`, `bank_holder_without_account`, `bank_account_limit_reached`, `bank_refused`, `insufficient_funds`, `bank_rejected`, `bank_review_required` */
4248
4241
  422: {
4249
4242
  headers: {
4250
4243
  [name: string]: unknown;
@@ -4274,6 +4267,18 @@ export interface operations {
4274
4267
  message?: string;
4275
4268
  /** @description When present, an English sentence suggesting to the developer what to do about the error. Never branch on it and never show it to a person. */
4276
4269
  hint?: string;
4270
+ } | {
4271
+ /** @constant */
4272
+ error: "destination_not_own_account";
4273
+ /**
4274
+ * Format: uuid
4275
+ * @description The Intent the refusal is about, when it was refused at its release rather than at its creation.
4276
+ */
4277
+ intent_id?: string;
4278
+ /** @description An English sentence for the developer reading a log. Never branch on it and never show it to a person. */
4279
+ message?: string;
4280
+ /** @description When present, an English sentence suggesting to the developer what to do about the error. Never branch on it and never show it to a person. */
4281
+ hint?: string;
4277
4282
  } | {
4278
4283
  /** @constant */
4279
4284
  error: "amount_out_of_grant";
@@ -4653,7 +4658,7 @@ export interface operations {
4653
4658
  "application/json": components["schemas"]["Transfer"];
4654
4659
  };
4655
4660
  };
4656
- /** @description `invalid_request`, `idempotency_key_not_allowed`, `approval_required_use_intents`, `invalid_signed_instruction` */
4661
+ /** @description `invalid_request`, `idempotency_key_not_allowed`, `invalid_signed_instruction` */
4657
4662
  400: {
4658
4663
  headers: {
4659
4664
  [name: string]: unknown;
@@ -4681,13 +4686,6 @@ export interface operations {
4681
4686
  message?: string;
4682
4687
  /** @description When present, an English sentence suggesting to the developer what to do about the error. Never branch on it and never show it to a person. */
4683
4688
  hint?: string;
4684
- } | {
4685
- /** @constant */
4686
- error: "approval_required_use_intents";
4687
- /** @description An English sentence for the developer reading a log. Never branch on it and never show it to a person. */
4688
- message?: string;
4689
- /** @description When present, an English sentence suggesting to the developer what to do about the error. Never branch on it and never show it to a person. */
4690
- hint?: string;
4691
4689
  } | {
4692
4690
  /** @constant */
4693
4691
  error: "invalid_signed_instruction";