formatting: re-run prettier

This commit is contained in:
Florian Dold 2021-06-09 15:26:18 +02:00
parent 5c26461247
commit 3d2b7b2a65
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B
42 changed files with 363 additions and 385 deletions

View File

@ -220,5 +220,5 @@ export interface Backend {
clearObjectStore( clearObjectStore(
btx: DatabaseTransaction, btx: DatabaseTransaction,
objectStoreName: string, objectStoreName: string,
): Promise<void> ): Promise<void>;
} }

View File

@ -3,11 +3,12 @@ This directory contains test cases from the W3C Web Platform Tests suite for Ind
The original code for these tests can be found here: https://github.com/web-platform-tests/wpt/tree/master/IndexedDB The original code for these tests can be found here: https://github.com/web-platform-tests/wpt/tree/master/IndexedDB
The following tests are intentionally not included: The following tests are intentionally not included:
* error-attributes.html (assumes we have a DOM)
* file_support.sub.html (assumes we have a DOM) - error-attributes.html (assumes we have a DOM)
* fire-error-event-exception.html (ava can't test unhandled rejections) - file_support.sub.html (assumes we have a DOM)
* fire-success-event-exception.html (ava can't test unhandled rejections) - fire-error-event-exception.html (ava can't test unhandled rejections)
* fire-upgradeneeded-event-exception.html (ava can't test unhandled rejections) - fire-success-event-exception.html (ava can't test unhandled rejections)
- fire-upgradeneeded-event-exception.html (ava can't test unhandled rejections)
Test todo: Test todo:

View File

@ -28,76 +28,85 @@ test.cb("WPT test cursor-overloads.htm", (t) => {
await checkCursorDirection(store.openCursor(), "next"); await checkCursorDirection(store.openCursor(), "next");
await checkCursorDirection(store.openCursor(0), "next"); await checkCursorDirection(store.openCursor(0), "next");
await checkCursorDirection(store.openCursor(0, 'next'), "next"); await checkCursorDirection(store.openCursor(0, "next"), "next");
await checkCursorDirection(store.openCursor(0, 'nextunique'), "nextunique"); await checkCursorDirection(store.openCursor(0, "nextunique"), "nextunique");
await checkCursorDirection(store.openCursor(0, 'prev'), "prev"); await checkCursorDirection(store.openCursor(0, "prev"), "prev");
await checkCursorDirection(store.openCursor(0, 'prevunique'), "prevunique"); await checkCursorDirection(store.openCursor(0, "prevunique"), "prevunique");
await checkCursorDirection(store.openCursor(IDBKeyRange.only(0)), "next"); await checkCursorDirection(store.openCursor(IDBKeyRange.only(0)), "next");
await checkCursorDirection( await checkCursorDirection(
store.openCursor(BridgeIDBKeyRange.only(0), 'next'), store.openCursor(BridgeIDBKeyRange.only(0), "next"),
"next", "next",
); );
await checkCursorDirection( await checkCursorDirection(
store.openCursor(IDBKeyRange.only(0), 'nextunique'), store.openCursor(IDBKeyRange.only(0), "nextunique"),
"nextunique", "nextunique",
); );
await checkCursorDirection( await checkCursorDirection(
store.openCursor(IDBKeyRange.only(0), 'prev'), store.openCursor(IDBKeyRange.only(0), "prev"),
"prev", "prev",
); );
await checkCursorDirection( await checkCursorDirection(
store.openCursor(IDBKeyRange.only(0), 'prevunique'), store.openCursor(IDBKeyRange.only(0), "prevunique"),
"prevunique", "prevunique",
); );
await checkCursorDirection(index.openCursor(), "next"); await checkCursorDirection(index.openCursor(), "next");
await checkCursorDirection(index.openCursor(0), "next"); await checkCursorDirection(index.openCursor(0), "next");
await checkCursorDirection(index.openCursor(0, 'next'), "next"); await checkCursorDirection(index.openCursor(0, "next"), "next");
await checkCursorDirection(index.openCursor(0, 'nextunique'), "nextunique"); await checkCursorDirection(index.openCursor(0, "nextunique"), "nextunique");
await checkCursorDirection(index.openCursor(0, 'prev'), "prev"); await checkCursorDirection(index.openCursor(0, "prev"), "prev");
await checkCursorDirection(index.openCursor(0, 'prevunique'), "prevunique"); await checkCursorDirection(index.openCursor(0, "prevunique"), "prevunique");
await checkCursorDirection(index.openCursor(IDBKeyRange.only(0)), "next"); await checkCursorDirection(index.openCursor(IDBKeyRange.only(0)), "next");
await checkCursorDirection( await checkCursorDirection(
index.openCursor(IDBKeyRange.only(0), 'next'), index.openCursor(IDBKeyRange.only(0), "next"),
"next", "next",
); );
await checkCursorDirection( await checkCursorDirection(
index.openCursor(IDBKeyRange.only(0), 'nextunique'), index.openCursor(IDBKeyRange.only(0), "nextunique"),
"nextunique", "nextunique",
); );
await checkCursorDirection( await checkCursorDirection(
index.openCursor(IDBKeyRange.only(0), 'prev'), index.openCursor(IDBKeyRange.only(0), "prev"),
"prev", "prev",
); );
await checkCursorDirection( await checkCursorDirection(
index.openCursor(IDBKeyRange.only(0), 'prevunique'), index.openCursor(IDBKeyRange.only(0), "prevunique"),
"prevunique", "prevunique",
); );
await checkCursorDirection(index.openKeyCursor(), "next"); await checkCursorDirection(index.openKeyCursor(), "next");
await checkCursorDirection(index.openKeyCursor(0), "next"); await checkCursorDirection(index.openKeyCursor(0), "next");
await checkCursorDirection(index.openKeyCursor(0, 'next'), "next"); await checkCursorDirection(index.openKeyCursor(0, "next"), "next");
await checkCursorDirection(index.openKeyCursor(0, 'nextunique'), "nextunique");
await checkCursorDirection(index.openKeyCursor(0, 'prev'), "prev");
await checkCursorDirection(index.openKeyCursor(0, 'prevunique'), "prevunique");
await checkCursorDirection(index.openKeyCursor(IDBKeyRange.only(0)), "next");
await checkCursorDirection( await checkCursorDirection(
index.openKeyCursor(IDBKeyRange.only(0), 'next'), index.openKeyCursor(0, "nextunique"),
"nextunique",
);
await checkCursorDirection(index.openKeyCursor(0, "prev"), "prev");
await checkCursorDirection(
index.openKeyCursor(0, "prevunique"),
"prevunique",
);
await checkCursorDirection(
index.openKeyCursor(IDBKeyRange.only(0)),
"next", "next",
); );
await checkCursorDirection( await checkCursorDirection(
index.openKeyCursor(IDBKeyRange.only(0), 'nextunique'), index.openKeyCursor(IDBKeyRange.only(0), "next"),
"next",
);
await checkCursorDirection(
index.openKeyCursor(IDBKeyRange.only(0), "nextunique"),
"nextunique", "nextunique",
); );
await checkCursorDirection( await checkCursorDirection(
index.openKeyCursor(IDBKeyRange.only(0), 'prev'), index.openKeyCursor(IDBKeyRange.only(0), "prev"),
"prev", "prev",
); );
await checkCursorDirection( await checkCursorDirection(
index.openKeyCursor(IDBKeyRange.only(0), 'prevunique'), index.openKeyCursor(IDBKeyRange.only(0), "prevunique"),
"prevunique", "prevunique",
); );
@ -110,7 +119,11 @@ test.cb("WPT test cursor-overloads.htm", (t) => {
): Promise<void> { ): Promise<void> {
return new Promise<void>((resolve, reject) => { return new Promise<void>((resolve, reject) => {
request.onsuccess = function (event: any) { request.onsuccess = function (event: any) {
t.notDeepEqual(event.target.result, null, "Check the result is not null"); t.notDeepEqual(
event.target.result,
null,
"Check the result is not null",
);
t.deepEqual( t.deepEqual(
event.target.result.direction, event.target.result.direction,
direction, direction,

View File

@ -37,8 +37,8 @@ test.cb("WPT test value.htm, date", (t) => {
.transaction("store") .transaction("store")
.objectStore("store") .objectStore("store")
.get(1).onsuccess = (e: any) => { .get(1).onsuccess = (e: any) => {
console.log("target", e.target); console.log("target", e.target);
console.log("result", e.target.result); console.log("result", e.target.result);
t.assert(e.target.result instanceof _instanceof, "instanceof"); t.assert(e.target.result instanceof _instanceof, "instanceof");
t.end(); t.end();
}; };

View File

@ -116,4 +116,4 @@ export function shimIndexedDB(factory: BridgeIDBFactory): void {
export * from "./idbtypes"; export * from "./idbtypes";
export * from "./util/structuredClone"; export * from "./util/structuredClone";

View File

@ -182,9 +182,7 @@ export type ReserveTransaction =
| ReserveClosingTransaction | ReserveClosingTransaction
| ReserveRecoupTransaction; | ReserveRecoupTransaction;
export const codecForReserveWithdrawTransaction = (): Codec< export const codecForReserveWithdrawTransaction = (): Codec<ReserveWithdrawTransaction> =>
ReserveWithdrawTransaction
> =>
buildCodecForObject<ReserveWithdrawTransaction>() buildCodecForObject<ReserveWithdrawTransaction>()
.property("amount", codecForString()) .property("amount", codecForString())
.property("h_coin_envelope", codecForString()) .property("h_coin_envelope", codecForString())
@ -194,9 +192,7 @@ export const codecForReserveWithdrawTransaction = (): Codec<
.property("withdraw_fee", codecForString()) .property("withdraw_fee", codecForString())
.build("ReserveWithdrawTransaction"); .build("ReserveWithdrawTransaction");
export const codecForReserveCreditTransaction = (): Codec< export const codecForReserveCreditTransaction = (): Codec<ReserveCreditTransaction> =>
ReserveCreditTransaction
> =>
buildCodecForObject<ReserveCreditTransaction>() buildCodecForObject<ReserveCreditTransaction>()
.property("amount", codecForString()) .property("amount", codecForString())
.property("sender_account_url", codecForString()) .property("sender_account_url", codecForString())
@ -205,9 +201,7 @@ export const codecForReserveCreditTransaction = (): Codec<
.property("type", codecForConstString(ReserveTransactionType.Credit)) .property("type", codecForConstString(ReserveTransactionType.Credit))
.build("ReserveCreditTransaction"); .build("ReserveCreditTransaction");
export const codecForReserveClosingTransaction = (): Codec< export const codecForReserveClosingTransaction = (): Codec<ReserveClosingTransaction> =>
ReserveClosingTransaction
> =>
buildCodecForObject<ReserveClosingTransaction>() buildCodecForObject<ReserveClosingTransaction>()
.property("amount", codecForString()) .property("amount", codecForString())
.property("closing_fee", codecForString()) .property("closing_fee", codecForString())
@ -219,9 +213,7 @@ export const codecForReserveClosingTransaction = (): Codec<
.property("wtid", codecForString()) .property("wtid", codecForString())
.build("ReserveClosingTransaction"); .build("ReserveClosingTransaction");
export const codecForReserveRecoupTransaction = (): Codec< export const codecForReserveRecoupTransaction = (): Codec<ReserveRecoupTransaction> =>
ReserveRecoupTransaction
> =>
buildCodecForObject<ReserveRecoupTransaction>() buildCodecForObject<ReserveRecoupTransaction>()
.property("amount", codecForString()) .property("amount", codecForString())
.property("coin_pub", codecForString()) .property("coin_pub", codecForString())

View File

@ -16,14 +16,26 @@
import test from "ava"; import test from "ava";
import * as helpers from "./helpers"; import * as helpers from "./helpers";
test("URL canonicalization", (t) => { test("URL canonicalization", (t) => {
// converts to relative, adds https // converts to relative, adds https
t.is("https://alice.example.com/exchange/", helpers.canonicalizeBaseUrl("alice.example.com/exchange")); t.is(
// keeps http, adds trailing slash "https://alice.example.com/exchange/",
t.is("http://alice.example.com/exchange/", helpers.canonicalizeBaseUrl("http://alice.example.com/exchange")); helpers.canonicalizeBaseUrl("alice.example.com/exchange"),
// keeps http, adds trailing slash );
t.is("http://alice.example.com/exchange/", helpers.canonicalizeBaseUrl("http://alice.example.com/exchange#foobar")); // keeps http, adds trailing slash
// Remove search component t.is(
t.is("http://alice.example.com/exchange/", helpers.canonicalizeBaseUrl("http://alice.example.com/exchange?foo=bar")); "http://alice.example.com/exchange/",
t.pass(); helpers.canonicalizeBaseUrl("http://alice.example.com/exchange"),
);
// keeps http, adds trailing slash
t.is(
"http://alice.example.com/exchange/",
helpers.canonicalizeBaseUrl("http://alice.example.com/exchange#foobar"),
);
// Remove search component
t.is(
"http://alice.example.com/exchange/",
helpers.canonicalizeBaseUrl("http://alice.example.com/exchange?foo=bar"),
);
t.pass();
}); });
//# sourceMappingURL=helpers.test.js.map //# sourceMappingURL=helpers.test.js.map

View File

@ -68,11 +68,7 @@ export function canonicalJson(obj: any): string {
return "\\u" + ("0000" + chr.charCodeAt(0).toString(16)).substr(-4); return "\\u" + ("0000" + chr.charCodeAt(0).toString(16)).substr(-4);
}); });
} }
if ( if (typeof obj === "number" || typeof obj === "boolean" || obj === null) {
typeof obj === "number" ||
typeof obj === "boolean" ||
obj === null
) {
return JSON.stringify(obj); return JSON.stringify(obj);
} }
if (Array.isArray(obj)) { if (Array.isArray(obj)) {

View File

@ -17,7 +17,7 @@ export function setupI18n(lang: string, strings: { [s: string]: any }): any {
lang = "en-US"; lang = "en-US";
logger.warn(`language ${lang} not found, defaulting to english`); logger.warn(`language ${lang} not found, defaulting to english`);
} }
debugger debugger;
jed = new jedLib.Jed(strings[lang]); jed = new jedLib.Jed(strings[lang]);
} }
@ -58,11 +58,14 @@ export function str(stringSeq: TemplateStringsArray, ...values: any[]): string {
/** /**
* Internationalize a string template without serializing * Internationalize a string template without serializing
*/ */
export function translate(stringSeq: TemplateStringsArray, ...values: any[]): any[] { export function translate(
stringSeq: TemplateStringsArray,
...values: any[]
): any[] {
const s = toI18nString(stringSeq); const s = toI18nString(stringSeq);
if (!s) return [] if (!s) return [];
const translation: string = jed.ngettext(s, s, 1); const translation: string = jed.ngettext(s, s, 1);
return replacePlaceholderWithValues(translation, values) return replacePlaceholderWithValues(translation, values);
} }
/** /**
@ -71,9 +74,9 @@ export function translate(stringSeq: TemplateStringsArray, ...values: any[]): an
export function Translate({ children, ...rest }: { children: any }): any { export function Translate({ children, ...rest }: { children: any }): any {
const c = [].concat(children); const c = [].concat(children);
const s = stringifyArray(c); const s = stringifyArray(c);
if (!s) return [] if (!s) return [];
const translation: string = jed.ngettext(s, s, 1); const translation: string = jed.ngettext(s, s, 1);
return replacePlaceholderWithValues(translation, c) return replacePlaceholderWithValues(translation, c);
} }
/** /**
@ -94,7 +97,6 @@ export function getTranslatedArray(array: Array<any>) {
return replacePlaceholderWithValues(translation, array); return replacePlaceholderWithValues(translation, array);
} }
function replacePlaceholderWithValues( function replacePlaceholderWithValues(
translation: string, translation: string,
childArray: Array<any>, childArray: Array<any>,
@ -142,6 +144,5 @@ function stringifyArray(children: Array<any>): string {
export const i18n = { export const i18n = {
str, str,
Translate, Translate,
translate translate,
} };

View File

@ -18,4 +18,4 @@ export * from "./time.js";
export * from "./transactionsTypes.js"; export * from "./transactionsTypes.js";
export * from "./walletTypes.js"; export * from "./walletTypes.js";
export * from "./i18n.js"; export * from "./i18n.js";
export * from "./logging.js"; export * from "./logging.js";

View File

@ -19,7 +19,9 @@
*/ */
const isNode = const isNode =
typeof process !== "undefined" && typeof process.release !== "undefined" && process.release.name === "node"; typeof process !== "undefined" &&
typeof process.release !== "undefined" &&
process.release.name === "node";
function writeNodeLog( function writeNodeLog(
message: any, message: any,

View File

@ -22,8 +22,6 @@
*/ */
export enum TalerErrorCode { export enum TalerErrorCode {
/** /**
* Special code to indicate success (no error). * Special code to indicate success (no error).
* Returned with an HTTP status code of #MHD_HTTP_UNINITIALIZED (0). * Returned with an HTTP status code of #MHD_HTTP_UNINITIALIZED (0).
@ -2319,5 +2317,4 @@ export enum TalerErrorCode {
* (A value of 0 indicates that the error is generated client-side). * (A value of 0 indicates that the error is generated client-side).
*/ */
END = 9999, END = 9999,
} }

View File

@ -989,9 +989,7 @@ export interface BankWithdrawalOperationPostResponse {
transfer_done: boolean; transfer_done: boolean;
} }
export const codecForBankWithdrawalOperationPostResponse = (): Codec< export const codecForBankWithdrawalOperationPostResponse = (): Codec<BankWithdrawalOperationPostResponse> =>
BankWithdrawalOperationPostResponse
> =>
buildCodecForObject<BankWithdrawalOperationPostResponse>() buildCodecForObject<BankWithdrawalOperationPostResponse>()
.property("transfer_done", codecForBoolean()) .property("transfer_done", codecForBoolean())
.build("BankWithdrawalOperationPostResponse"); .build("BankWithdrawalOperationPostResponse");
@ -1070,9 +1068,8 @@ export const codecForTax = (): Codec<Tax> =>
.property("tax", codecForString()) .property("tax", codecForString())
.build("Tax"); .build("Tax");
export const codecForInternationalizedString = (): Codec< export const codecForInternationalizedString = (): Codec<InternationalizedString> =>
InternationalizedString codecForMap(codecForString());
> => codecForMap(codecForString());
export const codecForProduct = (): Codec<Product> => export const codecForProduct = (): Codec<Product> =>
buildCodecForObject<Product>() buildCodecForObject<Product>()
@ -1120,9 +1117,7 @@ export const codecForContractTerms = (): Codec<ContractTerms> =>
.property("extra", codecForAny()) .property("extra", codecForAny())
.build("ContractTerms"); .build("ContractTerms");
export const codecForMerchantRefundPermission = (): Codec< export const codecForMerchantRefundPermission = (): Codec<MerchantAbortPayRefundDetails> =>
MerchantAbortPayRefundDetails
> =>
buildCodecForObject<MerchantAbortPayRefundDetails>() buildCodecForObject<MerchantAbortPayRefundDetails>()
.property("refund_amount", codecForAmountString()) .property("refund_amount", codecForAmountString())
.property("refund_fee", codecForAmountString()) .property("refund_fee", codecForAmountString())
@ -1135,9 +1130,7 @@ export const codecForMerchantRefundPermission = (): Codec<
.property("exchange_pub", codecOptional(codecForString())) .property("exchange_pub", codecOptional(codecForString()))
.build("MerchantRefundPermission"); .build("MerchantRefundPermission");
export const codecForMerchantRefundResponse = (): Codec< export const codecForMerchantRefundResponse = (): Codec<MerchantRefundResponse> =>
MerchantRefundResponse
> =>
buildCodecForObject<MerchantRefundResponse>() buildCodecForObject<MerchantRefundResponse>()
.property("merchant_pub", codecForString()) .property("merchant_pub", codecForString())
.property("h_contract_terms", codecForString()) .property("h_contract_terms", codecForString())
@ -1217,9 +1210,7 @@ export const codecForCheckPaymentResponse = (): Codec<CheckPaymentResponse> =>
.property("contract_url", codecOptional(codecForString())) .property("contract_url", codecOptional(codecForString()))
.build("CheckPaymentResponse"); .build("CheckPaymentResponse");
export const codecForWithdrawOperationStatusResponse = (): Codec< export const codecForWithdrawOperationStatusResponse = (): Codec<WithdrawOperationStatusResponse> =>
WithdrawOperationStatusResponse
> =>
buildCodecForObject<WithdrawOperationStatusResponse>() buildCodecForObject<WithdrawOperationStatusResponse>()
.property("selection_done", codecForBoolean()) .property("selection_done", codecForBoolean())
.property("transfer_done", codecForBoolean()) .property("transfer_done", codecForBoolean())
@ -1267,16 +1258,12 @@ export const codecForExchangeRevealItem = (): Codec<ExchangeRevealItem> =>
.property("ev_sig", codecForString()) .property("ev_sig", codecForString())
.build("ExchangeRevealItem"); .build("ExchangeRevealItem");
export const codecForExchangeRevealResponse = (): Codec< export const codecForExchangeRevealResponse = (): Codec<ExchangeRevealResponse> =>
ExchangeRevealResponse
> =>
buildCodecForObject<ExchangeRevealResponse>() buildCodecForObject<ExchangeRevealResponse>()
.property("ev_sigs", codecForList(codecForExchangeRevealItem())) .property("ev_sigs", codecForList(codecForExchangeRevealItem()))
.build("ExchangeRevealResponse"); .build("ExchangeRevealResponse");
export const codecForMerchantCoinRefundSuccessStatus = (): Codec< export const codecForMerchantCoinRefundSuccessStatus = (): Codec<MerchantCoinRefundSuccessStatus> =>
MerchantCoinRefundSuccessStatus
> =>
buildCodecForObject<MerchantCoinRefundSuccessStatus>() buildCodecForObject<MerchantCoinRefundSuccessStatus>()
.property("type", codecForConstString("success")) .property("type", codecForConstString("success"))
.property("coin_pub", codecForString()) .property("coin_pub", codecForString())
@ -1288,9 +1275,7 @@ export const codecForMerchantCoinRefundSuccessStatus = (): Codec<
.property("execution_time", codecForTimestamp) .property("execution_time", codecForTimestamp)
.build("MerchantCoinRefundSuccessStatus"); .build("MerchantCoinRefundSuccessStatus");
export const codecForMerchantCoinRefundFailureStatus = (): Codec< export const codecForMerchantCoinRefundFailureStatus = (): Codec<MerchantCoinRefundFailureStatus> =>
MerchantCoinRefundFailureStatus
> =>
buildCodecForObject<MerchantCoinRefundFailureStatus>() buildCodecForObject<MerchantCoinRefundFailureStatus>()
.property("type", codecForConstString("failure")) .property("type", codecForConstString("failure"))
.property("coin_pub", codecForString()) .property("coin_pub", codecForString())
@ -1302,35 +1287,27 @@ export const codecForMerchantCoinRefundFailureStatus = (): Codec<
.property("execution_time", codecForTimestamp) .property("execution_time", codecForTimestamp)
.build("MerchantCoinRefundFailureStatus"); .build("MerchantCoinRefundFailureStatus");
export const codecForMerchantCoinRefundStatus = (): Codec< export const codecForMerchantCoinRefundStatus = (): Codec<MerchantCoinRefundStatus> =>
MerchantCoinRefundStatus
> =>
buildCodecForUnion<MerchantCoinRefundStatus>() buildCodecForUnion<MerchantCoinRefundStatus>()
.discriminateOn("type") .discriminateOn("type")
.alternative("success", codecForMerchantCoinRefundSuccessStatus()) .alternative("success", codecForMerchantCoinRefundSuccessStatus())
.alternative("failure", codecForMerchantCoinRefundFailureStatus()) .alternative("failure", codecForMerchantCoinRefundFailureStatus())
.build("MerchantCoinRefundStatus"); .build("MerchantCoinRefundStatus");
export const codecForMerchantOrderStatusPaid = (): Codec< export const codecForMerchantOrderStatusPaid = (): Codec<MerchantOrderStatusPaid> =>
MerchantOrderStatusPaid
> =>
buildCodecForObject<MerchantOrderStatusPaid>() buildCodecForObject<MerchantOrderStatusPaid>()
.property("refund_amount", codecForString()) .property("refund_amount", codecForString())
.property("refunded", codecForBoolean()) .property("refunded", codecForBoolean())
.build("MerchantOrderStatusPaid"); .build("MerchantOrderStatusPaid");
export const codecForMerchantOrderRefundPickupResponse = (): Codec< export const codecForMerchantOrderRefundPickupResponse = (): Codec<MerchantOrderRefundResponse> =>
MerchantOrderRefundResponse
> =>
buildCodecForObject<MerchantOrderRefundResponse>() buildCodecForObject<MerchantOrderRefundResponse>()
.property("merchant_pub", codecForString()) .property("merchant_pub", codecForString())
.property("refund_amount", codecForString()) .property("refund_amount", codecForString())
.property("refunds", codecForList(codecForMerchantCoinRefundStatus())) .property("refunds", codecForList(codecForMerchantCoinRefundStatus()))
.build("MerchantOrderRefundPickupResponse"); .build("MerchantOrderRefundPickupResponse");
export const codecForMerchantOrderStatusUnpaid = (): Codec< export const codecForMerchantOrderStatusUnpaid = (): Codec<MerchantOrderStatusUnpaid> =>
MerchantOrderStatusUnpaid
> =>
buildCodecForObject<MerchantOrderStatusUnpaid>() buildCodecForObject<MerchantOrderStatusUnpaid>()
.property("taler_pay_uri", codecForString()) .property("taler_pay_uri", codecForString())
.property("already_paid_order_id", codecOptional(codecForString())) .property("already_paid_order_id", codecOptional(codecForString()))
@ -1412,9 +1389,7 @@ export interface MerchantAbortPayRefundSuccessStatus {
exchange_pub: string; exchange_pub: string;
} }
export const codecForMerchantAbortPayRefundSuccessStatus = (): Codec< export const codecForMerchantAbortPayRefundSuccessStatus = (): Codec<MerchantAbortPayRefundSuccessStatus> =>
MerchantAbortPayRefundSuccessStatus
> =>
buildCodecForObject<MerchantAbortPayRefundSuccessStatus>() buildCodecForObject<MerchantAbortPayRefundSuccessStatus>()
.property("exchange_pub", codecForString()) .property("exchange_pub", codecForString())
.property("exchange_sig", codecForString()) .property("exchange_sig", codecForString())
@ -1422,9 +1397,7 @@ export const codecForMerchantAbortPayRefundSuccessStatus = (): Codec<
.property("type", codecForConstString("success")) .property("type", codecForConstString("success"))
.build("MerchantAbortPayRefundSuccessStatus"); .build("MerchantAbortPayRefundSuccessStatus");
export const codecForMerchantAbortPayRefundFailureStatus = (): Codec< export const codecForMerchantAbortPayRefundFailureStatus = (): Codec<MerchantAbortPayRefundFailureStatus> =>
MerchantAbortPayRefundFailureStatus
> =>
buildCodecForObject<MerchantAbortPayRefundFailureStatus>() buildCodecForObject<MerchantAbortPayRefundFailureStatus>()
.property("exchange_code", codecForNumber()) .property("exchange_code", codecForNumber())
.property("exchange_reply", codecForAny()) .property("exchange_reply", codecForAny())
@ -1432,9 +1405,7 @@ export const codecForMerchantAbortPayRefundFailureStatus = (): Codec<
.property("type", codecForConstString("failure")) .property("type", codecForConstString("failure"))
.build("MerchantAbortPayRefundFailureStatus"); .build("MerchantAbortPayRefundFailureStatus");
export const codecForMerchantAbortPayRefundStatus = (): Codec< export const codecForMerchantAbortPayRefundStatus = (): Codec<MerchantAbortPayRefundStatus> =>
MerchantAbortPayRefundStatus
> =>
buildCodecForUnion<MerchantAbortPayRefundStatus>() buildCodecForUnion<MerchantAbortPayRefundStatus>()
.discriminateOn("type") .discriminateOn("type")
.alternative("success", codecForMerchantAbortPayRefundSuccessStatus()) .alternative("success", codecForMerchantAbortPayRefundSuccessStatus())

View File

@ -28,18 +28,18 @@ import { Amounts } from "./amounts.js";
const nodejs_fs = (function () { const nodejs_fs = (function () {
let fs: typeof import("fs"); let fs: typeof import("fs");
return function() { return function () {
if (!fs) { if (!fs) {
/** /**
* need to use an expression when doing a require if we want * need to use an expression when doing a require if we want
* webpack not to find out about the requirement * webpack not to find out about the requirement
*/ */
const _r = "require" const _r = "require";
fs = module[_r]("fs") fs = module[_r]("fs");
} }
return fs return fs;
} };
})() })();
export class ConfigError extends Error { export class ConfigError extends Error {
constructor(message: string) { constructor(message: string) {

View File

@ -22,7 +22,7 @@ import fs from "fs";
/** /**
* Resolve an asset name into an absolute filename. * Resolve an asset name into an absolute filename.
* *
* The asset file should be placed in the "assets" directory * The asset file should be placed in the "assets" directory
* at the top level of the package (i.e. next to package.json). * at the top level of the package (i.e. next to package.json).
*/ */

View File

@ -82,7 +82,7 @@ interface LibeufinNexusMoneyMovement {
}; };
endToEndId: string; endToEndId: string;
unstructuredRemittanceInformation: string; unstructuredRemittanceInformation: string;
} };
} }
interface LibeufinNexusBatches { interface LibeufinNexusBatches {
@ -668,7 +668,10 @@ export class LibeufinCli {
console.log(stdout); console.log(stdout);
} }
async submitPayment(details: LibeufinPreparedPaymentDetails, paymentUuid: string): Promise<void> { async submitPayment(
details: LibeufinPreparedPaymentDetails,
paymentUuid: string,
): Promise<void> {
const stdout = await sh( const stdout = await sh(
this.globalTestState, this.globalTestState,
"libeufin-cli-submitpayment", "libeufin-cli-submitpayment",
@ -820,7 +823,7 @@ export interface NexusAuth {
auth: { auth: {
username: string; username: string;
password: string; password: string;
} };
} }
export interface CreateNexusUserRequest { export interface CreateNexusUserRequest {
@ -832,10 +835,12 @@ export interface PostNexusTaskRequest {
name: string; name: string;
cronspec: string; cronspec: string;
type: string; // fetch | submit type: string; // fetch | submit
params: { params:
level: string; // report | statement | all | {
rangeType: string; // all | since-last | previous-days | latest level: string; // report | statement | all
} | {} rangeType: string; // all | since-last | previous-days | latest
}
| {};
} }
export interface PostNexusPermissionRequest { export interface PostNexusPermissionRequest {
@ -850,20 +855,16 @@ export interface PostNexusPermissionRequest {
} }
export namespace LibeufinNexusApi { export namespace LibeufinNexusApi {
export async function getAllConnections( export async function getAllConnections(
nexus: LibeufinNexusServiceInterface, nexus: LibeufinNexusServiceInterface,
): Promise<any> { ): Promise<any> {
let url = new URL("bank-connections", nexus.baseUrl); let url = new URL("bank-connections", nexus.baseUrl);
const res = await axios.get( const res = await axios.get(url.href, {
url.href, auth: {
{ username: "admin",
auth: { password: "test",
username: "admin",
password: "test",
},
}, },
); });
return res; return res;
} }
@ -873,16 +874,12 @@ export namespace LibeufinNexusApi {
): Promise<any> { ): Promise<any> {
const baseUrl = libeufinNexusService.baseUrl; const baseUrl = libeufinNexusService.baseUrl;
let url = new URL("bank-connections/delete-connection", baseUrl); let url = new URL("bank-connections/delete-connection", baseUrl);
return await axios.post( return await axios.post(url.href, req, {
url.href, auth: {
req, username: "admin",
{ password: "test",
auth: { },
username: "admin", });
password: "test",
}
}
);
} }
export async function createEbicsBankConnection( export async function createEbicsBankConnection(
@ -1012,31 +1009,26 @@ export namespace LibeufinNexusApi {
`/bank-accounts/${accountName}/payment-initiations`, `/bank-accounts/${accountName}/payment-initiations`,
baseUrl, baseUrl,
); );
let response = await axios.get( let response = await axios.get(url.href, {
url.href, auth: {
{ username: username,
auth: { password: password,
username: username,
password: password,
},
}, },
});
console.log(
`Payment initiations of: ${accountName}`,
JSON.stringify(response.data, null, 2),
); );
console.log(`Payment initiations of: ${accountName}`,
JSON.stringify(response.data, null, 2));
} }
export async function getConfig( export async function getConfig(
libeufinNexusService: LibeufinNexusService, libeufinNexusService: LibeufinNexusService,
): Promise<void> { ): Promise<void> {
const baseUrl = libeufinNexusService.baseUrl; const baseUrl = libeufinNexusService.baseUrl;
let url = new URL( let url = new URL(`/config`, baseUrl);
`/config`,
baseUrl,
);
let response = await axios.get(url.href); let response = await axios.get(url.href);
} }
// FIXME: this function should return some structured // FIXME: this function should return some structured
// object that represents a history. // object that represents a history.
export async function getAccountTransactions( export async function getAccountTransactions(
@ -1046,19 +1038,13 @@ export namespace LibeufinNexusApi {
password: string = "test", password: string = "test",
): Promise<any> { ): Promise<any> {
const baseUrl = libeufinNexusService.baseUrl; const baseUrl = libeufinNexusService.baseUrl;
let url = new URL( let url = new URL(`/bank-accounts/${accountName}/transactions`, baseUrl);
`/bank-accounts/${accountName}/transactions`, let response = await axios.get(url.href, {
baseUrl, auth: {
); username: username,
let response = await axios.get( password: password,
url.href,
{
auth: {
username: username,
password: password,
},
}, },
); });
return response; return response;
} }
@ -1174,7 +1160,10 @@ export namespace LibeufinNexusApi {
taskName: string, taskName: string,
) { ) {
const baseUrl = libeufinNexusService.baseUrl; const baseUrl = libeufinNexusService.baseUrl;
let url = new URL(`/bank-accounts/${bankAccountName}/schedule/${taskName}`, baseUrl); let url = new URL(
`/bank-accounts/${bankAccountName}/schedule/${taskName}`,
baseUrl,
);
await axios.delete(url.href, { await axios.delete(url.href, {
auth: { auth: {
username: "admin", username: "admin",
@ -1204,15 +1193,12 @@ export namespace LibeufinNexusApi {
): Promise<any> { ): Promise<any> {
const baseUrl = libeufinNexusService.baseUrl; const baseUrl = libeufinNexusService.baseUrl;
let url = new URL(`facades/${facadeName}`, baseUrl); let url = new URL(`facades/${facadeName}`, baseUrl);
return await axios.delete( return await axios.delete(url.href, {
url.href, auth: {
{ username: "admin",
auth: { password: "test",
username: "admin", },
password: "test", });
},
}
);
} }
export async function getAllFacades( export async function getAllFacades(
@ -1220,15 +1206,12 @@ export namespace LibeufinNexusApi {
): Promise<any> { ): Promise<any> {
const baseUrl = libeufinNexusService.baseUrl; const baseUrl = libeufinNexusService.baseUrl;
let url = new URL("facades", baseUrl); let url = new URL("facades", baseUrl);
return await axios.get( return await axios.get(url.href, {
url.href, auth: {
{ username: "admin",
auth: { password: "test",
username: "admin", },
password: "test", });
},
}
);
} }
export async function createTwgFacade( export async function createTwgFacade(
@ -1368,16 +1351,12 @@ export function findNexusPayment(
key: string, key: string,
payments: LibeufinNexusTransactions, payments: LibeufinNexusTransactions,
): LibeufinNexusMoneyMovement | void { ): LibeufinNexusMoneyMovement | void {
let transactions = payments["transactions"]; let transactions = payments["transactions"];
for (let i = 0; i < transactions.length; i++) { for (let i = 0; i < transactions.length; i++) {
let batches = transactions[i]["batches"]; let batches = transactions[i]["batches"];
for (let y = 0; y < batches.length; y++) { for (let y = 0; y < batches.length; y++) {
let movements = batches[y]["batchTransactions"]; let movements = batches[y]["batchTransactions"];
for (let z = 0; z < movements.length; z++) { for (let z = 0; z < movements.length; z++) {
let movement = movements[z]; let movement = movements[z];
if (movement["details"]["unstructuredRemittanceInformation"] == key) if (movement["details"]["unstructuredRemittanceInformation"] == key)
return movement; return movement;

View File

@ -27,9 +27,7 @@ import {
BankApi, BankApi,
BankAccessApi, BankAccessApi,
} from "./harness"; } from "./harness";
import { import { URL } from "@gnu-taler/taler-wallet-core";
URL,
} from "@gnu-taler/taler-wallet-core";
import { ExchangesListRespose, TalerErrorCode } from "@gnu-taler/taler-util"; import { ExchangesListRespose, TalerErrorCode } from "@gnu-taler/taler-util";
import { import {
FaultInjectedExchangeService, FaultInjectedExchangeService,

View File

@ -38,13 +38,10 @@ export async function runLibeufinApiBankaccountTest(t: GlobalTestState) {
await nexus.start(); await nexus.start();
await nexus.pingUntilAvailable(); await nexus.pingUntilAvailable();
await LibeufinNexusApi.createUser( await LibeufinNexusApi.createUser(nexus, {
nexus, username: "one",
{ password: "testing-the-bankaccount-api",
username: "one", });
password: "testing-the-bankaccount-api",
}
);
const sandbox = await LibeufinSandboxService.create(t, { const sandbox = await LibeufinSandboxService.create(t, {
httpPort: 5012, httpPort: 5012,
databaseJdbcUri: `jdbc:sqlite:${t.testDir}/libeufin-sandbox.sqlite3`, databaseJdbcUri: `jdbc:sqlite:${t.testDir}/libeufin-sandbox.sqlite3`,
@ -52,43 +49,38 @@ export async function runLibeufinApiBankaccountTest(t: GlobalTestState) {
await sandbox.start(); await sandbox.start();
await sandbox.pingUntilAvailable(); await sandbox.pingUntilAvailable();
await LibeufinSandboxApi.createEbicsHost(sandbox, "mock"); await LibeufinSandboxApi.createEbicsHost(sandbox, "mock");
await LibeufinSandboxApi.createEbicsSubscriber( await LibeufinSandboxApi.createEbicsSubscriber(sandbox, {
sandbox, hostID: "mock",
{ userID: "mock",
hostID: "mock", partnerID: "mock",
userID: "mock", });
partnerID: "mock", await LibeufinSandboxApi.createEbicsBankAccount(sandbox, {
} subscriber: {
);
await LibeufinSandboxApi.createEbicsBankAccount(
sandbox,
{
subscriber: {
hostID: "mock",
partnerID: "mock",
userID: "mock",
},
iban: "DE71500105179674997361",
bic: "BELADEBEXXX",
name: "mock",
currency: "mock",
label: "mock",
},
);
await LibeufinNexusApi.createEbicsBankConnection(
nexus,
{
name: "bankaccount-api-test-connection",
ebicsURL: "http://localhost:5012/ebicsweb",
hostID: "mock", hostID: "mock",
userID: "mock",
partnerID: "mock", partnerID: "mock",
} userID: "mock",
); },
iban: "DE71500105179674997361",
bic: "BELADEBEXXX",
name: "mock",
currency: "mock",
label: "mock",
});
await LibeufinNexusApi.createEbicsBankConnection(nexus, {
name: "bankaccount-api-test-connection",
ebicsURL: "http://localhost:5012/ebicsweb",
hostID: "mock",
userID: "mock",
partnerID: "mock",
});
await LibeufinNexusApi.connectBankConnection( await LibeufinNexusApi.connectBankConnection(
nexus, "bankaccount-api-test-connection" nexus,
"bankaccount-api-test-connection",
);
await LibeufinNexusApi.fetchAccounts(
nexus,
"bankaccount-api-test-connection",
); );
await LibeufinNexusApi.fetchAccounts(nexus, "bankaccount-api-test-connection");
await LibeufinNexusApi.importConnectionAccount( await LibeufinNexusApi.importConnectionAccount(
nexus, nexus,
@ -96,30 +88,24 @@ export async function runLibeufinApiBankaccountTest(t: GlobalTestState) {
"mock", "mock",
"local-mock", "local-mock",
); );
await LibeufinSandboxApi.bookPayment2( await LibeufinSandboxApi.bookPayment2(sandbox, {
sandbox, creditorIban: "DE71500105179674997361",
{ creditorBic: "BELADEBEXXX",
creditorIban: "DE71500105179674997361", creditorName: "mock",
creditorBic: "BELADEBEXXX", debitorIban: "DE84500105176881385584",
creditorName: "mock", debitorBic: "BELADEBEXXX",
debitorIban: "DE84500105176881385584", debitorName: "mock2",
debitorBic: "BELADEBEXXX", subject: "mock subject",
debitorName: "mock2", currency: "EUR",
subject: "mock subject", amount: "1",
currency: "EUR", uid: "mock",
amount: "1", direction: "CRDT",
uid: "mock", });
direction: "CRDT", await LibeufinNexusApi.fetchAllTransactions(nexus, "local-mock");
}
);
await LibeufinNexusApi.fetchAllTransactions(
nexus,
"local-mock"
);
let transactions = await LibeufinNexusApi.getAccountTransactions( let transactions = await LibeufinNexusApi.getAccountTransactions(
nexus, nexus,
"local-mock" "local-mock",
); );
let el = findNexusPayment("mock subject", transactions.data); let el = findNexusPayment("mock subject", transactions.data);
t.assertTrue(el instanceof Object); t.assertTrue(el instanceof Object);

View File

@ -38,34 +38,25 @@ export async function runLibeufinApiBankconnectionTest(t: GlobalTestState) {
await nexus.start(); await nexus.start();
await nexus.pingUntilAvailable(); await nexus.pingUntilAvailable();
await LibeufinNexusApi.createUser( await LibeufinNexusApi.createUser(nexus, {
nexus, username: "one",
{ password: "testing-the-bankconnection-api",
username: "one", });
password: "testing-the-bankconnection-api",
}
);
await LibeufinNexusApi.createEbicsBankConnection( await LibeufinNexusApi.createEbicsBankConnection(nexus, {
nexus, name: "bankconnection-api-test-connection",
{ ebicsURL: "http://localhost:5012/ebicsweb",
name: "bankconnection-api-test-connection", hostID: "mock",
ebicsURL: "http://localhost:5012/ebicsweb", userID: "mock",
hostID: "mock", partnerID: "mock",
userID: "mock", });
partnerID: "mock",
}
);
let connections = await LibeufinNexusApi.getAllConnections(nexus); let connections = await LibeufinNexusApi.getAllConnections(nexus);
t.assertTrue(connections.data["bankConnections"].length == 1); t.assertTrue(connections.data["bankConnections"].length == 1);
await LibeufinNexusApi.deleteBankConnection( await LibeufinNexusApi.deleteBankConnection(nexus, {
nexus, bankConnectionId: "bankconnection-api-test-connection",
{ });
bankConnectionId: "bankconnection-api-test-connection",
}
);
connections = await LibeufinNexusApi.getAllConnections(nexus); connections = await LibeufinNexusApi.getAllConnections(nexus);
t.assertTrue(connections.data["bankConnections"].length == 0); t.assertTrue(connections.data["bankConnections"].length == 0);
} }

View File

@ -43,15 +43,19 @@ export async function runLibeufinApiFacadeTest(t: GlobalTestState) {
* Launch Sandbox and Nexus. * Launch Sandbox and Nexus.
*/ */
const libeufinServices = await launchLibeufinServices( const libeufinServices = await launchLibeufinServices(
t, [user01nexus], [user01sandbox], t,
[user01nexus],
[user01sandbox],
);
let resp = await LibeufinNexusApi.getAllFacades(
libeufinServices.libeufinNexus,
); );
let resp = await LibeufinNexusApi.getAllFacades(libeufinServices.libeufinNexus);
// check that original facade shows up. // check that original facade shows up.
t.assertTrue(resp.data["facades"][0]["name"] == user01nexus.twgReq["name"]); t.assertTrue(resp.data["facades"][0]["name"] == user01nexus.twgReq["name"]);
// delete it. // delete it.
resp = await LibeufinNexusApi.deleteFacade( resp = await LibeufinNexusApi.deleteFacade(
libeufinServices.libeufinNexus, libeufinServices.libeufinNexus,
user01nexus.twgReq["name"] user01nexus.twgReq["name"],
); );
// check that no facades show up. // check that no facades show up.
t.assertTrue(!resp.data.hasOwnProperty("facades")); t.assertTrue(!resp.data.hasOwnProperty("facades"));

View File

@ -51,8 +51,8 @@ export async function runLibeufinApiPermissionsTest(t: GlobalTestState) {
let transferPermission = await LibeufinNexusApi.getAllPermissions(nexus); let transferPermission = await LibeufinNexusApi.getAllPermissions(nexus);
let element = transferPermission.data["permissions"].pop(); let element = transferPermission.data["permissions"].pop();
t.assertTrue( t.assertTrue(
element["permissionName"] == "facade.talerWireGateway.transfer" element["permissionName"] == "facade.talerWireGateway.transfer" &&
&& element["subjectId"] == "username-01" element["subjectId"] == "username-01",
); );
let denyTransfer = user01nexus.twgTransferPermission; let denyTransfer = user01nexus.twgTransferPermission;

View File

@ -40,7 +40,6 @@ export async function runLibeufinApiSchedulingTest(t: GlobalTestState) {
await nexus.start(); await nexus.start();
await nexus.pingUntilAvailable(); await nexus.pingUntilAvailable();
const user01nexus = new NexusUserBundle( const user01nexus = new NexusUserBundle(
"01", "01",
"http://localhost:5010/ebicsweb", "http://localhost:5010/ebicsweb",
@ -54,13 +53,25 @@ export async function runLibeufinApiSchedulingTest(t: GlobalTestState) {
params: { params: {
level: "all", level: "all",
rangeType: "all", rangeType: "all",
} },
}); });
let resp = await LibeufinNexusApi.getTasks(nexus, user01nexus.localAccountName, "test-task"); let resp = await LibeufinNexusApi.getTasks(
nexus,
user01nexus.localAccountName,
"test-task",
);
t.assertTrue(resp.data["taskName"] == "test-task"); t.assertTrue(resp.data["taskName"] == "test-task");
await LibeufinNexusApi.deleteTask(nexus, user01nexus.localAccountName, "test-task"); await LibeufinNexusApi.deleteTask(
nexus,
user01nexus.localAccountName,
"test-task",
);
try { try {
await LibeufinNexusApi.getTasks(nexus, user01nexus.localAccountName, "test-task"); await LibeufinNexusApi.getTasks(
nexus,
user01nexus.localAccountName,
"test-task",
);
} catch (err) { } catch (err) {
t.assertTrue(err.response.status == 404); t.assertTrue(err.response.status == 404);
} }
@ -72,11 +83,23 @@ export async function runLibeufinApiSchedulingTest(t: GlobalTestState) {
type: "submit", type: "submit",
params: {}, params: {},
}); });
resp = await LibeufinNexusApi.getTasks(nexus, user01nexus.localAccountName, "test-task"); resp = await LibeufinNexusApi.getTasks(
nexus,
user01nexus.localAccountName,
"test-task",
);
t.assertTrue(resp.data["taskName"] == "test-task"); t.assertTrue(resp.data["taskName"] == "test-task");
await LibeufinNexusApi.deleteTask(nexus, user01nexus.localAccountName, "test-task"); await LibeufinNexusApi.deleteTask(
nexus,
user01nexus.localAccountName,
"test-task",
);
try { try {
await LibeufinNexusApi.getTasks(nexus, user01nexus.localAccountName, "test-task"); await LibeufinNexusApi.getTasks(
nexus,
user01nexus.localAccountName,
"test-task",
);
} catch (err) { } catch (err) {
t.assertTrue(err.response.status == 404); t.assertTrue(err.response.status == 404);
} }

View File

@ -35,13 +35,10 @@ export async function runLibeufinApiUsersTest(t: GlobalTestState) {
await nexus.start(); await nexus.start();
await nexus.pingUntilAvailable(); await nexus.pingUntilAvailable();
await LibeufinNexusApi.createUser( await LibeufinNexusApi.createUser(nexus, {
nexus, username: "one",
{ password: "will-be-changed",
username: "one", });
password: "will-be-changed",
}
);
await LibeufinNexusApi.changePassword( await LibeufinNexusApi.changePassword(
nexus, nexus,
@ -52,19 +49,16 @@ export async function runLibeufinApiUsersTest(t: GlobalTestState) {
auth: { auth: {
username: "one", username: "one",
password: "will-be-changed", password: "will-be-changed",
} },
}, },
); );
let resp = await LibeufinNexusApi.getUser( let resp = await LibeufinNexusApi.getUser(nexus, {
nexus, auth: {
{ username: "one",
auth: { password: "got-changed",
username: "one", },
password: "got-changed", });
}
}
);
console.log(resp.data); console.log(resp.data);
t.assertTrue(resp.data["username"] == "one" && !resp.data["superuser"]); t.assertTrue(resp.data["username"] == "one" && !resp.data["superuser"]);
} }

View File

@ -90,15 +90,15 @@ export async function runLibeufinRefundMultipleUsersTest(t: GlobalTestState) {
libeufinServices.libeufinNexus, libeufinServices.libeufinNexus,
user02nexus.localAccountName, user02nexus.localAccountName,
"1", // so far the only one that can exist. "1", // so far the only one that can exist.
); );
// Counterpart checks whether the reimbursement shows up. // Counterpart checks whether the reimbursement shows up.
let history = await LibeufinSandboxApi.getAccountTransactions( let history = await LibeufinSandboxApi.getAccountTransactions(
libeufinServices.libeufinSandbox, libeufinServices.libeufinSandbox,
user01sandbox.ebicsBankAccount["label"] user01sandbox.ebicsBankAccount["label"],
); );
t.assertTrue(history["payments"].length == 1) t.assertTrue(history["payments"].length == 1);
} }
runLibeufinRefundMultipleUsersTest.suites = ["libeufin"]; runLibeufinRefundMultipleUsersTest.suites = ["libeufin"];

View File

@ -80,14 +80,14 @@ export async function runLibeufinRefundTest(t: GlobalTestState) {
libeufinServices.libeufinNexus, libeufinServices.libeufinNexus,
user02nexus.localAccountName, user02nexus.localAccountName,
"1", // so far the only one that can exist. "1", // so far the only one that can exist.
); );
// Counterpart checks whether the reimbursement shows up. // Counterpart checks whether the reimbursement shows up.
let history = await LibeufinSandboxApi.getAccountTransactions( let history = await LibeufinSandboxApi.getAccountTransactions(
libeufinServices.libeufinSandbox, libeufinServices.libeufinSandbox,
user01sandbox.ebicsBankAccount["label"] user01sandbox.ebicsBankAccount["label"],
); );
t.assertTrue(history["payments"].length == 1) t.assertTrue(history["payments"].length == 1);
} }
runLibeufinRefundTest.suites = ["libeufin"]; runLibeufinRefundTest.suites = ["libeufin"];

View File

@ -109,7 +109,6 @@ export async function createConfusedMerchantTestkudosEnvironment(
paytoUris: [`payto://x-taler-bank/merchant-default`], paytoUris: [`payto://x-taler-bank/merchant-default`],
}); });
await merchant.addInstance({ await merchant.addInstance({
id: "minst1", id: "minst1",
name: "minst1", name: "minst1",

View File

@ -30,10 +30,7 @@ import {
withdrawViaBank, withdrawViaBank,
SimpleTestEnvironment, SimpleTestEnvironment,
} from "./helpers"; } from "./helpers";
import { import { durationFromSpec, PreparePayResultType } from "@gnu-taler/taler-util";
durationFromSpec,
PreparePayResultType,
} from "@gnu-taler/taler-util";
import axios from "axios"; import axios from "axios";
import { URL } from "@gnu-taler/taler-wallet-core"; import { URL } from "@gnu-taler/taler-wallet-core";

View File

@ -23,9 +23,7 @@
* Imports. * Imports.
*/ */
import { PreparePayResultType, TalerErrorCode } from "@gnu-taler/taler-util"; import { PreparePayResultType, TalerErrorCode } from "@gnu-taler/taler-util";
import { import { URL } from "@gnu-taler/taler-wallet-core";
URL,
} from "@gnu-taler/taler-wallet-core";
import { import {
FaultInjectionRequestContext, FaultInjectionRequestContext,
FaultInjectionResponseContext, FaultInjectionResponseContext,
@ -152,4 +150,4 @@ export async function runPayAbortTest(t: GlobalTestState) {
t.assertDeepEqual(txTypes, ["withdrawal", "payment", "refund"]); t.assertDeepEqual(txTypes, ["withdrawal", "payment", "refund"]);
} }
runPayAbortTest.suites = ["wallet"]; runPayAbortTest.suites = ["wallet"];

View File

@ -232,4 +232,4 @@ export async function runPaywallFlowTest(t: GlobalTestState) {
t.assertTrue(pubUnpaidStatus.already_paid_order_id === firstOrderId); t.assertTrue(pubUnpaidStatus.already_paid_order_id === firstOrderId);
} }
runPaywallFlowTest.suites = ["wallet"]; runPaywallFlowTest.suites = ["wallet"];

View File

@ -99,4 +99,4 @@ export async function runRefundAutoTest(t: GlobalTestState) {
await t.shutdown(); await t.shutdown();
} }
runRefundAutoTest.suites = ["wallet"]; runRefundAutoTest.suites = ["wallet"];

View File

@ -126,4 +126,4 @@ export async function runRefundGoneTest(t: GlobalTestState) {
await t.shutdown(); await t.shutdown();
} }
runRefundGoneTest.suites = ["wallet"]; runRefundGoneTest.suites = ["wallet"];

View File

@ -189,4 +189,4 @@ export async function runRefundIncrementalTest(t: GlobalTestState) {
await t.shutdown(); await t.shutdown();
} }
runRefundIncrementalTest.suites = ["wallet"]; runRefundIncrementalTest.suites = ["wallet"];

View File

@ -135,7 +135,7 @@ const allTests: TestMainFunction[] = [
export interface TestRunSpec { export interface TestRunSpec {
includePattern?: string; includePattern?: string;
suiteSpec?: string; suiteSpec?: string;
dryRun?: boolean, dryRun?: boolean;
} }
export interface TestInfo { export interface TestInfo {

View File

@ -222,7 +222,7 @@ export class CryptoImplementation {
.put(decodeCrock(req.merchantPub)) .put(decodeCrock(req.merchantPub))
.put(decodeCrock(req.coinPub)) .put(decodeCrock(req.coinPub))
.build(); .build();
return encodeCrock(eddsaSign(p, decodeCrock(req.merchantPriv))); return encodeCrock(eddsaSign(p, decodeCrock(req.merchantPriv)));
} }
/** /**

View File

@ -92,8 +92,10 @@ export function handleWorkerMessage(msg: any): void {
try { try {
const result = (impl as any)[operation](...args); const result = (impl as any)[operation](...args);
// eslint-disable-next-line @typescript-eslint/no-var-requires // eslint-disable-next-line @typescript-eslint/no-var-requires
const _r = "require" const _r = "require";
const worker_threads: typeof import("worker_threads") = module[_r]("worker_threads"); const worker_threads: typeof import("worker_threads") = module[_r](
"worker_threads",
);
// const worker_threads = require("worker_threads"); // const worker_threads = require("worker_threads");
const p = worker_threads.parentPort; const p = worker_threads.parentPort;
@ -149,7 +151,7 @@ class NodeThreadCryptoWorker implements CryptoWorker {
constructor() { constructor() {
// eslint-disable-next-line @typescript-eslint/no-var-requires // eslint-disable-next-line @typescript-eslint/no-var-requires
const _r = "require" const _r = "require";
const worker_threads = module[_r]("worker_threads"); const worker_threads = module[_r]("worker_threads");
logger.trace("starting node crypto worker"); logger.trace("starting node crypto worker");

View File

@ -169,7 +169,6 @@ export async function openTalerDatabase(
return new DbAccess(mainDbHandle, WalletStoresV1); return new DbAccess(mainDbHandle, WalletStoresV1);
} }
export function deleteTalerDatabase(idbFactory: IDBFactory): void { export function deleteTalerDatabase(idbFactory: IDBFactory): void {
idbFactory.deleteDatabase(TALER_DB_NAME); idbFactory.deleteDatabase(TALER_DB_NAME);
} }

View File

@ -41,18 +41,18 @@ const logger = new Logger("headless/helpers.ts");
const nodejs_fs = (function () { const nodejs_fs = (function () {
let fs: typeof import("fs"); let fs: typeof import("fs");
return function() { return function () {
if (!fs) { if (!fs) {
/** /**
* need to use an expression when doing a require if we want * need to use an expression when doing a require if we want
* webpack not to find out about the requirement * webpack not to find out about the requirement
*/ */
const _r = "require" const _r = "require";
fs = module[_r]("fs") fs = module[_r]("fs");
} }
return fs return fs;
} };
})() })();
export interface DefaultNodeWalletArgs { export interface DefaultNodeWalletArgs {
/** /**
@ -123,9 +123,13 @@ export async function getDefaultNodeWallet(
} }
const tmpPath = `${args.persistentStoragePath}-${makeId(5)}.tmp`; const tmpPath = `${args.persistentStoragePath}-${makeId(5)}.tmp`;
const dbContent = myBackend.exportDump(); const dbContent = myBackend.exportDump();
nodejs_fs().writeFileSync(tmpPath, JSON.stringify(dbContent, undefined, 2), { nodejs_fs().writeFileSync(
encoding: "utf-8", tmpPath,
}); JSON.stringify(dbContent, undefined, 2),
{
encoding: "utf-8",
},
);
// Atomically move the temporary file onto the DB path. // Atomically move the temporary file onto the DB path.
nodejs_fs().renameSync(tmpPath, args.persistentStoragePath); nodejs_fs().renameSync(tmpPath, args.persistentStoragePath);
}; };
@ -157,7 +161,7 @@ export async function getDefaultNodeWallet(
let workerFactory; let workerFactory;
try { try {
// Try if we have worker threads available, fails in older node versions. // Try if we have worker threads available, fails in older node versions.
const _r = "require" const _r = "require";
const worker_threads = module[_r]("worker_threads"); const worker_threads = module[_r]("worker_threads");
// require("worker_threads"); // require("worker_threads");
workerFactory = new NodeThreadCryptoWorkerFactory(); workerFactory = new NodeThreadCryptoWorkerFactory();

View File

@ -17,7 +17,12 @@
/** /**
* Imports. * Imports.
*/ */
import { AmountJson, BalancesResponse, Amounts, Logger } from "@gnu-taler/taler-util"; import {
AmountJson,
BalancesResponse,
Amounts,
Logger,
} from "@gnu-taler/taler-util";
import { CoinStatus, WalletStoresV1 } from "../db.js"; import { CoinStatus, WalletStoresV1 } from "../db.js";
import { GetReadOnlyAccess } from "../util/query.js"; import { GetReadOnlyAccess } from "../util/query.js";

View File

@ -1649,8 +1649,9 @@ export async function refuseProposal(
ws: InternalWalletState, ws: InternalWalletState,
proposalId: string, proposalId: string,
): Promise<void> { ): Promise<void> {
const success = await ws.db.mktx((x) => ({proposals: x.proposals})).runReadWrite( const success = await ws.db
async (tx) => { .mktx((x) => ({ proposals: x.proposals }))
.runReadWrite(async (tx) => {
const proposal = await tx.proposals.get(proposalId); const proposal = await tx.proposals.get(proposalId);
if (!proposal) { if (!proposal) {
logger.trace(`proposal ${proposalId} not found, won't refuse proposal`); logger.trace(`proposal ${proposalId} not found, won't refuse proposal`);
@ -1662,8 +1663,7 @@ export async function refuseProposal(
proposal.proposalStatus = ProposalStatus.REFUSED; proposal.proposalStatus = ProposalStatus.REFUSED;
await tx.proposals.put(proposal); await tx.proposals.put(proposal);
return true; return true;
}, });
);
if (success) { if (success) {
ws.notify({ ws.notify({
type: NotificationType.ProposalRefused, type: NotificationType.ProposalRefused,

View File

@ -239,7 +239,7 @@ async function gatherRefreshPending(
async function gatherWithdrawalPending( async function gatherWithdrawalPending(
tx: GetReadOnlyAccess<{ tx: GetReadOnlyAccess<{
withdrawalGroups: typeof WalletStoresV1.withdrawalGroups; withdrawalGroups: typeof WalletStoresV1.withdrawalGroups;
planchets: typeof WalletStoresV1.planchets, planchets: typeof WalletStoresV1.planchets;
}>, }>,
now: Timestamp, now: Timestamp,
resp: PendingOperationsResponse, resp: PendingOperationsResponse,
@ -464,21 +464,22 @@ export async function getPendingOperations(
{ onlyDue = false } = {}, { onlyDue = false } = {},
): Promise<PendingOperationsResponse> { ): Promise<PendingOperationsResponse> {
const now = getTimestampNow(); const now = getTimestampNow();
return await ws.db.mktx((x) => ({ return await ws.db
exchanges: x.exchanges, .mktx((x) => ({
exchangeDetails: x.exchangeDetails, exchanges: x.exchanges,
reserves: x.reserves, exchangeDetails: x.exchangeDetails,
refreshGroups: x.refreshGroups, reserves: x.reserves,
coins: x.coins, refreshGroups: x.refreshGroups,
withdrawalGroups: x.withdrawalGroups, coins: x.coins,
proposals: x.proposals, withdrawalGroups: x.withdrawalGroups,
tips: x.tips, proposals: x.proposals,
purchases: x.purchases, tips: x.tips,
planchets: x.planchets, purchases: x.purchases,
depositGroups: x.depositGroups, planchets: x.planchets,
recoupGroups: x.recoupGroups, depositGroups: x.depositGroups,
})).runReadWrite( recoupGroups: x.recoupGroups,
async (tx) => { }))
.runReadWrite(async (tx) => {
const walletBalance = await getBalancesInsideTransaction(ws, tx); const walletBalance = await getBalancesInsideTransaction(ws, tx);
const resp: PendingOperationsResponse = { const resp: PendingOperationsResponse = {
nextRetryDelay: { d_ms: Number.MAX_SAFE_INTEGER }, nextRetryDelay: { d_ms: Number.MAX_SAFE_INTEGER },
@ -496,6 +497,5 @@ export async function getPendingOperations(
await gatherRecoupPending(tx, now, resp, onlyDue); await gatherRecoupPending(tx, now, resp, onlyDue);
await gatherDepositPending(tx, now, resp, onlyDue); await gatherDepositPending(tx, now, resp, onlyDue);
return resp; return resp;
}, });
);
} }

View File

@ -23,7 +23,16 @@ import {
readSuccessResponseJsonOrThrow, readSuccessResponseJsonOrThrow,
checkSuccessResponseOrThrow, checkSuccessResponseOrThrow,
} from "../util/http"; } from "../util/http";
import { AmountString, codecForAny, CheckPaymentResponse, codecForCheckPaymentResponse, IntegrationTestArgs, Amounts, TestPayArgs, PreparePayResultType } from "@gnu-taler/taler-util"; import {
AmountString,
codecForAny,
CheckPaymentResponse,
codecForCheckPaymentResponse,
IntegrationTestArgs,
Amounts,
TestPayArgs,
PreparePayResultType,
} from "@gnu-taler/taler-util";
import { URL } from "../index.js"; import { URL } from "../index.js";
import { Wallet } from "../wallet.js"; import { Wallet } from "../wallet.js";
import { createTalerWithdrawReserve } from "./reserves.js"; import { createTalerWithdrawReserve } from "./reserves.js";
@ -102,8 +111,8 @@ export async function withdrawTestBalance(
function getMerchantAuthHeader(m: MerchantBackendInfo): Record<string, string> { function getMerchantAuthHeader(m: MerchantBackendInfo): Record<string, string> {
if (m.authToken) { if (m.authToken) {
return { return {
"Authorization": `Bearer ${m.authToken}`, Authorization: `Bearer ${m.authToken}`,
} };
} }
return {}; return {};
} }

View File

@ -24,7 +24,12 @@
/** /**
* Imports. * Imports.
*/ */
import { TalerErrorDetails, BalancesResponse, Duration, Timestamp } from "@gnu-taler/taler-util"; import {
TalerErrorDetails,
BalancesResponse,
Duration,
Timestamp,
} from "@gnu-taler/taler-util";
import { ReserveRecordStatus } from "./db.js"; import { ReserveRecordStatus } from "./db.js";
import { RetryInfo } from "./util/retries.js"; import { RetryInfo } from "./util/retries.js";