aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2023-03-29 18:49:06 +0200
committerFlorian Dold <florian@dold.me>2023-03-29 18:50:07 +0200
commita17a08ae287a46e837c9a691caebdd029a07dc62 (patch)
tree519b14cde985a19fdfd9063c08662dadb107b40e /packages/taler-wallet-core
parente311dc4bef5e50ee7f797d5ff08309a63a43568d (diff)
downloadwallet-core-a17a08ae287a46e837c9a691caebdd029a07dc62.tar.xz
implement IBAN validation
Diffstat (limited to 'packages/taler-wallet-core')
-rw-r--r--packages/taler-wallet-core/src/wallet-api-types.ts12
-rw-r--r--packages/taler-wallet-core/src/wallet.ts11
2 files changed, 23 insertions, 0 deletions
diff --git a/packages/taler-wallet-core/src/wallet-api-types.ts b/packages/taler-wallet-core/src/wallet-api-types.ts
index 84bad09fe..0b1968857 100644
--- a/packages/taler-wallet-core/src/wallet-api-types.ts
+++ b/packages/taler-wallet-core/src/wallet-api-types.ts
@@ -110,6 +110,8 @@ import {
WithdrawFakebankRequest,
WithdrawTestBalanceRequest,
WithdrawUriInfoResponse,
+ ValidateIbanRequest,
+ ValidateIbanResponse,
} from "@gnu-taler/taler-util";
import { WalletContractData } from "./db.js";
import {
@@ -197,6 +199,7 @@ export enum WalletApiOperation {
Recycle = "recycle",
SetDevMode = "setDevMode",
ApplyDevExperiment = "applyDevExperiment",
+ ValidateIban = "validateIban",
}
// group: Initialization
@@ -683,6 +686,14 @@ export type ConfirmPeerPullDebitOp = {
response: EmptyObject;
};
+// group: Data Validation
+
+export type ValidateIbanOp = {
+ op: WalletApiOperation.ValidateIban;
+ request: ValidateIbanRequest;
+ response: ValidateIbanResponse;
+};
+
// group: Database Management
/**
@@ -937,6 +948,7 @@ export type WalletOperations = {
[WalletApiOperation.Recycle]: RecycleOp;
[WalletApiOperation.ApplyDevExperiment]: ApplyDevExperimentOp;
[WalletApiOperation.SetDevMode]: SetDevModeOp;
+ [WalletApiOperation.ValidateIban]: ValidateIbanOp;
};
export type WalletCoreRequestType<
diff --git a/packages/taler-wallet-core/src/wallet.ts b/packages/taler-wallet-core/src/wallet.ts
index 6197f000e..363214e7b 100644
--- a/packages/taler-wallet-core/src/wallet.ts
+++ b/packages/taler-wallet-core/src/wallet.ts
@@ -109,6 +109,9 @@ import {
WalletNotification,
codecForSuspendTransaction,
codecForResumeTransaction,
+ validateIban,
+ codecForValidateIbanRequest,
+ ValidateIbanResponse,
} from "@gnu-taler/taler-util";
import { TalerCryptoInterface } from "./crypto/cryptoImplementation.js";
import {
@@ -1043,6 +1046,14 @@ async function dispatchRequestInternal<Op extends WalletApiOperation>(
await runIntegrationTest(ws, req);
return {};
}
+ case WalletApiOperation.ValidateIban: {
+ const req = codecForValidateIbanRequest().decode(payload);
+ const valRes = validateIban(req.iban);
+ const resp: ValidateIbanResponse = {
+ valid: valRes.type === "valid",
+ };
+ return resp;
+ }
case WalletApiOperation.TestPay: {
const req = codecForTestPayArgs().decode(payload);
return await testPay(ws, req);