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

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.
@@ -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 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 `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;
@@ -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. */
@@ -4244,7 +4246,7 @@ export interface operations {
4244
4246
  };
4245
4247
  };
4246
4248
  };
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` */
4249
+ /** @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
4250
  422: {
4249
4251
  headers: {
4250
4252
  [name: string]: unknown;
@@ -4274,6 +4276,18 @@ export interface operations {
4274
4276
  message?: string;
4275
4277
  /** @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
4278
  hint?: string;
4279
+ } | {
4280
+ /** @constant */
4281
+ error: "destination_not_own_account";
4282
+ /**
4283
+ * Format: uuid
4284
+ * @description The Intent the refusal is about, when it was refused at its release rather than at its creation.
4285
+ */
4286
+ intent_id?: string;
4287
+ /** @description An English sentence for the developer reading a log. Never branch on it and never show it to a person. */
4288
+ message?: string;
4289
+ /** @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. */
4290
+ hint?: string;
4277
4291
  } | {
4278
4292
  /** @constant */
4279
4293
  error: "amount_out_of_grant";