summaryrefslogtreecommitdiff
path: root/packages/taler-util/src
diff options
context:
space:
mode:
Diffstat (limited to 'packages/taler-util/src')
-rw-r--r--packages/taler-util/src/bank-api-client.ts41
-rw-r--r--packages/taler-util/src/talerconfig.ts6
-rw-r--r--packages/taler-util/src/wallet-types.ts13
3 files changed, 53 insertions, 7 deletions
diff --git a/packages/taler-util/src/bank-api-client.ts b/packages/taler-util/src/bank-api-client.ts
index d42317f91..a8cd4b0da 100644
--- a/packages/taler-util/src/bank-api-client.ts
+++ b/packages/taler-util/src/bank-api-client.ts
@@ -264,7 +264,7 @@ export class TalerCorebankApiClient {
const resp = await this.httpLib.fetch(url.href, {
headers: this.makeAuthHeader(),
});
- return await resp.json();
+ return readSuccessResponseJsonOrThrow(resp, codecForAny());
}
async getTransactions(username: string): Promise<void> {
@@ -295,6 +295,30 @@ export class TalerCorebankApiClient {
return await readSuccessResponseJsonOrThrow(resp, codecForAny());
}
+ async registerAccountExtended(req: RegisterAccountRequest): Promise<void> {
+ const url = new URL("accounts", this.baseUrl);
+ const resp = await this.httpLib.fetch(url.href, {
+ method: "POST",
+ body: req,
+ });
+
+ if (
+ resp.status !== 200 &&
+ resp.status !== 201 &&
+ resp.status !== 202 &&
+ resp.status !== 204
+ ) {
+ logger.error(`unexpected status ${resp.status} from POST ${url.href}`);
+ logger.error(`${j2s(await resp.json())}`);
+ throw TalerError.fromDetail(
+ TalerErrorCode.GENERIC_UNEXPECTED_REQUEST_ERROR,
+ {
+ httpStatusCode: resp.status,
+ },
+ );
+ }
+ }
+
/**
* Register a new account and return information about it.
*
@@ -311,7 +335,13 @@ export class TalerCorebankApiClient {
name: username,
},
});
- if (resp.status !== 200 && resp.status !== 202 && resp.status !== 204) {
+ if (
+ resp.status !== 200 &&
+ resp.status !== 201 &&
+ resp.status !== 202 &&
+ resp.status !== 204
+ ) {
+ logger.error(`unexpected status ${resp.status} from POST ${url.href}`);
logger.error(`${j2s(await resp.json())}`);
throw TalerError.fromDetail(
TalerErrorCode.GENERIC_UNEXPECTED_REQUEST_ERROR,
@@ -320,8 +350,13 @@ export class TalerCorebankApiClient {
},
);
}
+ // FIXME: Corebank should directly return this info!
const infoUrl = new URL(`accounts/${username}`, this.baseUrl);
- const infoResp = await this.httpLib.fetch(infoUrl.href);
+ const infoResp = await this.httpLib.fetch(infoUrl.href, {
+ headers: {
+ Authorization: makeBasicAuthHeader(username, password),
+ },
+ });
// FIXME: Validate!
const acctInfo: AccountData = await readSuccessResponseJsonOrThrow(
infoResp,
diff --git a/packages/taler-util/src/talerconfig.ts b/packages/taler-util/src/talerconfig.ts
index e9eb71279..f817d9bcb 100644
--- a/packages/taler-util/src/talerconfig.ts
+++ b/packages/taler-util/src/talerconfig.ts
@@ -143,9 +143,9 @@ export function expandPath(path: string): string {
export function pathsub(
x: string,
lookup: (s: string, depth: number) => string | undefined,
- depth = 0,
+ recursionDepth = 0,
): string {
- if (depth >= 128) {
+ if (recursionDepth >= 128) {
throw Error("recursion in path substitution");
}
let s = x;
@@ -201,7 +201,7 @@ export function pathsub(
} else {
const m = /^[a-zA-Z-_][a-zA-Z0-9-_]*/.exec(s.substring(l + 1));
if (m && m[0]) {
- const r = lookup(m[0], depth + 1);
+ const r = lookup(m[0], recursionDepth + 1);
if (r !== undefined) {
s = s.substring(0, l) + r + s.substring(l + 1 + m[0].length);
l = l + r.length;
diff --git a/packages/taler-util/src/wallet-types.ts b/packages/taler-util/src/wallet-types.ts
index 87985fa2a..c5c2c375c 100644
--- a/packages/taler-util/src/wallet-types.ts
+++ b/packages/taler-util/src/wallet-types.ts
@@ -73,7 +73,13 @@ import {
codecForAbsoluteTime,
codecForTimestamp,
} from "./time.js";
-import { OrderShortInfo, TransactionType } from "./transactions-types.js";
+import {
+ OrderShortInfo,
+ TransactionMajorState,
+ TransactionMinorState,
+ TransactionState,
+ TransactionType,
+} from "./transactions-types.js";
/**
* Identifier for a transaction in the wallet.
@@ -2715,3 +2721,8 @@ export interface WalletContractData {
maxDepositFee: AmountString;
minimumAge?: number;
}
+
+export interface TestingWaitTransactionRequest {
+ transactionId: string;
+ txState: TransactionState;
+}