formatting pass
This commit is contained in:
parent
c4b44a5109
commit
f332d61fb6
@ -124,7 +124,6 @@ const coinCheapCommon = (curr: string) => ({
|
|||||||
feeWithdraw: `${curr}:0.2`,
|
feeWithdraw: `${curr}:0.2`,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
export function makeNoFeeCoinConfig(curr: string): CoinConfig[] {
|
export function makeNoFeeCoinConfig(curr: string): CoinConfig[] {
|
||||||
const cc: CoinConfig[] = [];
|
const cc: CoinConfig[] = [];
|
||||||
|
|
||||||
|
@ -908,9 +908,7 @@ export class ExchangeService implements ExchangeServiceInterface {
|
|||||||
|
|
||||||
addCoinConfigList(ccs: CoinConfig[]) {
|
addCoinConfigList(ccs: CoinConfig[]) {
|
||||||
const config = Configuration.load(this.configFilename);
|
const config = Configuration.load(this.configFilename);
|
||||||
ccs.forEach((cc) =>
|
ccs.forEach((cc) => setCoin(config, cc));
|
||||||
setCoin(config, cc),
|
|
||||||
);
|
|
||||||
config.write(this.configFilename);
|
config.write(this.configFilename);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1545,8 +1543,9 @@ export class WalletCli {
|
|||||||
throw new OperationFailedError(resp.error);
|
throw new OperationFailedError(resp.error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async abortFailedPayWithRefund(
|
||||||
async abortFailedPayWithRefund(req: AbortPayWithRefundRequest): Promise<void> {
|
req: AbortPayWithRefundRequest,
|
||||||
|
): Promise<void> {
|
||||||
const resp = await this.apiRequest("abortFailedPayWithRefund", req);
|
const resp = await this.apiRequest("abortFailedPayWithRefund", req);
|
||||||
if (resp.type === "response") {
|
if (resp.type === "response") {
|
||||||
return;
|
return;
|
||||||
|
@ -107,7 +107,9 @@ export const codecForCheckPaymentUnpaidResponse = (): Codec<
|
|||||||
.property("already_paid_order_id", codecOptional(codecForString()))
|
.property("already_paid_order_id", codecOptional(codecForString()))
|
||||||
.build("CheckPaymentPaidResponse");
|
.build("CheckPaymentPaidResponse");
|
||||||
|
|
||||||
export const codecForCheckPaymentClaimedResponse = (): Codec<CheckPaymentClaimedResponse> =>
|
export const codecForCheckPaymentClaimedResponse = (): Codec<
|
||||||
|
CheckPaymentClaimedResponse
|
||||||
|
> =>
|
||||||
buildCodecForObject<CheckPaymentClaimedResponse>()
|
buildCodecForObject<CheckPaymentClaimedResponse>()
|
||||||
.property("order_status", codecForConstString("claimed"))
|
.property("order_status", codecForConstString("claimed"))
|
||||||
.property("contract_terms", codecForContractTerms())
|
.property("contract_terms", codecForContractTerms())
|
||||||
@ -179,7 +181,6 @@ export interface CheckPaymentPaidResponse {
|
|||||||
order_status_url: string;
|
order_status_url: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export interface CheckPaymentUnpaidResponse {
|
export interface CheckPaymentUnpaidResponse {
|
||||||
order_status: "unpaid";
|
order_status: "unpaid";
|
||||||
|
|
||||||
@ -275,7 +276,6 @@ export interface ReserveStatusEntry {
|
|||||||
active: boolean;
|
active: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export interface TipCreateConfirmation {
|
export interface TipCreateConfirmation {
|
||||||
// Unique tip identifier for the tip that was created.
|
// Unique tip identifier for the tip that was created.
|
||||||
tip_id: string;
|
tip_id: string;
|
||||||
|
@ -116,7 +116,9 @@ runTest(async (t: GlobalTestState) => {
|
|||||||
|
|
||||||
// Check that we got the sign-up bonus.
|
// Check that we got the sign-up bonus.
|
||||||
t.assertAmountEquals(balResp.balance.amount, "TESTKUDOS:100");
|
t.assertAmountEquals(balResp.balance.amount, "TESTKUDOS:100");
|
||||||
t.assertTrue(balResp.balance.credit_debit_indicator === CreditDebitIndicator.Credit);
|
t.assertTrue(
|
||||||
|
balResp.balance.credit_debit_indicator === CreditDebitIndicator.Credit,
|
||||||
|
);
|
||||||
|
|
||||||
const res = createEddsaKeyPair();
|
const res = createEddsaKeyPair();
|
||||||
|
|
||||||
@ -129,5 +131,7 @@ runTest(async (t: GlobalTestState) => {
|
|||||||
|
|
||||||
balResp = await BankAccessApi.getAccountBalance(bank, bankUser);
|
balResp = await BankAccessApi.getAccountBalance(bank, bankUser);
|
||||||
t.assertAmountEquals(balResp.balance.amount, "TESTKUDOS:15");
|
t.assertAmountEquals(balResp.balance.amount, "TESTKUDOS:15");
|
||||||
t.assertTrue(balResp.balance.credit_debit_indicator === CreditDebitIndicator.Debit);
|
t.assertTrue(
|
||||||
|
balResp.balance.credit_debit_indicator === CreditDebitIndicator.Debit,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
@ -24,7 +24,7 @@ import {
|
|||||||
WalletCli,
|
WalletCli,
|
||||||
} from "./harness";
|
} from "./harness";
|
||||||
import { createSimpleTestkudosEnvironment, withdrawViaBank } from "./helpers";
|
import { createSimpleTestkudosEnvironment, withdrawViaBank } from "./helpers";
|
||||||
import { URL } from "url"
|
import { URL } from "url";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run test for the merchant's order lifecycle.
|
* Run test for the merchant's order lifecycle.
|
||||||
@ -50,13 +50,16 @@ runTest(async (t: GlobalTestState) => {
|
|||||||
summary: "Buy me!",
|
summary: "Buy me!",
|
||||||
amount: "TESTKUDOS:5",
|
amount: "TESTKUDOS:5",
|
||||||
fulfillment_url: "taler://fulfillment-success/thx",
|
fulfillment_url: "taler://fulfillment-success/thx",
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// Query private order status before claiming it.
|
// Query private order status before claiming it.
|
||||||
let orderStatusBefore = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
|
let orderStatusBefore = await MerchantPrivateApi.queryPrivateOrderStatus(
|
||||||
|
merchant,
|
||||||
|
{
|
||||||
orderId: orderResp.order_id,
|
orderId: orderResp.order_id,
|
||||||
});
|
},
|
||||||
|
);
|
||||||
t.assertTrue(orderStatusBefore.order_status === "unpaid");
|
t.assertTrue(orderStatusBefore.order_status === "unpaid");
|
||||||
let statusUrlBefore = new URL(orderStatusBefore.order_status_url);
|
let statusUrlBefore = new URL(orderStatusBefore.order_status_url);
|
||||||
|
|
||||||
@ -64,13 +67,16 @@ runTest(async (t: GlobalTestState) => {
|
|||||||
t.assertTrue(orderStatusBefore.order_status === "unpaid");
|
t.assertTrue(orderStatusBefore.order_status === "unpaid");
|
||||||
const talerPayUri = orderStatusBefore.taler_pay_uri;
|
const talerPayUri = orderStatusBefore.taler_pay_uri;
|
||||||
const y = await wallet.preparePay({
|
const y = await wallet.preparePay({
|
||||||
talerPayUri
|
talerPayUri,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Query private order status after claiming it.
|
// Query private order status after claiming it.
|
||||||
let orderStatusAfter = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
|
let orderStatusAfter = await MerchantPrivateApi.queryPrivateOrderStatus(
|
||||||
|
merchant,
|
||||||
|
{
|
||||||
orderId: orderResp.order_id,
|
orderId: orderResp.order_id,
|
||||||
});
|
},
|
||||||
|
);
|
||||||
t.assertTrue(orderStatusAfter.order_status === "claimed");
|
t.assertTrue(orderStatusAfter.order_status === "claimed");
|
||||||
|
|
||||||
await t.shutdown();
|
await t.shutdown();
|
||||||
|
@ -17,15 +17,22 @@
|
|||||||
/**
|
/**
|
||||||
* Imports.
|
* Imports.
|
||||||
*/
|
*/
|
||||||
import { defaultCoinConfig } from './denomStructures';
|
import { defaultCoinConfig } from "./denomStructures";
|
||||||
import { runTest, GlobalTestState, BankService, ExchangeService, MerchantService, setupDb, WalletCli } from "./harness";
|
import {
|
||||||
|
runTest,
|
||||||
|
GlobalTestState,
|
||||||
|
BankService,
|
||||||
|
ExchangeService,
|
||||||
|
MerchantService,
|
||||||
|
setupDb,
|
||||||
|
WalletCli,
|
||||||
|
} from "./harness";
|
||||||
import {
|
import {
|
||||||
withdrawViaBank,
|
withdrawViaBank,
|
||||||
makeTestPayment,
|
makeTestPayment,
|
||||||
SimpleTestEnvironment,
|
SimpleTestEnvironment,
|
||||||
} from "./helpers";
|
} from "./helpers";
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run a test case with a simple TESTKUDOS Taler environment, consisting
|
* Run a test case with a simple TESTKUDOS Taler environment, consisting
|
||||||
* of one exchange, one bank and one merchant.
|
* of one exchange, one bank and one merchant.
|
||||||
@ -83,42 +90,42 @@ export async function createMyTestkudosEnvironment(
|
|||||||
{
|
{
|
||||||
...coinCommon,
|
...coinCommon,
|
||||||
name: "c1",
|
name: "c1",
|
||||||
value: "TESTKUDOS:1.28"
|
value: "TESTKUDOS:1.28",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
...coinCommon,
|
...coinCommon,
|
||||||
name: "c2",
|
name: "c2",
|
||||||
value: "TESTKUDOS:0.64"
|
value: "TESTKUDOS:0.64",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
...coinCommon,
|
...coinCommon,
|
||||||
name: "c3",
|
name: "c3",
|
||||||
value: "TESTKUDOS:0.32"
|
value: "TESTKUDOS:0.32",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
...coinCommon,
|
...coinCommon,
|
||||||
name: "c4",
|
name: "c4",
|
||||||
value: "TESTKUDOS:0.16"
|
value: "TESTKUDOS:0.16",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
...coinCommon,
|
...coinCommon,
|
||||||
name: "c5",
|
name: "c5",
|
||||||
value: "TESTKUDOS:0.08"
|
value: "TESTKUDOS:0.08",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
...coinCommon,
|
...coinCommon,
|
||||||
name: "c5",
|
name: "c5",
|
||||||
value: "TESTKUDOS:0.04"
|
value: "TESTKUDOS:0.04",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
...coinCommon,
|
...coinCommon,
|
||||||
name: "c6",
|
name: "c6",
|
||||||
value: "TESTKUDOS:0.02"
|
value: "TESTKUDOS:0.02",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
...coinCommon,
|
...coinCommon,
|
||||||
name: "c7",
|
name: "c7",
|
||||||
value: "TESTKUDOS:0.01"
|
value: "TESTKUDOS:0.01",
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@ -171,7 +178,12 @@ runTest(async (t: GlobalTestState) => {
|
|||||||
|
|
||||||
// Withdraw digital cash into the wallet.
|
// Withdraw digital cash into the wallet.
|
||||||
|
|
||||||
await withdrawViaBank(t, { wallet, bank, exchange, amount: "TESTKUDOS:1.92" });
|
await withdrawViaBank(t, {
|
||||||
|
wallet,
|
||||||
|
bank,
|
||||||
|
exchange,
|
||||||
|
amount: "TESTKUDOS:1.92",
|
||||||
|
});
|
||||||
|
|
||||||
const coins = await wallet.dumpCoins();
|
const coins = await wallet.dumpCoins();
|
||||||
|
|
||||||
|
@ -39,11 +39,7 @@ import {
|
|||||||
FaultInjectionRequestContext,
|
FaultInjectionRequestContext,
|
||||||
FaultInjectionResponseContext,
|
FaultInjectionResponseContext,
|
||||||
} from "./faultInjection";
|
} from "./faultInjection";
|
||||||
import {
|
import { PreparePayResultType, URL, TalerErrorCode } from "taler-wallet-core";
|
||||||
PreparePayResultType,
|
|
||||||
URL,
|
|
||||||
TalerErrorCode,
|
|
||||||
} from "taler-wallet-core";
|
|
||||||
import { defaultCoinConfig } from "./denomStructures";
|
import { defaultCoinConfig } from "./denomStructures";
|
||||||
import { withdrawViaBank, makeTestPayment } from "./helpers";
|
import { withdrawViaBank, makeTestPayment } from "./helpers";
|
||||||
|
|
||||||
|
@ -150,7 +150,10 @@ runTest(async (t: GlobalTestState) => {
|
|||||||
sessionId: "mysession-two",
|
sessionId: "mysession-two",
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log("order status under mysession-two:", JSON.stringify(orderStatus, undefined, 2));
|
console.log(
|
||||||
|
"order status under mysession-two:",
|
||||||
|
JSON.stringify(orderStatus, undefined, 2),
|
||||||
|
);
|
||||||
|
|
||||||
// Should be claimed (not paid!) because of a new session ID
|
// Should be claimed (not paid!) because of a new session ID
|
||||||
t.assertTrue(orderStatus.order_status === "claimed");
|
t.assertTrue(orderStatus.order_status === "claimed");
|
||||||
@ -169,7 +172,6 @@ runTest(async (t: GlobalTestState) => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
let orderRespTwo = await MerchantPrivateApi.createOrder(merchant, "default", {
|
let orderRespTwo = await MerchantPrivateApi.createOrder(merchant, "default", {
|
||||||
order: {
|
order: {
|
||||||
summary: "Buy me!",
|
summary: "Buy me!",
|
||||||
@ -178,10 +180,13 @@ runTest(async (t: GlobalTestState) => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
let orderStatusTwo = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
|
let orderStatusTwo = await MerchantPrivateApi.queryPrivateOrderStatus(
|
||||||
|
merchant,
|
||||||
|
{
|
||||||
orderId: orderRespTwo.order_id,
|
orderId: orderRespTwo.order_id,
|
||||||
sessionId: "mysession-two",
|
sessionId: "mysession-two",
|
||||||
});
|
},
|
||||||
|
);
|
||||||
|
|
||||||
t.assertTrue(orderStatusTwo.order_status === "unpaid");
|
t.assertTrue(orderStatusTwo.order_status === "unpaid");
|
||||||
|
|
||||||
|
@ -25,7 +25,6 @@ import {
|
|||||||
ExchangeService,
|
ExchangeService,
|
||||||
MerchantService,
|
MerchantService,
|
||||||
WalletCli,
|
WalletCli,
|
||||||
|
|
||||||
MerchantPrivateApi,
|
MerchantPrivateApi,
|
||||||
} from "./harness";
|
} from "./harness";
|
||||||
import { withdrawViaBank } from "./helpers";
|
import { withdrawViaBank } from "./helpers";
|
||||||
|
@ -32,7 +32,10 @@ import {
|
|||||||
TalerErrorCode,
|
TalerErrorCode,
|
||||||
} from "taler-wallet-core";
|
} from "taler-wallet-core";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { FaultInjectionRequestContext, FaultInjectionResponseContext } from "./faultInjection";
|
import {
|
||||||
|
FaultInjectionRequestContext,
|
||||||
|
FaultInjectionResponseContext,
|
||||||
|
} from "./faultInjection";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run test for a payment where the merchant has a transient
|
* Run test for a payment where the merchant has a transient
|
||||||
@ -134,7 +137,7 @@ runTest(async (t: GlobalTestState) => {
|
|||||||
};
|
};
|
||||||
ctx.responseBody = Buffer.from(JSON.stringify(err));
|
ctx.responseBody = Buffer.from(JSON.stringify(err));
|
||||||
ctx.statusCode = 500;
|
ctx.statusCode = 500;
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const confirmPayResp = await wallet.confirmPay({
|
const confirmPayResp = await wallet.confirmPay({
|
||||||
|
@ -48,7 +48,7 @@ runTest(async (t: GlobalTestState) => {
|
|||||||
d_ms: 3000,
|
d_ms: 3000,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
refund_delay: durationFromSpec({ minutes: 5}),
|
refund_delay: durationFromSpec({ minutes: 5 }),
|
||||||
});
|
});
|
||||||
|
|
||||||
let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
|
let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
|
||||||
|
@ -51,7 +51,7 @@ runTest(async (t: GlobalTestState) => {
|
|||||||
amount: "TESTKUDOS:10",
|
amount: "TESTKUDOS:10",
|
||||||
fulfillment_url: "taler://fulfillment-success/thx",
|
fulfillment_url: "taler://fulfillment-success/thx",
|
||||||
},
|
},
|
||||||
refund_delay: durationFromSpec({ minutes: 5}),
|
refund_delay: durationFromSpec({ minutes: 5 }),
|
||||||
});
|
});
|
||||||
|
|
||||||
let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
|
let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
/**
|
/**
|
||||||
* Imports.
|
* Imports.
|
||||||
*/
|
*/
|
||||||
import { durationFromSpec } from 'taler-wallet-core';
|
import { durationFromSpec } from "taler-wallet-core";
|
||||||
import { runTest, GlobalTestState, MerchantPrivateApi } from "./harness";
|
import { runTest, GlobalTestState, MerchantPrivateApi } from "./harness";
|
||||||
import { createSimpleTestkudosEnvironment, withdrawViaBank } from "./helpers";
|
import { createSimpleTestkudosEnvironment, withdrawViaBank } from "./helpers";
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ runTest(async (t: GlobalTestState) => {
|
|||||||
amount: "TESTKUDOS:5",
|
amount: "TESTKUDOS:5",
|
||||||
fulfillment_url: "taler://fulfillment-success/thx",
|
fulfillment_url: "taler://fulfillment-success/thx",
|
||||||
},
|
},
|
||||||
refund_delay: durationFromSpec({ minutes: 5}),
|
refund_delay: durationFromSpec({ minutes: 5 }),
|
||||||
});
|
});
|
||||||
|
|
||||||
let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
|
let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
|
||||||
|
@ -126,7 +126,9 @@ export class AndroidHttpLib implements HttpRequestLibrary {
|
|||||||
requestMethod: "FIXME",
|
requestMethod: "FIXME",
|
||||||
json: async () => JSON.parse(msg.responseText),
|
json: async () => JSON.parse(msg.responseText),
|
||||||
text: async () => msg.responseText,
|
text: async () => msg.responseText,
|
||||||
bytes: async () => { throw Error("bytes() not supported for tunnel response") },
|
bytes: async () => {
|
||||||
|
throw Error("bytes() not supported for tunnel response");
|
||||||
|
},
|
||||||
};
|
};
|
||||||
p.resolve(resp);
|
p.resolve(resp);
|
||||||
} else {
|
} else {
|
||||||
|
@ -655,7 +655,7 @@ testCli.subcommand("vectors", "vectors").action(async (args) => {
|
|||||||
async function read(stream: NodeJS.ReadStream) {
|
async function read(stream: NodeJS.ReadStream) {
|
||||||
const chunks = [];
|
const chunks = [];
|
||||||
for await (const chunk of stream) chunks.push(chunk);
|
for await (const chunk of stream) chunks.push(chunk);
|
||||||
return Buffer.concat(chunks).toString('utf8');
|
return Buffer.concat(chunks).toString("utf8");
|
||||||
}
|
}
|
||||||
|
|
||||||
testCli.subcommand("tvgcheck", "tvgcheck").action(async (args) => {
|
testCli.subcommand("tvgcheck", "tvgcheck").action(async (args) => {
|
||||||
@ -667,7 +667,7 @@ testCli.subcommand("tvgcheck", "tvgcheck").action(async (args) => {
|
|||||||
throw Error("can't split lines");
|
throw Error("can't split lines");
|
||||||
}
|
}
|
||||||
|
|
||||||
const vals: Record<string, string> = {}
|
const vals: Record<string, string> = {};
|
||||||
|
|
||||||
let inBlindSigningSection = false;
|
let inBlindSigningSection = false;
|
||||||
|
|
||||||
@ -684,7 +684,7 @@ testCli.subcommand("tvgcheck", "tvgcheck").action(async (args) => {
|
|||||||
const m = line.match(/ (\w+) (\w+)/);
|
const m = line.match(/ (\w+) (\w+)/);
|
||||||
if (!m) {
|
if (!m) {
|
||||||
console.log("bad format");
|
console.log("bad format");
|
||||||
process.exit(2)
|
process.exit(2);
|
||||||
}
|
}
|
||||||
vals[m[1]] = m[2];
|
vals[m[1]] = m[2];
|
||||||
}
|
}
|
||||||
@ -697,7 +697,7 @@ testCli.subcommand("tvgcheck", "tvgcheck").action(async (args) => {
|
|||||||
throw Error(`no value for ${k}`);
|
throw Error(`no value for ${k}`);
|
||||||
}
|
}
|
||||||
return decodeCrock(vals[k]);
|
return decodeCrock(vals[k]);
|
||||||
}
|
};
|
||||||
|
|
||||||
const myBm = rsaBlind(
|
const myBm = rsaBlind(
|
||||||
req("message_hash"),
|
req("message_hash"),
|
||||||
|
@ -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).
|
||||||
@ -1668,5 +1666,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,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -187,4 +187,3 @@ test("taler-exchange-tvg eddsa_ecdh #2", (t) => {
|
|||||||
);
|
);
|
||||||
t.deepEqual(encodeCrock(myKm2), key_material);
|
t.deepEqual(encodeCrock(myKm2), key_material);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -76,7 +76,10 @@ export function openTalerDatabase(
|
|||||||
if ((si as any)[indexName] instanceof Index) {
|
if ((si as any)[indexName] instanceof Index) {
|
||||||
const ii: Index<string, string, any, any> = (si as any)[indexName];
|
const ii: Index<string, string, any, any> = (si as any)[indexName];
|
||||||
const indexVersionAdded = ii.options?.versionAdded ?? 0;
|
const indexVersionAdded = ii.options?.versionAdded ?? 0;
|
||||||
if (indexVersionAdded > oldVersion || storeVersionAdded > oldVersion) {
|
if (
|
||||||
|
indexVersionAdded > oldVersion ||
|
||||||
|
storeVersionAdded > oldVersion
|
||||||
|
) {
|
||||||
s.createIndex(ii.indexName, ii.keyPath, ii.options);
|
s.createIndex(ii.indexName, ii.keyPath, ii.options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ import { OperationFailedError, makeErrorDetails } from "../operations/errors";
|
|||||||
import { TalerErrorCode } from "../TalerErrorCode";
|
import { TalerErrorCode } from "../TalerErrorCode";
|
||||||
import { URL } from "../util/url";
|
import { URL } from "../util/url";
|
||||||
import { Logger } from "../util/logging";
|
import { Logger } from "../util/logging";
|
||||||
import { bytesToString } from '../crypto/talerCrypto';
|
import { bytesToString } from "../crypto/talerCrypto";
|
||||||
|
|
||||||
const logger = new Logger("NodeHttpLib.ts");
|
const logger = new Logger("NodeHttpLib.ts");
|
||||||
|
|
||||||
@ -92,10 +92,10 @@ export class NodeHttpLib implements HttpRequestLibrary {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const makeText = async(): Promise<string> => {
|
const makeText = async (): Promise<string> => {
|
||||||
const respText = new Uint8Array(resp.data);
|
const respText = new Uint8Array(resp.data);
|
||||||
return bytesToString(respText);
|
return bytesToString(respText);
|
||||||
}
|
};
|
||||||
|
|
||||||
const makeJson = async (): Promise<any> => {
|
const makeJson = async (): Promise<any> => {
|
||||||
let responseJson;
|
let responseJson;
|
||||||
@ -152,7 +152,6 @@ export class NodeHttpLib implements HttpRequestLibrary {
|
|||||||
json: makeJson,
|
json: makeJson,
|
||||||
bytes: makeBytes,
|
bytes: makeBytes,
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
async get(url: string, opt?: HttpRequestOptions): Promise<HttpResponse> {
|
async get(url: string, opt?: HttpRequestOptions): Promise<HttpResponse> {
|
||||||
return this.fetch(url, {
|
return this.fetch(url, {
|
||||||
|
@ -64,8 +64,7 @@ export interface DefaultNodeWalletArgs {
|
|||||||
*/
|
*/
|
||||||
function makeId(length: number): string {
|
function makeId(length: number): string {
|
||||||
let result = "";
|
let result = "";
|
||||||
const characters =
|
const characters = "abcdefghijklmnopqrstuvwxyz0123456789";
|
||||||
"abcdefghijklmnopqrstuvwxyz0123456789";
|
|
||||||
for (let i = 0; i < length; i++) {
|
for (let i = 0; i < length; i++) {
|
||||||
result += characters.charAt(Math.floor(Math.random() * characters.length));
|
result += characters.charAt(Math.floor(Math.random() * characters.length));
|
||||||
}
|
}
|
||||||
@ -129,7 +128,9 @@ export async function getDefaultNodeWallet(
|
|||||||
|
|
||||||
const myVersionChange = (): Promise<void> => {
|
const myVersionChange = (): Promise<void> => {
|
||||||
logger.error("version change requested, should not happen");
|
logger.error("version change requested, should not happen");
|
||||||
throw Error("BUG: wallet DB version change event can't happen with memory IDB");
|
throw Error(
|
||||||
|
"BUG: wallet DB version change event can't happen with memory IDB",
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
shimIndexedDB(myBridgeIdbFactory);
|
shimIndexedDB(myBridgeIdbFactory);
|
||||||
|
@ -120,7 +120,7 @@ async function provideBackupState(
|
|||||||
key: WALLET_BACKUP_STATE_KEY,
|
key: WALLET_BACKUP_STATE_KEY,
|
||||||
value: {
|
value: {
|
||||||
deviceId,
|
deviceId,
|
||||||
clocks: { [deviceId]: 1},
|
clocks: { [deviceId]: 1 },
|
||||||
walletRootPub: k.pub,
|
walletRootPub: k.pub,
|
||||||
walletRootPriv: k.priv,
|
walletRootPriv: k.priv,
|
||||||
lastBackupHash: undefined,
|
lastBackupHash: undefined,
|
||||||
@ -152,7 +152,9 @@ export async function exportBackup(
|
|||||||
|
|
||||||
const exchanges: BackupExchange[] = [];
|
const exchanges: BackupExchange[] = [];
|
||||||
const coinsByDenom: { [dph: string]: BackupCoin[] } = {};
|
const coinsByDenom: { [dph: string]: BackupCoin[] } = {};
|
||||||
const denominationsByExchange: { [url: string]: BackupDenomination[] } = {};
|
const denominationsByExchange: {
|
||||||
|
[url: string]: BackupDenomination[];
|
||||||
|
} = {};
|
||||||
const reservesByExchange: { [url: string]: BackupReserve[] } = {};
|
const reservesByExchange: { [url: string]: BackupReserve[] } = {};
|
||||||
|
|
||||||
await tx.iter(Stores.coins).forEach((coin) => {
|
await tx.iter(Stores.coins).forEach((coin) => {
|
||||||
@ -193,7 +195,9 @@ export async function exportBackup(
|
|||||||
});
|
});
|
||||||
|
|
||||||
await tx.iter(Stores.denominations).forEach((denom) => {
|
await tx.iter(Stores.denominations).forEach((denom) => {
|
||||||
const backupDenoms = (denominationsByExchange[denom.exchangeBaseUrl] ??= []);
|
const backupDenoms = (denominationsByExchange[
|
||||||
|
denom.exchangeBaseUrl
|
||||||
|
] ??= []);
|
||||||
backupDenoms.push({
|
backupDenoms.push({
|
||||||
coins: coinsByDenom[denom.denomPubHash] ?? [],
|
coins: coinsByDenom[denom.denomPubHash] ?? [],
|
||||||
denom_pub: denom.denomPub,
|
denom_pub: denom.denomPub,
|
||||||
@ -401,7 +405,7 @@ export async function runBackupCycle(ws: InternalWalletState): Promise<void> {
|
|||||||
|
|
||||||
if (resp.status === HttpResponseStatus.PaymentRequired) {
|
if (resp.status === HttpResponseStatus.PaymentRequired) {
|
||||||
logger.trace("payment required for backup");
|
logger.trace("payment required for backup");
|
||||||
logger.trace(`headers: ${j2s(resp.headers)}`)
|
logger.trace(`headers: ${j2s(resp.headers)}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,9 @@ export class OperationFailedAndReportedError extends Error {
|
|||||||
message: string,
|
message: string,
|
||||||
details: Record<string, unknown>,
|
details: Record<string, unknown>,
|
||||||
): OperationFailedAndReportedError {
|
): OperationFailedAndReportedError {
|
||||||
return new OperationFailedAndReportedError(makeErrorDetails(ec, message, details));
|
return new OperationFailedAndReportedError(
|
||||||
|
makeErrorDetails(ec, message, details),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(public operationError: TalerErrorDetails) {
|
constructor(public operationError: TalerErrorDetails) {
|
||||||
|
@ -289,9 +289,7 @@ async function updateExchangeFinalize(
|
|||||||
if (exchange.updateStatus != ExchangeUpdateStatus.FinalizeUpdate) {
|
if (exchange.updateStatus != ExchangeUpdateStatus.FinalizeUpdate) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await ws.db.runWithWriteTransaction(
|
await ws.db.runWithWriteTransaction([Stores.exchanges], async (tx) => {
|
||||||
[Stores.exchanges],
|
|
||||||
async (tx) => {
|
|
||||||
const r = await tx.get(Stores.exchanges, exchangeBaseUrl);
|
const r = await tx.get(Stores.exchanges, exchangeBaseUrl);
|
||||||
if (!r) {
|
if (!r) {
|
||||||
return;
|
return;
|
||||||
@ -305,8 +303,7 @@ async function updateExchangeFinalize(
|
|||||||
// as now new denominations might be available.
|
// as now new denominations might be available.
|
||||||
r.nextRefreshCheck = undefined;
|
r.nextRefreshCheck = undefined;
|
||||||
await tx.put(Stores.exchanges, r);
|
await tx.put(Stores.exchanges, r);
|
||||||
},
|
});
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function updateExchangeWithTermsOfService(
|
async function updateExchangeWithTermsOfService(
|
||||||
@ -547,7 +544,9 @@ export async function getExchangeTrust(
|
|||||||
);
|
);
|
||||||
if (currencyRecord) {
|
if (currencyRecord) {
|
||||||
for (const trustedExchange of currencyRecord.exchanges) {
|
for (const trustedExchange of currencyRecord.exchanges) {
|
||||||
if (trustedExchange.exchangeMasterPub === exchangeDetails.masterPublicKey) {
|
if (
|
||||||
|
trustedExchange.exchangeMasterPub === exchangeDetails.masterPublicKey
|
||||||
|
) {
|
||||||
isTrusted = true;
|
isTrusted = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -435,7 +435,9 @@ async function recordConfirmPay(
|
|||||||
} else {
|
} else {
|
||||||
sessionId = proposal.downloadSessionId;
|
sessionId = proposal.downloadSessionId;
|
||||||
}
|
}
|
||||||
logger.trace(`recording payment on ${proposal.orderId} with session ID ${sessionId}`);
|
logger.trace(
|
||||||
|
`recording payment on ${proposal.orderId} with session ID ${sessionId}`,
|
||||||
|
);
|
||||||
const payCostInfo = await getTotalPaymentCost(ws, coinSelection);
|
const payCostInfo = await getTotalPaymentCost(ws, coinSelection);
|
||||||
const t: PurchaseRecord = {
|
const t: PurchaseRecord = {
|
||||||
abortStatus: AbortStatus.None,
|
abortStatus: AbortStatus.None,
|
||||||
@ -943,7 +945,10 @@ async function submitPay(
|
|||||||
session_id: purchase.lastSessionId,
|
session_id: purchase.lastSessionId,
|
||||||
};
|
};
|
||||||
|
|
||||||
logger.trace("making pay request ... ", JSON.stringify(reqBody, undefined, 2));
|
logger.trace(
|
||||||
|
"making pay request ... ",
|
||||||
|
JSON.stringify(reqBody, undefined, 2),
|
||||||
|
);
|
||||||
|
|
||||||
const resp = await ws.runSequentialized([EXCHANGE_COINS_LOCK], () =>
|
const resp = await ws.runSequentialized([EXCHANGE_COINS_LOCK], () =>
|
||||||
ws.http.postJson(payUrl, reqBody, {
|
ws.http.postJson(payUrl, reqBody, {
|
||||||
@ -1208,10 +1213,7 @@ export async function confirmPay(
|
|||||||
throw Error("proposal is in invalid state");
|
throw Error("proposal is in invalid state");
|
||||||
}
|
}
|
||||||
|
|
||||||
let purchase = await ws.db.get(
|
let purchase = await ws.db.get(Stores.purchases, proposalId);
|
||||||
Stores.purchases,
|
|
||||||
proposalId,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (purchase) {
|
if (purchase) {
|
||||||
if (
|
if (
|
||||||
|
@ -38,10 +38,7 @@ import {
|
|||||||
|
|
||||||
import { codecForRecoupConfirmation } from "../types/talerTypes";
|
import { codecForRecoupConfirmation } from "../types/talerTypes";
|
||||||
import { NotificationType } from "../types/notifications";
|
import { NotificationType } from "../types/notifications";
|
||||||
import {
|
import { getReserveRequestTimeout, processReserve } from "./reserves";
|
||||||
getReserveRequestTimeout,
|
|
||||||
processReserve,
|
|
||||||
} from "./reserves";
|
|
||||||
|
|
||||||
import { Amounts } from "../util/amounts";
|
import { Amounts } from "../util/amounts";
|
||||||
import { createRefreshGroup, processRefreshGroup } from "./refresh";
|
import { createRefreshGroup, processRefreshGroup } from "./refresh";
|
||||||
|
@ -286,7 +286,10 @@ async function storeFailedRefund(
|
|||||||
}
|
}
|
||||||
if (contrib) {
|
if (contrib) {
|
||||||
coin.currentAmount = Amounts.add(coin.currentAmount, contrib).amount;
|
coin.currentAmount = Amounts.add(coin.currentAmount, contrib).amount;
|
||||||
coin.currentAmount = Amounts.sub(coin.currentAmount, denom.feeRefund).amount;
|
coin.currentAmount = Amounts.sub(
|
||||||
|
coin.currentAmount,
|
||||||
|
denom.feeRefund,
|
||||||
|
).amount;
|
||||||
}
|
}
|
||||||
refreshCoinsMap[coin.coinPub] = { coinPub: coin.coinPub };
|
refreshCoinsMap[coin.coinPub] = { coinPub: coin.coinPub };
|
||||||
await tx.put(Stores.coins, coin);
|
await tx.put(Stores.coins, coin);
|
||||||
@ -325,7 +328,8 @@ async function acceptRefunds(
|
|||||||
|
|
||||||
const isPermanentFailure =
|
const isPermanentFailure =
|
||||||
refundStatus.type === "failure" &&
|
refundStatus.type === "failure" &&
|
||||||
refundStatus.exchange_status >= 400 && refundStatus.exchange_status < 500 ;
|
refundStatus.exchange_status >= 400 &&
|
||||||
|
refundStatus.exchange_status < 500;
|
||||||
|
|
||||||
// Already failed.
|
// Already failed.
|
||||||
if (existingRefundInfo?.type === RefundState.Failed) {
|
if (existingRefundInfo?.type === RefundState.Failed) {
|
||||||
@ -536,7 +540,7 @@ export async function applyRefund(
|
|||||||
fulfillmentMessage: purchase.contractData.fulfillmentMessage,
|
fulfillmentMessage: purchase.contractData.fulfillmentMessage,
|
||||||
summary_i18n: purchase.contractData.summaryI18n,
|
summary_i18n: purchase.contractData.summaryI18n,
|
||||||
fulfillmentMessage_i18n: purchase.contractData.fulfillmentMessageI18n,
|
fulfillmentMessage_i18n: purchase.contractData.fulfillmentMessageI18n,
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +40,10 @@ import { getRandomBytes, encodeCrock } from "../crypto/talerCrypto";
|
|||||||
import { guardOperationException, makeErrorDetails } from "./errors";
|
import { guardOperationException, makeErrorDetails } from "./errors";
|
||||||
import { NotificationType } from "../types/notifications";
|
import { NotificationType } from "../types/notifications";
|
||||||
import { getTimestampNow } from "../util/time";
|
import { getTimestampNow } from "../util/time";
|
||||||
import { getHttpResponseErrorDetails, readSuccessResponseJsonOrThrow } from "../util/http";
|
import {
|
||||||
|
getHttpResponseErrorDetails,
|
||||||
|
readSuccessResponseJsonOrThrow,
|
||||||
|
} from "../util/http";
|
||||||
import { URL } from "../util/url";
|
import { URL } from "../util/url";
|
||||||
import { Logger } from "../util/logging";
|
import { Logger } from "../util/logging";
|
||||||
import { checkDbInvariant } from "../util/invariants";
|
import { checkDbInvariant } from "../util/invariants";
|
||||||
|
@ -43,7 +43,10 @@ import { InternalWalletState } from "./state";
|
|||||||
import { parseWithdrawUri } from "../util/taleruri";
|
import { parseWithdrawUri } from "../util/taleruri";
|
||||||
import { Logger } from "../util/logging";
|
import { Logger } from "../util/logging";
|
||||||
import { updateExchangeFromUrl, getExchangeTrust } from "./exchanges";
|
import { updateExchangeFromUrl, getExchangeTrust } from "./exchanges";
|
||||||
import { WALLET_EXCHANGE_PROTOCOL_VERSION, WALLET_BANK_INTEGRATION_PROTOCOL_VERSION } from "./versions";
|
import {
|
||||||
|
WALLET_EXCHANGE_PROTOCOL_VERSION,
|
||||||
|
WALLET_BANK_INTEGRATION_PROTOCOL_VERSION,
|
||||||
|
} from "./versions";
|
||||||
|
|
||||||
import * as LibtoolVersion from "../util/libtoolVersion";
|
import * as LibtoolVersion from "../util/libtoolVersion";
|
||||||
import {
|
import {
|
||||||
@ -155,10 +158,7 @@ export async function getBankWithdrawalInfo(
|
|||||||
throw Error(`can't parse URL ${talerWithdrawUri}`);
|
throw Error(`can't parse URL ${talerWithdrawUri}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const configReqUrl = new URL(
|
const configReqUrl = new URL("config", uriResult.bankIntegrationApiBaseUrl);
|
||||||
"config",
|
|
||||||
uriResult.bankIntegrationApiBaseUrl,
|
|
||||||
)
|
|
||||||
|
|
||||||
const configResp = await ws.http.get(configReqUrl.href);
|
const configResp = await ws.http.get(configReqUrl.href);
|
||||||
const config = await readSuccessResponseJsonOrThrow(
|
const config = await readSuccessResponseJsonOrThrow(
|
||||||
@ -166,7 +166,10 @@ export async function getBankWithdrawalInfo(
|
|||||||
codecForTalerConfigResponse(),
|
codecForTalerConfigResponse(),
|
||||||
);
|
);
|
||||||
|
|
||||||
const versionRes = compare(WALLET_BANK_INTEGRATION_PROTOCOL_VERSION, config.version);
|
const versionRes = compare(
|
||||||
|
WALLET_BANK_INTEGRATION_PROTOCOL_VERSION,
|
||||||
|
config.version,
|
||||||
|
);
|
||||||
if (versionRes?.compatible != true) {
|
if (versionRes?.compatible != true) {
|
||||||
const opErr = makeErrorDetails(
|
const opErr = makeErrorDetails(
|
||||||
TalerErrorCode.WALLET_BANK_INTEGRATION_PROTOCOL_VERSION_INCOMPATIBLE,
|
TalerErrorCode.WALLET_BANK_INTEGRATION_PROTOCOL_VERSION_INCOMPATIBLE,
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
* Current limitations:
|
* Current limitations:
|
||||||
* 1. Exchange/auditor trust isn't exported yet
|
* 1. Exchange/auditor trust isn't exported yet
|
||||||
* (see https://bugs.gnunet.org/view.php?id=6448)
|
* (see https://bugs.gnunet.org/view.php?id=6448)
|
||||||
|
* 2. Reports to the auditor (cryptographic proofs and/or diagnostics) aren't exported yet
|
||||||
*
|
*
|
||||||
* General considerations / decisions:
|
* General considerations / decisions:
|
||||||
* 1. Information about previously occurring errors and
|
* 1. Information about previously occurring errors and
|
||||||
|
@ -54,7 +54,6 @@ test("contract terms validation", (t) => {
|
|||||||
t.fail();
|
t.fail();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
test("contract terms validation (locations)", (t) => {
|
test("contract terms validation (locations)", (t) => {
|
||||||
const c = {
|
const c = {
|
||||||
nonce: "123123123",
|
nonce: "123123123",
|
||||||
@ -69,7 +68,7 @@ test("contract terms validation (locations)", (t) => {
|
|||||||
name: "Foo",
|
name: "Foo",
|
||||||
address: {
|
address: {
|
||||||
country: "DE",
|
country: "DE",
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
order_id: "test_order",
|
order_id: "test_order",
|
||||||
pay_deadline: { t_ms: 42 },
|
pay_deadline: { t_ms: 42 },
|
||||||
@ -83,7 +82,7 @@ test("contract terms validation (locations)", (t) => {
|
|||||||
delivery_location: {
|
delivery_location: {
|
||||||
country: "FR",
|
country: "FR",
|
||||||
town: "Rennes",
|
town: "Rennes",
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const r = codecForContractTerms().decode(c);
|
const r = codecForContractTerms().decode(c);
|
||||||
|
@ -974,7 +974,9 @@ export interface AbortPayWithRefundRequest {
|
|||||||
proposalId: string;
|
proposalId: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const codecForAbortPayWithRefundRequest = (): Codec<AbortPayWithRefundRequest> =>
|
export const codecForAbortPayWithRefundRequest = (): Codec<
|
||||||
|
AbortPayWithRefundRequest
|
||||||
|
> =>
|
||||||
buildCodecForObject<AbortPayWithRefundRequest>()
|
buildCodecForObject<AbortPayWithRefundRequest>()
|
||||||
.property("proposalId", codecForString())
|
.property("proposalId", codecForString())
|
||||||
.build("AbortPayWithRefundRequest");
|
.build("AbortPayWithRefundRequest");
|
||||||
|
@ -21,7 +21,11 @@
|
|||||||
/**
|
/**
|
||||||
* Imports.
|
* Imports.
|
||||||
*/
|
*/
|
||||||
import { getTimestampNow, timestampDifference, timestampCmp } from "../util/time";
|
import {
|
||||||
|
getTimestampNow,
|
||||||
|
timestampDifference,
|
||||||
|
timestampCmp,
|
||||||
|
} from "../util/time";
|
||||||
import { URL } from "./url";
|
import { URL } from "./url";
|
||||||
import { Logger } from "./logging";
|
import { Logger } from "./logging";
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ export class Headers {
|
|||||||
|
|
||||||
toJSON(): any {
|
toJSON(): any {
|
||||||
const m: Record<string, string> = {};
|
const m: Record<string, string> = {};
|
||||||
this.headerMap.forEach((v, k) => m[k] = v);
|
this.headerMap.forEach((v, k) => (m[k] = v));
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -120,10 +120,7 @@ export interface HttpRequestLibrary {
|
|||||||
/**
|
/**
|
||||||
* Make an HTTP POST request with a JSON body.
|
* Make an HTTP POST request with a JSON body.
|
||||||
*/
|
*/
|
||||||
fetch(
|
fetch(url: string, opt?: HttpRequestOptions): Promise<HttpResponse>;
|
||||||
url: string,
|
|
||||||
opt?: HttpRequestOptions,
|
|
||||||
): Promise<HttpResponse>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type TalerErrorResponse = {
|
type TalerErrorResponse = {
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
*/
|
*/
|
||||||
import { openPromise } from "./promiseUtils";
|
import { openPromise } from "./promiseUtils";
|
||||||
import {
|
import {
|
||||||
IDBObjectStoreParameters,
|
|
||||||
IDBRequest,
|
IDBRequest,
|
||||||
IDBTransaction,
|
IDBTransaction,
|
||||||
IDBValidKey,
|
IDBValidKey,
|
||||||
@ -574,7 +573,7 @@ export class Database {
|
|||||||
|
|
||||||
async get<N extends string, T>(
|
async get<N extends string, T>(
|
||||||
store: Store<N, T>,
|
store: Store<N, T>,
|
||||||
key: any,
|
key: IDBValidKey,
|
||||||
): Promise<T | undefined> {
|
): Promise<T | undefined> {
|
||||||
const tx = this.db.transaction([store.name], "readonly");
|
const tx = this.db.transaction([store.name], "readonly");
|
||||||
const req = tx.objectStore(store.name).get(key);
|
const req = tx.objectStore(store.name).get(key);
|
||||||
@ -585,7 +584,7 @@ export class Database {
|
|||||||
|
|
||||||
async getIndexed<Ind extends Index<string, string, any, any>>(
|
async getIndexed<Ind extends Index<string, string, any, any>>(
|
||||||
index: InferIndex<Ind>,
|
index: InferIndex<Ind>,
|
||||||
key: any,
|
key: IDBValidKey,
|
||||||
): Promise<IndexRecord<Ind> | undefined> {
|
): Promise<IndexRecord<Ind> | undefined> {
|
||||||
const tx = this.db.transaction([index.storeName], "readonly");
|
const tx = this.db.transaction([index.storeName], "readonly");
|
||||||
const req = tx.objectStore(index.storeName).index(index.indexName).get(key);
|
const req = tx.objectStore(index.storeName).index(index.indexName).get(key);
|
||||||
@ -597,7 +596,7 @@ export class Database {
|
|||||||
async put<St extends Store<string, any>>(
|
async put<St extends Store<string, any>>(
|
||||||
store: St,
|
store: St,
|
||||||
value: StoreContent<St>,
|
value: StoreContent<St>,
|
||||||
key?: any,
|
key?: IDBValidKey,
|
||||||
): Promise<any> {
|
): Promise<any> {
|
||||||
const tx = this.db.transaction([store.name], "readwrite");
|
const tx = this.db.transaction([store.name], "readwrite");
|
||||||
const req = tx.objectStore(store.name).put(value, key);
|
const req = tx.objectStore(store.name).put(value, key);
|
||||||
@ -608,7 +607,7 @@ export class Database {
|
|||||||
|
|
||||||
async mutate<N extends string, T>(
|
async mutate<N extends string, T>(
|
||||||
store: Store<N, T>,
|
store: Store<N, T>,
|
||||||
key: any,
|
key: IDBValidKey,
|
||||||
f: (x: T) => T | undefined,
|
f: (x: T) => T | undefined,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const tx = this.db.transaction([store.name], "readwrite");
|
const tx = this.db.transaction([store.name], "readwrite");
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
|
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { canonicalizeBaseUrl } from './helpers';
|
import { canonicalizeBaseUrl } from "./helpers";
|
||||||
import { URLSearchParams } from "./url";
|
import { URLSearchParams } from "./url";
|
||||||
|
|
||||||
export interface PayUriResult {
|
export interface PayUriResult {
|
||||||
|
@ -132,7 +132,11 @@ import {
|
|||||||
PendingOperationType,
|
PendingOperationType,
|
||||||
} from "./types/pending";
|
} from "./types/pending";
|
||||||
import { WalletNotification, NotificationType } from "./types/notifications";
|
import { WalletNotification, NotificationType } from "./types/notifications";
|
||||||
import { processPurchaseQueryRefund, applyRefund, abortFailedPayWithRefund } from "./operations/refund";
|
import {
|
||||||
|
processPurchaseQueryRefund,
|
||||||
|
applyRefund,
|
||||||
|
abortFailedPayWithRefund,
|
||||||
|
} from "./operations/refund";
|
||||||
import { durationMin, Duration } from "./util/time";
|
import { durationMin, Duration } from "./util/time";
|
||||||
import { processRecoupGroup } from "./operations/recoup";
|
import { processRecoupGroup } from "./operations/recoup";
|
||||||
import {
|
import {
|
||||||
@ -152,7 +156,12 @@ import {
|
|||||||
testPay,
|
testPay,
|
||||||
} from "./operations/testing";
|
} from "./operations/testing";
|
||||||
import { TalerErrorCode } from ".";
|
import { TalerErrorCode } from ".";
|
||||||
import { addBackupProvider, codecForAddBackupProviderRequest, runBackupCycle, exportBackup } from './operations/backup';
|
import {
|
||||||
|
addBackupProvider,
|
||||||
|
codecForAddBackupProviderRequest,
|
||||||
|
runBackupCycle,
|
||||||
|
exportBackup,
|
||||||
|
} from "./operations/backup";
|
||||||
|
|
||||||
const builtinCurrencies: CurrencyRecord[] = [
|
const builtinCurrencies: CurrencyRecord[] = [
|
||||||
{
|
{
|
||||||
@ -721,9 +730,7 @@ export class Wallet {
|
|||||||
* Accept a refund, return the contract hash for the contract
|
* Accept a refund, return the contract hash for the contract
|
||||||
* that was involved in the refund.
|
* that was involved in the refund.
|
||||||
*/
|
*/
|
||||||
async applyRefund(
|
async applyRefund(talerRefundUri: string): Promise<ApplyRefundResponse> {
|
||||||
talerRefundUri: string,
|
|
||||||
): Promise<ApplyRefundResponse> {
|
|
||||||
return applyRefund(this.ws, talerRefundUri);
|
return applyRefund(this.ws, talerRefundUri);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user