aboutsummaryrefslogtreecommitdiff
path: root/packages/aml-backoffice-ui/src/utils
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2024-04-29 17:23:04 -0300
committerSebastian <sebasjm@gmail.com>2024-04-29 17:23:04 -0300
commit22709ff4e2918a8d0e528539d11d761381920b45 (patch)
tree7e01f9115ed44e5e3875e3473eb0d31314380d5a /packages/aml-backoffice-ui/src/utils
parenteeabe64b3f0ac02818561ea6fca364d619f061b7 (diff)
downloadwallet-core-22709ff4e2918a8d0e528539d11d761381920b45.tar.xz
use exchange api type and start using ui_fields
Diffstat (limited to 'packages/aml-backoffice-ui/src/utils')
-rw-r--r--packages/aml-backoffice-ui/src/utils/converter.ts34
-rw-r--r--packages/aml-backoffice-ui/src/utils/types.ts124
2 files changed, 25 insertions, 133 deletions
diff --git a/packages/aml-backoffice-ui/src/utils/converter.ts b/packages/aml-backoffice-ui/src/utils/converter.ts
index d2f05ed84..cca764a81 100644
--- a/packages/aml-backoffice-ui/src/utils/converter.ts
+++ b/packages/aml-backoffice-ui/src/utils/converter.ts
@@ -1,30 +1,46 @@
-import { AmlExchangeBackend } from "./types.js";
+/*
+ This file is part of GNU Taler
+ (C) 2022-2024 Taler Systems S.A.
+
+ GNU Taler is free software; you can redistribute it and/or modify it under the
+ terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 3, or (at your option) any later version.
+
+ GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along with
+ GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+ */
+
+import { TalerExchangeApi } from "@gnu-taler/taler-util";
export const amlStateConverter = {
toStringUI: stringifyAmlState,
fromStringUI: parseAmlState,
};
-function stringifyAmlState(s: AmlExchangeBackend.AmlState | undefined): string {
+function stringifyAmlState(s: TalerExchangeApi.AmlState | undefined): string {
if (s === undefined) return "";
switch (s) {
- case AmlExchangeBackend.AmlState.normal:
+ case TalerExchangeApi.AmlState.normal:
return "normal";
- case AmlExchangeBackend.AmlState.pending:
+ case TalerExchangeApi.AmlState.pending:
return "pending";
- case AmlExchangeBackend.AmlState.frozen:
+ case TalerExchangeApi.AmlState.frozen:
return "frozen";
}
}
-function parseAmlState(s: string | undefined): AmlExchangeBackend.AmlState {
+function parseAmlState(s: string | undefined): TalerExchangeApi.AmlState {
switch (s) {
case "normal":
- return AmlExchangeBackend.AmlState.normal;
+ return TalerExchangeApi.AmlState.normal;
case "pending":
- return AmlExchangeBackend.AmlState.pending;
+ return TalerExchangeApi.AmlState.pending;
case "frozen":
- return AmlExchangeBackend.AmlState.frozen;
+ return TalerExchangeApi.AmlState.frozen;
default:
throw Error(`unknown AML state: ${s}`);
}
diff --git a/packages/aml-backoffice-ui/src/utils/types.ts b/packages/aml-backoffice-ui/src/utils/types.ts
deleted file mode 100644
index fd70d4e4d..000000000
--- a/packages/aml-backoffice-ui/src/utils/types.ts
+++ /dev/null
@@ -1,124 +0,0 @@
-export namespace AmlExchangeBackend {
- // FIXME: placeholder
- export interface AmlError {
- code: number;
- hint: string;
- }
- export interface AmlDecisionDetails {
- // Array of AML decisions made for this account. Possibly
- // contains only the most recent decision if "history" was
- // not set to 'true'.
- aml_history: AmlDecisionDetail[];
-
- // Array of KYC attributes obtained for this account.
- kyc_attributes: KycDetail[];
- }
-
- type AmlOfficerPublicKeyP = string;
-
- export interface AmlDecisionDetail {
- // What was the justification given?
- justification: string;
-
- // What is the new AML state.
- new_state: Integer;
-
- // When was this decision made?
- decision_time: Timestamp;
-
- // What is the new AML decision threshold (in monthly transaction volume)?
- new_threshold: Amount;
-
- // Who made the decision?
- decider_pub: AmlOfficerPublicKeyP;
- }
- export interface KycDetail {
- // Name of the configuration section that specifies the provider
- // which was used to collect the KYC details
- provider_section: string;
-
- // The collected KYC data. NULL if the attribute data could not
- // be decrypted (internal error of the exchange, likely the
- // attribute key was changed).
- attributes?: Object;
-
- // Time when the KYC data was collected
- collection_time: Timestamp;
-
- // Time when the validity of the KYC data will expire
- expiration_time: Timestamp;
- }
-
- interface Timestamp {
- // Seconds since epoch, or the special
- // value "never" to represent an event that will
- // never happen.
- t_s: number | "never";
- }
-
- type PaytoHash = string;
- type Integer = number;
- type Amount = string;
- // EdDSA signatures are transmitted as 64-bytes base32
- // binary-encoded objects with just the R and S values (base32_ binary-only).
- type EddsaSignature = string;
-
- export interface AmlRecords {
- // Array of AML records matching the query.
- records: AmlRecord[];
- }
-
- interface AmlRecord {
- // Which payto-address is this record about.
- // Identifies a GNU Taler wallet or an affected bank account.
- h_payto: PaytoHash;
-
- // What is the current AML state.
- current_state: AmlState;
-
- // Monthly transaction threshold before a review will be triggered
- threshold: Amount;
-
- // RowID of the record.
- rowid: Integer;
- }
-
- export enum AmlState {
- normal = 0,
- pending = 1,
- frozen = 2,
- }
-
-
- export interface AmlDecision {
-
- // Human-readable justification for the decision.
- justification: string;
-
- // At what monthly transaction volume should the
- // decision be automatically reviewed?
- new_threshold: Amount;
-
- // Which payto-address is the decision about?
- // Identifies a GNU Taler wallet or an affected bank account.
- h_payto: PaytoHash;
-
- // What is the new AML state (e.g. frozen, unfrozen, etc.)
- // Numerical values are defined in AmlDecisionState.
- new_state: Integer;
-
- // Signature by the AML officer over a
- // TALER_MasterAmlOfficerStatusPS.
- // Must have purpose TALER_SIGNATURE_MASTER_AML_KEY.
- officer_sig: EddsaSignature;
-
- // When was the decision made?
- decision_time: Timestamp;
-
- // Optional argument to impose new KYC requirements
- // that the customer has to satisfy to unblock transactions.
- kyc_requirements?: string[];
- }
-
-
-}