formatting: re-run prettier
This commit is contained in:
parent
5c26461247
commit
3d2b7b2a65
@ -220,5 +220,5 @@ export interface Backend {
|
||||
clearObjectStore(
|
||||
btx: DatabaseTransaction,
|
||||
objectStoreName: string,
|
||||
): Promise<void>
|
||||
): Promise<void>;
|
||||
}
|
||||
|
@ -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 following tests are intentionally not included:
|
||||
* error-attributes.html (assumes we have a DOM)
|
||||
* file_support.sub.html (assumes we have a DOM)
|
||||
* fire-error-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)
|
||||
|
||||
- error-attributes.html (assumes we have a DOM)
|
||||
- file_support.sub.html (assumes we have a DOM)
|
||||
- fire-error-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:
|
||||
|
||||
|
@ -28,76 +28,85 @@ test.cb("WPT test cursor-overloads.htm", (t) => {
|
||||
|
||||
await checkCursorDirection(store.openCursor(), "next");
|
||||
await checkCursorDirection(store.openCursor(0), "next");
|
||||
await checkCursorDirection(store.openCursor(0, 'next'), "next");
|
||||
await checkCursorDirection(store.openCursor(0, 'nextunique'), "nextunique");
|
||||
await checkCursorDirection(store.openCursor(0, 'prev'), "prev");
|
||||
await checkCursorDirection(store.openCursor(0, 'prevunique'), "prevunique");
|
||||
await checkCursorDirection(store.openCursor(0, "next"), "next");
|
||||
await checkCursorDirection(store.openCursor(0, "nextunique"), "nextunique");
|
||||
await checkCursorDirection(store.openCursor(0, "prev"), "prev");
|
||||
await checkCursorDirection(store.openCursor(0, "prevunique"), "prevunique");
|
||||
|
||||
await checkCursorDirection(store.openCursor(IDBKeyRange.only(0)), "next");
|
||||
await checkCursorDirection(
|
||||
store.openCursor(BridgeIDBKeyRange.only(0), 'next'),
|
||||
store.openCursor(BridgeIDBKeyRange.only(0), "next"),
|
||||
"next",
|
||||
);
|
||||
await checkCursorDirection(
|
||||
store.openCursor(IDBKeyRange.only(0), 'nextunique'),
|
||||
store.openCursor(IDBKeyRange.only(0), "nextunique"),
|
||||
"nextunique",
|
||||
);
|
||||
await checkCursorDirection(
|
||||
store.openCursor(IDBKeyRange.only(0), 'prev'),
|
||||
store.openCursor(IDBKeyRange.only(0), "prev"),
|
||||
"prev",
|
||||
);
|
||||
await checkCursorDirection(
|
||||
store.openCursor(IDBKeyRange.only(0), 'prevunique'),
|
||||
store.openCursor(IDBKeyRange.only(0), "prevunique"),
|
||||
"prevunique",
|
||||
);
|
||||
|
||||
await checkCursorDirection(index.openCursor(), "next");
|
||||
await checkCursorDirection(index.openCursor(0), "next");
|
||||
await checkCursorDirection(index.openCursor(0, 'next'), "next");
|
||||
await checkCursorDirection(index.openCursor(0, 'nextunique'), "nextunique");
|
||||
await checkCursorDirection(index.openCursor(0, 'prev'), "prev");
|
||||
await checkCursorDirection(index.openCursor(0, 'prevunique'), "prevunique");
|
||||
await checkCursorDirection(index.openCursor(0, "next"), "next");
|
||||
await checkCursorDirection(index.openCursor(0, "nextunique"), "nextunique");
|
||||
await checkCursorDirection(index.openCursor(0, "prev"), "prev");
|
||||
await checkCursorDirection(index.openCursor(0, "prevunique"), "prevunique");
|
||||
|
||||
await checkCursorDirection(index.openCursor(IDBKeyRange.only(0)), "next");
|
||||
await checkCursorDirection(
|
||||
index.openCursor(IDBKeyRange.only(0), 'next'),
|
||||
index.openCursor(IDBKeyRange.only(0), "next"),
|
||||
"next",
|
||||
);
|
||||
await checkCursorDirection(
|
||||
index.openCursor(IDBKeyRange.only(0), 'nextunique'),
|
||||
index.openCursor(IDBKeyRange.only(0), "nextunique"),
|
||||
"nextunique",
|
||||
);
|
||||
await checkCursorDirection(
|
||||
index.openCursor(IDBKeyRange.only(0), 'prev'),
|
||||
index.openCursor(IDBKeyRange.only(0), "prev"),
|
||||
"prev",
|
||||
);
|
||||
await checkCursorDirection(
|
||||
index.openCursor(IDBKeyRange.only(0), 'prevunique'),
|
||||
index.openCursor(IDBKeyRange.only(0), "prevunique"),
|
||||
"prevunique",
|
||||
);
|
||||
|
||||
await checkCursorDirection(index.openKeyCursor(), "next");
|
||||
await checkCursorDirection(index.openKeyCursor(0), "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(index.openKeyCursor(0, "next"), "next");
|
||||
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",
|
||||
);
|
||||
await checkCursorDirection(
|
||||
index.openKeyCursor(IDBKeyRange.only(0), 'nextunique'),
|
||||
index.openKeyCursor(IDBKeyRange.only(0), "next"),
|
||||
"next",
|
||||
);
|
||||
await checkCursorDirection(
|
||||
index.openKeyCursor(IDBKeyRange.only(0), "nextunique"),
|
||||
"nextunique",
|
||||
);
|
||||
await checkCursorDirection(
|
||||
index.openKeyCursor(IDBKeyRange.only(0), 'prev'),
|
||||
index.openKeyCursor(IDBKeyRange.only(0), "prev"),
|
||||
"prev",
|
||||
);
|
||||
await checkCursorDirection(
|
||||
index.openKeyCursor(IDBKeyRange.only(0), 'prevunique'),
|
||||
index.openKeyCursor(IDBKeyRange.only(0), "prevunique"),
|
||||
"prevunique",
|
||||
);
|
||||
|
||||
@ -110,7 +119,11 @@ test.cb("WPT test cursor-overloads.htm", (t) => {
|
||||
): Promise<void> {
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
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(
|
||||
event.target.result.direction,
|
||||
direction,
|
||||
|
@ -182,9 +182,7 @@ export type ReserveTransaction =
|
||||
| ReserveClosingTransaction
|
||||
| ReserveRecoupTransaction;
|
||||
|
||||
export const codecForReserveWithdrawTransaction = (): Codec<
|
||||
ReserveWithdrawTransaction
|
||||
> =>
|
||||
export const codecForReserveWithdrawTransaction = (): Codec<ReserveWithdrawTransaction> =>
|
||||
buildCodecForObject<ReserveWithdrawTransaction>()
|
||||
.property("amount", codecForString())
|
||||
.property("h_coin_envelope", codecForString())
|
||||
@ -194,9 +192,7 @@ export const codecForReserveWithdrawTransaction = (): Codec<
|
||||
.property("withdraw_fee", codecForString())
|
||||
.build("ReserveWithdrawTransaction");
|
||||
|
||||
export const codecForReserveCreditTransaction = (): Codec<
|
||||
ReserveCreditTransaction
|
||||
> =>
|
||||
export const codecForReserveCreditTransaction = (): Codec<ReserveCreditTransaction> =>
|
||||
buildCodecForObject<ReserveCreditTransaction>()
|
||||
.property("amount", codecForString())
|
||||
.property("sender_account_url", codecForString())
|
||||
@ -205,9 +201,7 @@ export const codecForReserveCreditTransaction = (): Codec<
|
||||
.property("type", codecForConstString(ReserveTransactionType.Credit))
|
||||
.build("ReserveCreditTransaction");
|
||||
|
||||
export const codecForReserveClosingTransaction = (): Codec<
|
||||
ReserveClosingTransaction
|
||||
> =>
|
||||
export const codecForReserveClosingTransaction = (): Codec<ReserveClosingTransaction> =>
|
||||
buildCodecForObject<ReserveClosingTransaction>()
|
||||
.property("amount", codecForString())
|
||||
.property("closing_fee", codecForString())
|
||||
@ -219,9 +213,7 @@ export const codecForReserveClosingTransaction = (): Codec<
|
||||
.property("wtid", codecForString())
|
||||
.build("ReserveClosingTransaction");
|
||||
|
||||
export const codecForReserveRecoupTransaction = (): Codec<
|
||||
ReserveRecoupTransaction
|
||||
> =>
|
||||
export const codecForReserveRecoupTransaction = (): Codec<ReserveRecoupTransaction> =>
|
||||
buildCodecForObject<ReserveRecoupTransaction>()
|
||||
.property("amount", codecForString())
|
||||
.property("coin_pub", codecForString())
|
||||
|
@ -17,13 +17,25 @@ import test from "ava";
|
||||
import * as helpers from "./helpers";
|
||||
test("URL canonicalization", (t) => {
|
||||
// converts to relative, adds https
|
||||
t.is("https://alice.example.com/exchange/", helpers.canonicalizeBaseUrl("alice.example.com/exchange"));
|
||||
t.is(
|
||||
"https://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"));
|
||||
t.is(
|
||||
"http://alice.example.com/exchange/",
|
||||
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"));
|
||||
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.is(
|
||||
"http://alice.example.com/exchange/",
|
||||
helpers.canonicalizeBaseUrl("http://alice.example.com/exchange?foo=bar"),
|
||||
);
|
||||
t.pass();
|
||||
});
|
||||
//# sourceMappingURL=helpers.test.js.map
|
@ -68,11 +68,7 @@ export function canonicalJson(obj: any): string {
|
||||
return "\\u" + ("0000" + chr.charCodeAt(0).toString(16)).substr(-4);
|
||||
});
|
||||
}
|
||||
if (
|
||||
typeof obj === "number" ||
|
||||
typeof obj === "boolean" ||
|
||||
obj === null
|
||||
) {
|
||||
if (typeof obj === "number" || typeof obj === "boolean" || obj === null) {
|
||||
return JSON.stringify(obj);
|
||||
}
|
||||
if (Array.isArray(obj)) {
|
||||
|
@ -17,7 +17,7 @@ export function setupI18n(lang: string, strings: { [s: string]: any }): any {
|
||||
lang = "en-US";
|
||||
logger.warn(`language ${lang} not found, defaulting to english`);
|
||||
}
|
||||
debugger
|
||||
debugger;
|
||||
jed = new jedLib.Jed(strings[lang]);
|
||||
}
|
||||
|
||||
@ -58,11 +58,14 @@ export function str(stringSeq: TemplateStringsArray, ...values: any[]): string {
|
||||
/**
|
||||
* 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);
|
||||
if (!s) return []
|
||||
if (!s) return [];
|
||||
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 {
|
||||
const c = [].concat(children);
|
||||
const s = stringifyArray(c);
|
||||
if (!s) return []
|
||||
if (!s) return [];
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
function replacePlaceholderWithValues(
|
||||
translation: string,
|
||||
childArray: Array<any>,
|
||||
@ -142,6 +144,5 @@ function stringifyArray(children: Array<any>): string {
|
||||
export const i18n = {
|
||||
str,
|
||||
Translate,
|
||||
translate
|
||||
}
|
||||
|
||||
translate,
|
||||
};
|
||||
|
@ -19,7 +19,9 @@
|
||||
*/
|
||||
|
||||
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(
|
||||
message: any,
|
||||
|
@ -22,8 +22,6 @@
|
||||
*/
|
||||
|
||||
export enum TalerErrorCode {
|
||||
|
||||
|
||||
/**
|
||||
* Special code to indicate success (no error).
|
||||
* 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).
|
||||
*/
|
||||
END = 9999,
|
||||
|
||||
}
|
||||
|
@ -989,9 +989,7 @@ export interface BankWithdrawalOperationPostResponse {
|
||||
transfer_done: boolean;
|
||||
}
|
||||
|
||||
export const codecForBankWithdrawalOperationPostResponse = (): Codec<
|
||||
BankWithdrawalOperationPostResponse
|
||||
> =>
|
||||
export const codecForBankWithdrawalOperationPostResponse = (): Codec<BankWithdrawalOperationPostResponse> =>
|
||||
buildCodecForObject<BankWithdrawalOperationPostResponse>()
|
||||
.property("transfer_done", codecForBoolean())
|
||||
.build("BankWithdrawalOperationPostResponse");
|
||||
@ -1070,9 +1068,8 @@ export const codecForTax = (): Codec<Tax> =>
|
||||
.property("tax", codecForString())
|
||||
.build("Tax");
|
||||
|
||||
export const codecForInternationalizedString = (): Codec<
|
||||
InternationalizedString
|
||||
> => codecForMap(codecForString());
|
||||
export const codecForInternationalizedString = (): Codec<InternationalizedString> =>
|
||||
codecForMap(codecForString());
|
||||
|
||||
export const codecForProduct = (): Codec<Product> =>
|
||||
buildCodecForObject<Product>()
|
||||
@ -1120,9 +1117,7 @@ export const codecForContractTerms = (): Codec<ContractTerms> =>
|
||||
.property("extra", codecForAny())
|
||||
.build("ContractTerms");
|
||||
|
||||
export const codecForMerchantRefundPermission = (): Codec<
|
||||
MerchantAbortPayRefundDetails
|
||||
> =>
|
||||
export const codecForMerchantRefundPermission = (): Codec<MerchantAbortPayRefundDetails> =>
|
||||
buildCodecForObject<MerchantAbortPayRefundDetails>()
|
||||
.property("refund_amount", codecForAmountString())
|
||||
.property("refund_fee", codecForAmountString())
|
||||
@ -1135,9 +1130,7 @@ export const codecForMerchantRefundPermission = (): Codec<
|
||||
.property("exchange_pub", codecOptional(codecForString()))
|
||||
.build("MerchantRefundPermission");
|
||||
|
||||
export const codecForMerchantRefundResponse = (): Codec<
|
||||
MerchantRefundResponse
|
||||
> =>
|
||||
export const codecForMerchantRefundResponse = (): Codec<MerchantRefundResponse> =>
|
||||
buildCodecForObject<MerchantRefundResponse>()
|
||||
.property("merchant_pub", codecForString())
|
||||
.property("h_contract_terms", codecForString())
|
||||
@ -1217,9 +1210,7 @@ export const codecForCheckPaymentResponse = (): Codec<CheckPaymentResponse> =>
|
||||
.property("contract_url", codecOptional(codecForString()))
|
||||
.build("CheckPaymentResponse");
|
||||
|
||||
export const codecForWithdrawOperationStatusResponse = (): Codec<
|
||||
WithdrawOperationStatusResponse
|
||||
> =>
|
||||
export const codecForWithdrawOperationStatusResponse = (): Codec<WithdrawOperationStatusResponse> =>
|
||||
buildCodecForObject<WithdrawOperationStatusResponse>()
|
||||
.property("selection_done", codecForBoolean())
|
||||
.property("transfer_done", codecForBoolean())
|
||||
@ -1267,16 +1258,12 @@ export const codecForExchangeRevealItem = (): Codec<ExchangeRevealItem> =>
|
||||
.property("ev_sig", codecForString())
|
||||
.build("ExchangeRevealItem");
|
||||
|
||||
export const codecForExchangeRevealResponse = (): Codec<
|
||||
ExchangeRevealResponse
|
||||
> =>
|
||||
export const codecForExchangeRevealResponse = (): Codec<ExchangeRevealResponse> =>
|
||||
buildCodecForObject<ExchangeRevealResponse>()
|
||||
.property("ev_sigs", codecForList(codecForExchangeRevealItem()))
|
||||
.build("ExchangeRevealResponse");
|
||||
|
||||
export const codecForMerchantCoinRefundSuccessStatus = (): Codec<
|
||||
MerchantCoinRefundSuccessStatus
|
||||
> =>
|
||||
export const codecForMerchantCoinRefundSuccessStatus = (): Codec<MerchantCoinRefundSuccessStatus> =>
|
||||
buildCodecForObject<MerchantCoinRefundSuccessStatus>()
|
||||
.property("type", codecForConstString("success"))
|
||||
.property("coin_pub", codecForString())
|
||||
@ -1288,9 +1275,7 @@ export const codecForMerchantCoinRefundSuccessStatus = (): Codec<
|
||||
.property("execution_time", codecForTimestamp)
|
||||
.build("MerchantCoinRefundSuccessStatus");
|
||||
|
||||
export const codecForMerchantCoinRefundFailureStatus = (): Codec<
|
||||
MerchantCoinRefundFailureStatus
|
||||
> =>
|
||||
export const codecForMerchantCoinRefundFailureStatus = (): Codec<MerchantCoinRefundFailureStatus> =>
|
||||
buildCodecForObject<MerchantCoinRefundFailureStatus>()
|
||||
.property("type", codecForConstString("failure"))
|
||||
.property("coin_pub", codecForString())
|
||||
@ -1302,35 +1287,27 @@ export const codecForMerchantCoinRefundFailureStatus = (): Codec<
|
||||
.property("execution_time", codecForTimestamp)
|
||||
.build("MerchantCoinRefundFailureStatus");
|
||||
|
||||
export const codecForMerchantCoinRefundStatus = (): Codec<
|
||||
MerchantCoinRefundStatus
|
||||
> =>
|
||||
export const codecForMerchantCoinRefundStatus = (): Codec<MerchantCoinRefundStatus> =>
|
||||
buildCodecForUnion<MerchantCoinRefundStatus>()
|
||||
.discriminateOn("type")
|
||||
.alternative("success", codecForMerchantCoinRefundSuccessStatus())
|
||||
.alternative("failure", codecForMerchantCoinRefundFailureStatus())
|
||||
.build("MerchantCoinRefundStatus");
|
||||
|
||||
export const codecForMerchantOrderStatusPaid = (): Codec<
|
||||
MerchantOrderStatusPaid
|
||||
> =>
|
||||
export const codecForMerchantOrderStatusPaid = (): Codec<MerchantOrderStatusPaid> =>
|
||||
buildCodecForObject<MerchantOrderStatusPaid>()
|
||||
.property("refund_amount", codecForString())
|
||||
.property("refunded", codecForBoolean())
|
||||
.build("MerchantOrderStatusPaid");
|
||||
|
||||
export const codecForMerchantOrderRefundPickupResponse = (): Codec<
|
||||
MerchantOrderRefundResponse
|
||||
> =>
|
||||
export const codecForMerchantOrderRefundPickupResponse = (): Codec<MerchantOrderRefundResponse> =>
|
||||
buildCodecForObject<MerchantOrderRefundResponse>()
|
||||
.property("merchant_pub", codecForString())
|
||||
.property("refund_amount", codecForString())
|
||||
.property("refunds", codecForList(codecForMerchantCoinRefundStatus()))
|
||||
.build("MerchantOrderRefundPickupResponse");
|
||||
|
||||
export const codecForMerchantOrderStatusUnpaid = (): Codec<
|
||||
MerchantOrderStatusUnpaid
|
||||
> =>
|
||||
export const codecForMerchantOrderStatusUnpaid = (): Codec<MerchantOrderStatusUnpaid> =>
|
||||
buildCodecForObject<MerchantOrderStatusUnpaid>()
|
||||
.property("taler_pay_uri", codecForString())
|
||||
.property("already_paid_order_id", codecOptional(codecForString()))
|
||||
@ -1412,9 +1389,7 @@ export interface MerchantAbortPayRefundSuccessStatus {
|
||||
exchange_pub: string;
|
||||
}
|
||||
|
||||
export const codecForMerchantAbortPayRefundSuccessStatus = (): Codec<
|
||||
MerchantAbortPayRefundSuccessStatus
|
||||
> =>
|
||||
export const codecForMerchantAbortPayRefundSuccessStatus = (): Codec<MerchantAbortPayRefundSuccessStatus> =>
|
||||
buildCodecForObject<MerchantAbortPayRefundSuccessStatus>()
|
||||
.property("exchange_pub", codecForString())
|
||||
.property("exchange_sig", codecForString())
|
||||
@ -1422,9 +1397,7 @@ export const codecForMerchantAbortPayRefundSuccessStatus = (): Codec<
|
||||
.property("type", codecForConstString("success"))
|
||||
.build("MerchantAbortPayRefundSuccessStatus");
|
||||
|
||||
export const codecForMerchantAbortPayRefundFailureStatus = (): Codec<
|
||||
MerchantAbortPayRefundFailureStatus
|
||||
> =>
|
||||
export const codecForMerchantAbortPayRefundFailureStatus = (): Codec<MerchantAbortPayRefundFailureStatus> =>
|
||||
buildCodecForObject<MerchantAbortPayRefundFailureStatus>()
|
||||
.property("exchange_code", codecForNumber())
|
||||
.property("exchange_reply", codecForAny())
|
||||
@ -1432,9 +1405,7 @@ export const codecForMerchantAbortPayRefundFailureStatus = (): Codec<
|
||||
.property("type", codecForConstString("failure"))
|
||||
.build("MerchantAbortPayRefundFailureStatus");
|
||||
|
||||
export const codecForMerchantAbortPayRefundStatus = (): Codec<
|
||||
MerchantAbortPayRefundStatus
|
||||
> =>
|
||||
export const codecForMerchantAbortPayRefundStatus = (): Codec<MerchantAbortPayRefundStatus> =>
|
||||
buildCodecForUnion<MerchantAbortPayRefundStatus>()
|
||||
.discriminateOn("type")
|
||||
.alternative("success", codecForMerchantAbortPayRefundSuccessStatus())
|
||||
|
@ -28,18 +28,18 @@ import { Amounts } from "./amounts.js";
|
||||
|
||||
const nodejs_fs = (function () {
|
||||
let fs: typeof import("fs");
|
||||
return function() {
|
||||
return function () {
|
||||
if (!fs) {
|
||||
/**
|
||||
* need to use an expression when doing a require if we want
|
||||
* webpack not to find out about the requirement
|
||||
*/
|
||||
const _r = "require"
|
||||
fs = module[_r]("fs")
|
||||
const _r = "require";
|
||||
fs = module[_r]("fs");
|
||||
}
|
||||
return fs
|
||||
}
|
||||
})()
|
||||
return fs;
|
||||
};
|
||||
})();
|
||||
|
||||
export class ConfigError extends Error {
|
||||
constructor(message: string) {
|
||||
|
@ -82,7 +82,7 @@ interface LibeufinNexusMoneyMovement {
|
||||
};
|
||||
endToEndId: string;
|
||||
unstructuredRemittanceInformation: string;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
interface LibeufinNexusBatches {
|
||||
@ -668,7 +668,10 @@ export class LibeufinCli {
|
||||
console.log(stdout);
|
||||
}
|
||||
|
||||
async submitPayment(details: LibeufinPreparedPaymentDetails, paymentUuid: string): Promise<void> {
|
||||
async submitPayment(
|
||||
details: LibeufinPreparedPaymentDetails,
|
||||
paymentUuid: string,
|
||||
): Promise<void> {
|
||||
const stdout = await sh(
|
||||
this.globalTestState,
|
||||
"libeufin-cli-submitpayment",
|
||||
@ -820,7 +823,7 @@ export interface NexusAuth {
|
||||
auth: {
|
||||
username: string;
|
||||
password: string;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export interface CreateNexusUserRequest {
|
||||
@ -832,10 +835,12 @@ export interface PostNexusTaskRequest {
|
||||
name: string;
|
||||
cronspec: string;
|
||||
type: string; // fetch | submit
|
||||
params: {
|
||||
params:
|
||||
| {
|
||||
level: string; // report | statement | all
|
||||
rangeType: string; // all | since-last | previous-days | latest
|
||||
} | {}
|
||||
}
|
||||
| {};
|
||||
}
|
||||
|
||||
export interface PostNexusPermissionRequest {
|
||||
@ -850,20 +855,16 @@ export interface PostNexusPermissionRequest {
|
||||
}
|
||||
|
||||
export namespace LibeufinNexusApi {
|
||||
|
||||
export async function getAllConnections(
|
||||
nexus: LibeufinNexusServiceInterface,
|
||||
): Promise<any> {
|
||||
let url = new URL("bank-connections", nexus.baseUrl);
|
||||
const res = await axios.get(
|
||||
url.href,
|
||||
{
|
||||
const res = await axios.get(url.href, {
|
||||
auth: {
|
||||
username: "admin",
|
||||
password: "test",
|
||||
},
|
||||
},
|
||||
);
|
||||
});
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -873,16 +874,12 @@ export namespace LibeufinNexusApi {
|
||||
): Promise<any> {
|
||||
const baseUrl = libeufinNexusService.baseUrl;
|
||||
let url = new URL("bank-connections/delete-connection", baseUrl);
|
||||
return await axios.post(
|
||||
url.href,
|
||||
req,
|
||||
{
|
||||
return await axios.post(url.href, req, {
|
||||
auth: {
|
||||
username: "admin",
|
||||
password: "test",
|
||||
}
|
||||
}
|
||||
);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export async function createEbicsBankConnection(
|
||||
@ -1012,31 +1009,26 @@ export namespace LibeufinNexusApi {
|
||||
`/bank-accounts/${accountName}/payment-initiations`,
|
||||
baseUrl,
|
||||
);
|
||||
let response = await axios.get(
|
||||
url.href,
|
||||
{
|
||||
let response = await axios.get(url.href, {
|
||||
auth: {
|
||||
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(
|
||||
libeufinNexusService: LibeufinNexusService,
|
||||
): Promise<void> {
|
||||
const baseUrl = libeufinNexusService.baseUrl;
|
||||
let url = new URL(
|
||||
`/config`,
|
||||
baseUrl,
|
||||
);
|
||||
let url = new URL(`/config`, baseUrl);
|
||||
let response = await axios.get(url.href);
|
||||
}
|
||||
|
||||
|
||||
// FIXME: this function should return some structured
|
||||
// object that represents a history.
|
||||
export async function getAccountTransactions(
|
||||
@ -1046,19 +1038,13 @@ export namespace LibeufinNexusApi {
|
||||
password: string = "test",
|
||||
): Promise<any> {
|
||||
const baseUrl = libeufinNexusService.baseUrl;
|
||||
let url = new URL(
|
||||
`/bank-accounts/${accountName}/transactions`,
|
||||
baseUrl,
|
||||
);
|
||||
let response = await axios.get(
|
||||
url.href,
|
||||
{
|
||||
let url = new URL(`/bank-accounts/${accountName}/transactions`, baseUrl);
|
||||
let response = await axios.get(url.href, {
|
||||
auth: {
|
||||
username: username,
|
||||
password: password,
|
||||
},
|
||||
},
|
||||
);
|
||||
});
|
||||
return response;
|
||||
}
|
||||
|
||||
@ -1174,7 +1160,10 @@ export namespace LibeufinNexusApi {
|
||||
taskName: string,
|
||||
) {
|
||||
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, {
|
||||
auth: {
|
||||
username: "admin",
|
||||
@ -1204,15 +1193,12 @@ export namespace LibeufinNexusApi {
|
||||
): Promise<any> {
|
||||
const baseUrl = libeufinNexusService.baseUrl;
|
||||
let url = new URL(`facades/${facadeName}`, baseUrl);
|
||||
return await axios.delete(
|
||||
url.href,
|
||||
{
|
||||
return await axios.delete(url.href, {
|
||||
auth: {
|
||||
username: "admin",
|
||||
password: "test",
|
||||
},
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
export async function getAllFacades(
|
||||
@ -1220,15 +1206,12 @@ export namespace LibeufinNexusApi {
|
||||
): Promise<any> {
|
||||
const baseUrl = libeufinNexusService.baseUrl;
|
||||
let url = new URL("facades", baseUrl);
|
||||
return await axios.get(
|
||||
url.href,
|
||||
{
|
||||
return await axios.get(url.href, {
|
||||
auth: {
|
||||
username: "admin",
|
||||
password: "test",
|
||||
},
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
export async function createTwgFacade(
|
||||
@ -1368,16 +1351,12 @@ export function findNexusPayment(
|
||||
key: string,
|
||||
payments: LibeufinNexusTransactions,
|
||||
): LibeufinNexusMoneyMovement | void {
|
||||
|
||||
let transactions = payments["transactions"];
|
||||
for (let i = 0; i < transactions.length; i++) {
|
||||
|
||||
let batches = transactions[i]["batches"];
|
||||
for (let y = 0; y < batches.length; y++) {
|
||||
|
||||
let movements = batches[y]["batchTransactions"];
|
||||
for (let z = 0; z < movements.length; z++) {
|
||||
|
||||
let movement = movements[z];
|
||||
if (movement["details"]["unstructuredRemittanceInformation"] == key)
|
||||
return movement;
|
||||
|
@ -27,9 +27,7 @@ import {
|
||||
BankApi,
|
||||
BankAccessApi,
|
||||
} from "./harness";
|
||||
import {
|
||||
URL,
|
||||
} from "@gnu-taler/taler-wallet-core";
|
||||
import { URL } from "@gnu-taler/taler-wallet-core";
|
||||
import { ExchangesListRespose, TalerErrorCode } from "@gnu-taler/taler-util";
|
||||
import {
|
||||
FaultInjectedExchangeService,
|
||||
|
@ -38,13 +38,10 @@ export async function runLibeufinApiBankaccountTest(t: GlobalTestState) {
|
||||
await nexus.start();
|
||||
await nexus.pingUntilAvailable();
|
||||
|
||||
await LibeufinNexusApi.createUser(
|
||||
nexus,
|
||||
{
|
||||
await LibeufinNexusApi.createUser(nexus, {
|
||||
username: "one",
|
||||
password: "testing-the-bankaccount-api",
|
||||
}
|
||||
);
|
||||
});
|
||||
const sandbox = await LibeufinSandboxService.create(t, {
|
||||
httpPort: 5012,
|
||||
databaseJdbcUri: `jdbc:sqlite:${t.testDir}/libeufin-sandbox.sqlite3`,
|
||||
@ -52,17 +49,12 @@ export async function runLibeufinApiBankaccountTest(t: GlobalTestState) {
|
||||
await sandbox.start();
|
||||
await sandbox.pingUntilAvailable();
|
||||
await LibeufinSandboxApi.createEbicsHost(sandbox, "mock");
|
||||
await LibeufinSandboxApi.createEbicsSubscriber(
|
||||
sandbox,
|
||||
{
|
||||
await LibeufinSandboxApi.createEbicsSubscriber(sandbox, {
|
||||
hostID: "mock",
|
||||
userID: "mock",
|
||||
partnerID: "mock",
|
||||
}
|
||||
);
|
||||
await LibeufinSandboxApi.createEbicsBankAccount(
|
||||
sandbox,
|
||||
{
|
||||
});
|
||||
await LibeufinSandboxApi.createEbicsBankAccount(sandbox, {
|
||||
subscriber: {
|
||||
hostID: "mock",
|
||||
partnerID: "mock",
|
||||
@ -73,22 +65,22 @@ export async function runLibeufinApiBankaccountTest(t: GlobalTestState) {
|
||||
name: "mock",
|
||||
currency: "mock",
|
||||
label: "mock",
|
||||
},
|
||||
);
|
||||
await LibeufinNexusApi.createEbicsBankConnection(
|
||||
nexus,
|
||||
{
|
||||
});
|
||||
await LibeufinNexusApi.createEbicsBankConnection(nexus, {
|
||||
name: "bankaccount-api-test-connection",
|
||||
ebicsURL: "http://localhost:5012/ebicsweb",
|
||||
hostID: "mock",
|
||||
userID: "mock",
|
||||
partnerID: "mock",
|
||||
}
|
||||
);
|
||||
});
|
||||
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(
|
||||
nexus,
|
||||
@ -97,9 +89,7 @@ export async function runLibeufinApiBankaccountTest(t: GlobalTestState) {
|
||||
"local-mock",
|
||||
);
|
||||
|
||||
await LibeufinSandboxApi.bookPayment2(
|
||||
sandbox,
|
||||
{
|
||||
await LibeufinSandboxApi.bookPayment2(sandbox, {
|
||||
creditorIban: "DE71500105179674997361",
|
||||
creditorBic: "BELADEBEXXX",
|
||||
creditorName: "mock",
|
||||
@ -111,15 +101,11 @@ export async function runLibeufinApiBankaccountTest(t: GlobalTestState) {
|
||||
amount: "1",
|
||||
uid: "mock",
|
||||
direction: "CRDT",
|
||||
}
|
||||
);
|
||||
await LibeufinNexusApi.fetchAllTransactions(
|
||||
nexus,
|
||||
"local-mock"
|
||||
);
|
||||
});
|
||||
await LibeufinNexusApi.fetchAllTransactions(nexus, "local-mock");
|
||||
let transactions = await LibeufinNexusApi.getAccountTransactions(
|
||||
nexus,
|
||||
"local-mock"
|
||||
"local-mock",
|
||||
);
|
||||
let el = findNexusPayment("mock subject", transactions.data);
|
||||
t.assertTrue(el instanceof Object);
|
||||
|
@ -38,34 +38,25 @@ export async function runLibeufinApiBankconnectionTest(t: GlobalTestState) {
|
||||
await nexus.start();
|
||||
await nexus.pingUntilAvailable();
|
||||
|
||||
await LibeufinNexusApi.createUser(
|
||||
nexus,
|
||||
{
|
||||
await LibeufinNexusApi.createUser(nexus, {
|
||||
username: "one",
|
||||
password: "testing-the-bankconnection-api",
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
await LibeufinNexusApi.createEbicsBankConnection(
|
||||
nexus,
|
||||
{
|
||||
await LibeufinNexusApi.createEbicsBankConnection(nexus, {
|
||||
name: "bankconnection-api-test-connection",
|
||||
ebicsURL: "http://localhost:5012/ebicsweb",
|
||||
hostID: "mock",
|
||||
userID: "mock",
|
||||
partnerID: "mock",
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
let connections = await LibeufinNexusApi.getAllConnections(nexus);
|
||||
t.assertTrue(connections.data["bankConnections"].length == 1);
|
||||
|
||||
await LibeufinNexusApi.deleteBankConnection(
|
||||
nexus,
|
||||
{
|
||||
await LibeufinNexusApi.deleteBankConnection(nexus, {
|
||||
bankConnectionId: "bankconnection-api-test-connection",
|
||||
}
|
||||
);
|
||||
});
|
||||
connections = await LibeufinNexusApi.getAllConnections(nexus);
|
||||
t.assertTrue(connections.data["bankConnections"].length == 0);
|
||||
}
|
||||
|
@ -43,15 +43,19 @@ export async function runLibeufinApiFacadeTest(t: GlobalTestState) {
|
||||
* Launch Sandbox and Nexus.
|
||||
*/
|
||||
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.
|
||||
t.assertTrue(resp.data["facades"][0]["name"] == user01nexus.twgReq["name"]);
|
||||
// delete it.
|
||||
resp = await LibeufinNexusApi.deleteFacade(
|
||||
libeufinServices.libeufinNexus,
|
||||
user01nexus.twgReq["name"]
|
||||
user01nexus.twgReq["name"],
|
||||
);
|
||||
// check that no facades show up.
|
||||
t.assertTrue(!resp.data.hasOwnProperty("facades"));
|
||||
|
@ -51,8 +51,8 @@ export async function runLibeufinApiPermissionsTest(t: GlobalTestState) {
|
||||
let transferPermission = await LibeufinNexusApi.getAllPermissions(nexus);
|
||||
let element = transferPermission.data["permissions"].pop();
|
||||
t.assertTrue(
|
||||
element["permissionName"] == "facade.talerWireGateway.transfer"
|
||||
&& element["subjectId"] == "username-01"
|
||||
element["permissionName"] == "facade.talerWireGateway.transfer" &&
|
||||
element["subjectId"] == "username-01",
|
||||
);
|
||||
let denyTransfer = user01nexus.twgTransferPermission;
|
||||
|
||||
|
@ -40,7 +40,6 @@ export async function runLibeufinApiSchedulingTest(t: GlobalTestState) {
|
||||
await nexus.start();
|
||||
await nexus.pingUntilAvailable();
|
||||
|
||||
|
||||
const user01nexus = new NexusUserBundle(
|
||||
"01",
|
||||
"http://localhost:5010/ebicsweb",
|
||||
@ -54,13 +53,25 @@ export async function runLibeufinApiSchedulingTest(t: GlobalTestState) {
|
||||
params: {
|
||||
level: "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");
|
||||
await LibeufinNexusApi.deleteTask(nexus, user01nexus.localAccountName, "test-task");
|
||||
await LibeufinNexusApi.deleteTask(
|
||||
nexus,
|
||||
user01nexus.localAccountName,
|
||||
"test-task",
|
||||
);
|
||||
try {
|
||||
await LibeufinNexusApi.getTasks(nexus, user01nexus.localAccountName, "test-task");
|
||||
await LibeufinNexusApi.getTasks(
|
||||
nexus,
|
||||
user01nexus.localAccountName,
|
||||
"test-task",
|
||||
);
|
||||
} catch (err) {
|
||||
t.assertTrue(err.response.status == 404);
|
||||
}
|
||||
@ -72,11 +83,23 @@ export async function runLibeufinApiSchedulingTest(t: GlobalTestState) {
|
||||
type: "submit",
|
||||
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");
|
||||
await LibeufinNexusApi.deleteTask(nexus, user01nexus.localAccountName, "test-task");
|
||||
await LibeufinNexusApi.deleteTask(
|
||||
nexus,
|
||||
user01nexus.localAccountName,
|
||||
"test-task",
|
||||
);
|
||||
try {
|
||||
await LibeufinNexusApi.getTasks(nexus, user01nexus.localAccountName, "test-task");
|
||||
await LibeufinNexusApi.getTasks(
|
||||
nexus,
|
||||
user01nexus.localAccountName,
|
||||
"test-task",
|
||||
);
|
||||
} catch (err) {
|
||||
t.assertTrue(err.response.status == 404);
|
||||
}
|
||||
|
@ -35,13 +35,10 @@ export async function runLibeufinApiUsersTest(t: GlobalTestState) {
|
||||
await nexus.start();
|
||||
await nexus.pingUntilAvailable();
|
||||
|
||||
await LibeufinNexusApi.createUser(
|
||||
nexus,
|
||||
{
|
||||
await LibeufinNexusApi.createUser(nexus, {
|
||||
username: "one",
|
||||
password: "will-be-changed",
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
await LibeufinNexusApi.changePassword(
|
||||
nexus,
|
||||
@ -52,19 +49,16 @@ export async function runLibeufinApiUsersTest(t: GlobalTestState) {
|
||||
auth: {
|
||||
username: "one",
|
||||
password: "will-be-changed",
|
||||
}
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
let resp = await LibeufinNexusApi.getUser(
|
||||
nexus,
|
||||
{
|
||||
let resp = await LibeufinNexusApi.getUser(nexus, {
|
||||
auth: {
|
||||
username: "one",
|
||||
password: "got-changed",
|
||||
}
|
||||
}
|
||||
);
|
||||
},
|
||||
});
|
||||
console.log(resp.data);
|
||||
t.assertTrue(resp.data["username"] == "one" && !resp.data["superuser"]);
|
||||
}
|
||||
|
@ -95,10 +95,10 @@ export async function runLibeufinRefundMultipleUsersTest(t: GlobalTestState) {
|
||||
// Counterpart checks whether the reimbursement shows up.
|
||||
let history = await LibeufinSandboxApi.getAccountTransactions(
|
||||
libeufinServices.libeufinSandbox,
|
||||
user01sandbox.ebicsBankAccount["label"]
|
||||
user01sandbox.ebicsBankAccount["label"],
|
||||
);
|
||||
|
||||
t.assertTrue(history["payments"].length == 1)
|
||||
t.assertTrue(history["payments"].length == 1);
|
||||
}
|
||||
|
||||
runLibeufinRefundMultipleUsersTest.suites = ["libeufin"];
|
||||
|
@ -85,9 +85,9 @@ export async function runLibeufinRefundTest(t: GlobalTestState) {
|
||||
// Counterpart checks whether the reimbursement shows up.
|
||||
let history = await LibeufinSandboxApi.getAccountTransactions(
|
||||
libeufinServices.libeufinSandbox,
|
||||
user01sandbox.ebicsBankAccount["label"]
|
||||
user01sandbox.ebicsBankAccount["label"],
|
||||
);
|
||||
|
||||
t.assertTrue(history["payments"].length == 1)
|
||||
t.assertTrue(history["payments"].length == 1);
|
||||
}
|
||||
runLibeufinRefundTest.suites = ["libeufin"];
|
||||
|
@ -109,7 +109,6 @@ export async function createConfusedMerchantTestkudosEnvironment(
|
||||
paytoUris: [`payto://x-taler-bank/merchant-default`],
|
||||
});
|
||||
|
||||
|
||||
await merchant.addInstance({
|
||||
id: "minst1",
|
||||
name: "minst1",
|
||||
|
@ -30,10 +30,7 @@ import {
|
||||
withdrawViaBank,
|
||||
SimpleTestEnvironment,
|
||||
} from "./helpers";
|
||||
import {
|
||||
durationFromSpec,
|
||||
PreparePayResultType,
|
||||
} from "@gnu-taler/taler-util";
|
||||
import { durationFromSpec, PreparePayResultType } from "@gnu-taler/taler-util";
|
||||
import axios from "axios";
|
||||
import { URL } from "@gnu-taler/taler-wallet-core";
|
||||
|
||||
|
@ -23,9 +23,7 @@
|
||||
* Imports.
|
||||
*/
|
||||
import { PreparePayResultType, TalerErrorCode } from "@gnu-taler/taler-util";
|
||||
import {
|
||||
URL,
|
||||
} from "@gnu-taler/taler-wallet-core";
|
||||
import { URL } from "@gnu-taler/taler-wallet-core";
|
||||
import {
|
||||
FaultInjectionRequestContext,
|
||||
FaultInjectionResponseContext,
|
||||
|
@ -135,7 +135,7 @@ const allTests: TestMainFunction[] = [
|
||||
export interface TestRunSpec {
|
||||
includePattern?: string;
|
||||
suiteSpec?: string;
|
||||
dryRun?: boolean,
|
||||
dryRun?: boolean;
|
||||
}
|
||||
|
||||
export interface TestInfo {
|
||||
|
@ -92,8 +92,10 @@ export function handleWorkerMessage(msg: any): void {
|
||||
try {
|
||||
const result = (impl as any)[operation](...args);
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const _r = "require"
|
||||
const worker_threads: typeof import("worker_threads") = module[_r]("worker_threads");
|
||||
const _r = "require";
|
||||
const worker_threads: typeof import("worker_threads") = module[_r](
|
||||
"worker_threads",
|
||||
);
|
||||
// const worker_threads = require("worker_threads");
|
||||
|
||||
const p = worker_threads.parentPort;
|
||||
@ -149,7 +151,7 @@ class NodeThreadCryptoWorker implements CryptoWorker {
|
||||
|
||||
constructor() {
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const _r = "require"
|
||||
const _r = "require";
|
||||
const worker_threads = module[_r]("worker_threads");
|
||||
|
||||
logger.trace("starting node crypto worker");
|
||||
|
@ -169,7 +169,6 @@ export async function openTalerDatabase(
|
||||
return new DbAccess(mainDbHandle, WalletStoresV1);
|
||||
}
|
||||
|
||||
|
||||
export function deleteTalerDatabase(idbFactory: IDBFactory): void {
|
||||
idbFactory.deleteDatabase(TALER_DB_NAME);
|
||||
}
|
||||
|
@ -41,18 +41,18 @@ const logger = new Logger("headless/helpers.ts");
|
||||
|
||||
const nodejs_fs = (function () {
|
||||
let fs: typeof import("fs");
|
||||
return function() {
|
||||
return function () {
|
||||
if (!fs) {
|
||||
/**
|
||||
* need to use an expression when doing a require if we want
|
||||
* webpack not to find out about the requirement
|
||||
*/
|
||||
const _r = "require"
|
||||
fs = module[_r]("fs")
|
||||
const _r = "require";
|
||||
fs = module[_r]("fs");
|
||||
}
|
||||
return fs
|
||||
}
|
||||
})()
|
||||
return fs;
|
||||
};
|
||||
})();
|
||||
|
||||
export interface DefaultNodeWalletArgs {
|
||||
/**
|
||||
@ -123,9 +123,13 @@ export async function getDefaultNodeWallet(
|
||||
}
|
||||
const tmpPath = `${args.persistentStoragePath}-${makeId(5)}.tmp`;
|
||||
const dbContent = myBackend.exportDump();
|
||||
nodejs_fs().writeFileSync(tmpPath, JSON.stringify(dbContent, undefined, 2), {
|
||||
nodejs_fs().writeFileSync(
|
||||
tmpPath,
|
||||
JSON.stringify(dbContent, undefined, 2),
|
||||
{
|
||||
encoding: "utf-8",
|
||||
});
|
||||
},
|
||||
);
|
||||
// Atomically move the temporary file onto the DB path.
|
||||
nodejs_fs().renameSync(tmpPath, args.persistentStoragePath);
|
||||
};
|
||||
@ -157,7 +161,7 @@ export async function getDefaultNodeWallet(
|
||||
let workerFactory;
|
||||
try {
|
||||
// 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");
|
||||
// require("worker_threads");
|
||||
workerFactory = new NodeThreadCryptoWorkerFactory();
|
||||
|
@ -17,7 +17,12 @@
|
||||
/**
|
||||
* 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 { GetReadOnlyAccess } from "../util/query.js";
|
||||
|
@ -1649,8 +1649,9 @@ export async function refuseProposal(
|
||||
ws: InternalWalletState,
|
||||
proposalId: string,
|
||||
): Promise<void> {
|
||||
const success = await ws.db.mktx((x) => ({proposals: x.proposals})).runReadWrite(
|
||||
async (tx) => {
|
||||
const success = await ws.db
|
||||
.mktx((x) => ({ proposals: x.proposals }))
|
||||
.runReadWrite(async (tx) => {
|
||||
const proposal = await tx.proposals.get(proposalId);
|
||||
if (!proposal) {
|
||||
logger.trace(`proposal ${proposalId} not found, won't refuse proposal`);
|
||||
@ -1662,8 +1663,7 @@ export async function refuseProposal(
|
||||
proposal.proposalStatus = ProposalStatus.REFUSED;
|
||||
await tx.proposals.put(proposal);
|
||||
return true;
|
||||
},
|
||||
);
|
||||
});
|
||||
if (success) {
|
||||
ws.notify({
|
||||
type: NotificationType.ProposalRefused,
|
||||
|
@ -239,7 +239,7 @@ async function gatherRefreshPending(
|
||||
async function gatherWithdrawalPending(
|
||||
tx: GetReadOnlyAccess<{
|
||||
withdrawalGroups: typeof WalletStoresV1.withdrawalGroups;
|
||||
planchets: typeof WalletStoresV1.planchets,
|
||||
planchets: typeof WalletStoresV1.planchets;
|
||||
}>,
|
||||
now: Timestamp,
|
||||
resp: PendingOperationsResponse,
|
||||
@ -464,7 +464,8 @@ export async function getPendingOperations(
|
||||
{ onlyDue = false } = {},
|
||||
): Promise<PendingOperationsResponse> {
|
||||
const now = getTimestampNow();
|
||||
return await ws.db.mktx((x) => ({
|
||||
return await ws.db
|
||||
.mktx((x) => ({
|
||||
exchanges: x.exchanges,
|
||||
exchangeDetails: x.exchangeDetails,
|
||||
reserves: x.reserves,
|
||||
@ -477,8 +478,8 @@ export async function getPendingOperations(
|
||||
planchets: x.planchets,
|
||||
depositGroups: x.depositGroups,
|
||||
recoupGroups: x.recoupGroups,
|
||||
})).runReadWrite(
|
||||
async (tx) => {
|
||||
}))
|
||||
.runReadWrite(async (tx) => {
|
||||
const walletBalance = await getBalancesInsideTransaction(ws, tx);
|
||||
const resp: PendingOperationsResponse = {
|
||||
nextRetryDelay: { d_ms: Number.MAX_SAFE_INTEGER },
|
||||
@ -496,6 +497,5 @@ export async function getPendingOperations(
|
||||
await gatherRecoupPending(tx, now, resp, onlyDue);
|
||||
await gatherDepositPending(tx, now, resp, onlyDue);
|
||||
return resp;
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
|
@ -23,7 +23,16 @@ import {
|
||||
readSuccessResponseJsonOrThrow,
|
||||
checkSuccessResponseOrThrow,
|
||||
} 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 { Wallet } from "../wallet.js";
|
||||
import { createTalerWithdrawReserve } from "./reserves.js";
|
||||
@ -102,8 +111,8 @@ export async function withdrawTestBalance(
|
||||
function getMerchantAuthHeader(m: MerchantBackendInfo): Record<string, string> {
|
||||
if (m.authToken) {
|
||||
return {
|
||||
"Authorization": `Bearer ${m.authToken}`,
|
||||
}
|
||||
Authorization: `Bearer ${m.authToken}`,
|
||||
};
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
@ -24,7 +24,12 @@
|
||||
/**
|
||||
* 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 { RetryInfo } from "./util/retries.js";
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user