towards wallet-core / util split
This commit is contained in:
parent
42a4d666f4
commit
07cdfb2e4e
6
.vscode/settings.json
vendored
6
.vscode/settings.json
vendored
@ -42,5 +42,9 @@
|
|||||||
"src/i18n/*.po": true
|
"src/i18n/*.po": true
|
||||||
},
|
},
|
||||||
"search.collapseResults": "auto",
|
"search.collapseResults": "auto",
|
||||||
"files.associations": { "api-extractor.json": "jsonc" }
|
"files.associations": {
|
||||||
|
"api-extractor.json": "jsonc"
|
||||||
|
},
|
||||||
|
"typescript.preferences.importModuleSpecifierEnding": "js",
|
||||||
|
"typescript.preferences.importModuleSpecifier": "project-relative"
|
||||||
}
|
}
|
@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
"preinstall": "npx only-allow pnpm",
|
||||||
"compile": "pnpm run --filter '{packages}' compile",
|
"compile": "pnpm run --filter '{packages}' compile",
|
||||||
"clean": "pnpm run --filter '{packages}' clean",
|
"clean": "pnpm run --filter '{packages}' clean",
|
||||||
"pretty": "pnpm run --filter '{packages}' pretty",
|
"pretty": "pnpm run --filter '{packages}' pretty",
|
||||||
|
9
packages/taler-util/README.md
Normal file
9
packages/taler-util/README.md
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
# @gnu-taler/taler-util
|
||||||
|
|
||||||
|
This package implements various utility functionality for GNU Taler.
|
||||||
|
|
||||||
|
|
||||||
|
## When should something be moved to this package?
|
||||||
|
|
||||||
|
The ``@gnu-taler/taler-util`` package should have minimal dependencies
|
||||||
|
and as few platform-specific functionality as possible.
|
44
packages/taler-util/package.json
Normal file
44
packages/taler-util/package.json
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
{
|
||||||
|
"name": "@gnu-taler/taler-util",
|
||||||
|
"version": "0.8.2",
|
||||||
|
"description": "Generic helper functionality for GNU Taler",
|
||||||
|
"exports": {
|
||||||
|
".": "./lib/index.js"
|
||||||
|
},
|
||||||
|
"module": "./lib/index.js",
|
||||||
|
"types": "./lib/index.d.ts",
|
||||||
|
"typesVersions": {
|
||||||
|
"*": {
|
||||||
|
"lib/index.d.ts": [
|
||||||
|
"lib/index.d.ts"
|
||||||
|
],
|
||||||
|
"src/*": [],
|
||||||
|
"*": []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"author": "Florian Dold",
|
||||||
|
"license": "AGPL-3.0-or-later",
|
||||||
|
"private": false,
|
||||||
|
"scripts": {
|
||||||
|
"prepare": "tsc",
|
||||||
|
"test": "tsc && ava",
|
||||||
|
"clean": "rimraf dist lib tsconfig.tsbuildinfo",
|
||||||
|
"pretty": "prettier --write src"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/node": "^14.14.22",
|
||||||
|
"ava": "^3.15.0",
|
||||||
|
"esbuild": "^0.9.2",
|
||||||
|
"prettier": "^2.2.1",
|
||||||
|
"rimraf": "^3.0.2",
|
||||||
|
"typescript": "^4.2.3"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"tslib": "^2.1.0"
|
||||||
|
},
|
||||||
|
"ava": {
|
||||||
|
"require": [
|
||||||
|
"esm"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
@ -26,7 +26,7 @@ import {
|
|||||||
buildCodecForObject,
|
buildCodecForObject,
|
||||||
codecForList,
|
codecForList,
|
||||||
Codec,
|
Codec,
|
||||||
} from "../util/codec";
|
} from "./codec.js";
|
||||||
import { AmountString } from "./talerTypes";
|
import { AmountString } from "./talerTypes";
|
||||||
import {
|
import {
|
||||||
ReserveTransaction,
|
ReserveTransaction,
|
@ -30,7 +30,7 @@ import {
|
|||||||
buildCodecForUnion,
|
buildCodecForUnion,
|
||||||
Codec,
|
Codec,
|
||||||
codecForNumber,
|
codecForNumber,
|
||||||
} from "../util/codec";
|
} from "./codec.js";
|
||||||
import {
|
import {
|
||||||
AmountString,
|
AmountString,
|
||||||
Base32String,
|
Base32String,
|
||||||
@ -38,7 +38,7 @@ import {
|
|||||||
EddsaPublicKeyString,
|
EddsaPublicKeyString,
|
||||||
CoinPublicKeyString,
|
CoinPublicKeyString,
|
||||||
} from "./talerTypes";
|
} from "./talerTypes";
|
||||||
import { Timestamp, codecForTimestamp } from "../util/time";
|
import { Timestamp, codecForTimestamp } from "./time.js";
|
||||||
|
|
||||||
export enum ReserveTransactionType {
|
export enum ReserveTransactionType {
|
||||||
Withdraw = "WITHDRAW",
|
Withdraw = "WITHDRAW",
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
import test from "ava";
|
import test from "ava";
|
||||||
|
|
||||||
import { Amounts, AmountJson } from "../util/amounts";
|
import { Amounts, AmountJson } from "./amounts.js";
|
||||||
|
|
||||||
const jAmt = (
|
const jAmt = (
|
||||||
value: number,
|
value: number,
|
@ -27,7 +27,7 @@ import {
|
|||||||
codecForNumber,
|
codecForNumber,
|
||||||
Codec,
|
Codec,
|
||||||
} from "./codec";
|
} from "./codec";
|
||||||
import { AmountString } from "../types/talerTypes";
|
import { AmountString } from "./talerTypes";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Number of fractional units that one value unit represents.
|
* Number of fractional units that one value unit represents.
|
@ -53,7 +53,7 @@
|
|||||||
/**
|
/**
|
||||||
* Imports.
|
* Imports.
|
||||||
*/
|
*/
|
||||||
import { Duration, Timestamp } from "../util/time";
|
import { Duration, Timestamp } from "./time.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Type alias for strings that are to be treated like amounts.
|
* Type alias for strings that are to be treated like amounts.
|
||||||
@ -1094,7 +1094,7 @@ export class BackupExchangeSignKey {
|
|||||||
/**
|
/**
|
||||||
* Signature by the auditor that a particular denomination key is audited.
|
* Signature by the auditor that a particular denomination key is audited.
|
||||||
*/
|
*/
|
||||||
export class AuditorDenomSig {
|
export class BackupAuditorDenomSig {
|
||||||
/**
|
/**
|
||||||
* Denomination public key's hash.
|
* Denomination public key's hash.
|
||||||
*/
|
*/
|
||||||
@ -1123,7 +1123,7 @@ export class BackupExchangeAuditor {
|
|||||||
/**
|
/**
|
||||||
* List of signatures for denominations by the auditor.
|
* List of signatures for denominations by the auditor.
|
||||||
*/
|
*/
|
||||||
denomination_keys: AuditorDenomSig[];
|
denomination_keys: BackupAuditorDenomSig[];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1297,3 +1297,10 @@ export interface BackupProposal {
|
|||||||
*/
|
*/
|
||||||
download_session_id?: string;
|
download_session_id?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface BackupRecovery {
|
||||||
|
walletRootPriv: string;
|
||||||
|
providers: {
|
||||||
|
url: string;
|
||||||
|
}[];
|
||||||
|
}
|
152
packages/taler-util/src/helpers.ts
Normal file
152
packages/taler-util/src/helpers.ts
Normal file
@ -0,0 +1,152 @@
|
|||||||
|
/*
|
||||||
|
This file is part of TALER
|
||||||
|
(C) 2016 GNUnet e.V.
|
||||||
|
|
||||||
|
TALER is free software; you can redistribute it and/or modify it under the
|
||||||
|
terms of the GNU General Public License as published by the Free Software
|
||||||
|
Foundation; either version 3, or (at your option) any later version.
|
||||||
|
|
||||||
|
TALER is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License along with
|
||||||
|
TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Small helper functions that don't fit anywhere else.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Imports.
|
||||||
|
*/
|
||||||
|
import { AmountJson } from "./amounts";
|
||||||
|
import * as Amounts from "./amounts";
|
||||||
|
import { URL } from "./url";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show an amount in a form suitable for the user.
|
||||||
|
* FIXME: In the future, this should consider currency-specific
|
||||||
|
* settings such as significant digits or currency symbols.
|
||||||
|
*/
|
||||||
|
export function amountToPretty(amount: AmountJson): string {
|
||||||
|
const x = amount.value + amount.fraction / Amounts.fractionalBase;
|
||||||
|
return `${x} ${amount.currency}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Canonicalize a base url, typically for the exchange.
|
||||||
|
*
|
||||||
|
* See http://api.taler.net/wallet.html#general
|
||||||
|
*/
|
||||||
|
export function canonicalizeBaseUrl(url: string): string {
|
||||||
|
if (!url.startsWith("http") && !url.startsWith("https")) {
|
||||||
|
url = "https://" + url;
|
||||||
|
}
|
||||||
|
const x = new URL(url);
|
||||||
|
if (!x.pathname.endsWith("/")) {
|
||||||
|
x.pathname = x.pathname + "/";
|
||||||
|
}
|
||||||
|
x.search = "";
|
||||||
|
x.hash = "";
|
||||||
|
return x.href;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert object to JSON with canonical ordering of keys
|
||||||
|
* and whitespace omitted.
|
||||||
|
*/
|
||||||
|
export function canonicalJson(obj: any): string {
|
||||||
|
// Check for cycles, etc.
|
||||||
|
obj = JSON.parse(JSON.stringify(obj));
|
||||||
|
if (typeof obj === "string" || typeof obj === "number" || obj === null) {
|
||||||
|
return JSON.stringify(obj);
|
||||||
|
}
|
||||||
|
if (Array.isArray(obj)) {
|
||||||
|
const objs: string[] = obj.map((e) => canonicalJson(e));
|
||||||
|
return `[${objs.join(",")}]`;
|
||||||
|
}
|
||||||
|
const keys: string[] = [];
|
||||||
|
for (const key in obj) {
|
||||||
|
keys.push(key);
|
||||||
|
}
|
||||||
|
keys.sort();
|
||||||
|
let s = "{";
|
||||||
|
for (let i = 0; i < keys.length; i++) {
|
||||||
|
const key = keys[i];
|
||||||
|
s += JSON.stringify(key) + ":" + canonicalJson(obj[key]);
|
||||||
|
if (i !== keys.length - 1) {
|
||||||
|
s += ",";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return s + "}";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check for deep equality of two objects.
|
||||||
|
* Only arrays, objects and primitives are supported.
|
||||||
|
*/
|
||||||
|
export function deepEquals(x: any, y: any): boolean {
|
||||||
|
if (x === y) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Array.isArray(x) && x.length !== y.length) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const p = Object.keys(x);
|
||||||
|
return (
|
||||||
|
Object.keys(y).every((i) => p.indexOf(i) !== -1) &&
|
||||||
|
p.every((i) => deepEquals(x[i], y[i]))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function deepCopy(x: any): any {
|
||||||
|
// FIXME: this has many issues ...
|
||||||
|
return JSON.parse(JSON.stringify(x));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map from a collection to a list or results and then
|
||||||
|
* concatenate the results.
|
||||||
|
*/
|
||||||
|
export function flatMap<T, U>(xs: T[], f: (x: T) => U[]): U[] {
|
||||||
|
return xs.reduce((acc: U[], next: T) => [...f(next), ...acc], []);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compute the hash function of a JSON object.
|
||||||
|
*/
|
||||||
|
export function hash(val: any): number {
|
||||||
|
const str = canonicalJson(val);
|
||||||
|
// https://github.com/darkskyapp/string-hash
|
||||||
|
let h = 5381;
|
||||||
|
let i = str.length;
|
||||||
|
while (i) {
|
||||||
|
h = (h * 33) ^ str.charCodeAt(--i);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* JavaScript does bitwise operations (like XOR, above) on 32-bit signed
|
||||||
|
* integers. Since we want the results to be always positive, convert the
|
||||||
|
* signed int to an unsigned by doing an unsigned bitshift. */
|
||||||
|
return h >>> 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lexically compare two strings.
|
||||||
|
*/
|
||||||
|
export function strcmp(s1: string, s2: string): number {
|
||||||
|
if (s1 < s2) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (s1 > s2) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function j2s(x: any): string {
|
||||||
|
return JSON.stringify(x, undefined, 2);
|
||||||
|
}
|
19
packages/taler-util/src/index.ts
Normal file
19
packages/taler-util/src/index.ts
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import { TalerErrorCode } from "./taler-error-codes.js";
|
||||||
|
|
||||||
|
export { TalerErrorCode };
|
||||||
|
|
||||||
|
export * from "./codec.js";
|
||||||
|
export * from "./amounts.js";
|
||||||
|
export * from "./talerconfig.js";
|
||||||
|
export * from "./time.js";
|
||||||
|
export * from "./walletTypes";
|
||||||
|
export * from "./transactionsTypes";
|
||||||
|
export * from "./notifications";
|
||||||
|
export * from "./talerTypes";
|
||||||
|
export * from "./talerconfig";
|
||||||
|
export * from "./taleruri";
|
||||||
|
export * from "./ReserveStatus";
|
||||||
|
export * from "./ReserveTransaction";
|
||||||
|
export * from "./backupTypes";
|
||||||
|
export * from "./payto.js";
|
||||||
|
export * from "./libtool-version";
|
@ -14,7 +14,7 @@
|
|||||||
TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
|
TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as LibtoolVersion from "./libtoolVersion";
|
import * as LibtoolVersion from "./libtool-version";
|
||||||
|
|
||||||
import test from "ava";
|
import test from "ava";
|
||||||
|
|
@ -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 { URLSearchParams } from "./url";
|
import { URLSearchParams } from "./url.js";
|
||||||
|
|
||||||
interface PaytoUri {
|
interface PaytoUri {
|
||||||
targetType: string;
|
targetType: string;
|
@ -40,14 +40,14 @@ import {
|
|||||||
codecForConstNumber,
|
codecForConstNumber,
|
||||||
buildCodecForUnion,
|
buildCodecForUnion,
|
||||||
codecForConstString,
|
codecForConstString,
|
||||||
} from "../util/codec";
|
} from "./codec";
|
||||||
import {
|
import {
|
||||||
Timestamp,
|
Timestamp,
|
||||||
codecForTimestamp,
|
codecForTimestamp,
|
||||||
Duration,
|
Duration,
|
||||||
codecForDuration,
|
codecForDuration,
|
||||||
} from "../util/time";
|
} from "./time";
|
||||||
import { codecForAmountString } from "../util/amounts";
|
import { codecForAmountString } from "./amounts";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Denomination as found in the /keys response from the exchange.
|
* Denomination as found in the /keys response from the exchange.
|
@ -1,5 +1,3 @@
|
|||||||
import { Codec, renderContext, Context } from "./codec";
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
This file is part of GNU Taler
|
This file is part of GNU Taler
|
||||||
(C) 2017-2019 Taler Systems S.A.
|
(C) 2017-2019 Taler Systems S.A.
|
||||||
@ -20,6 +18,11 @@ import { Codec, renderContext, Context } from "./codec";
|
|||||||
* Helpers for relative and absolute time.
|
* Helpers for relative and absolute time.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Imports.
|
||||||
|
*/
|
||||||
|
import { Codec, renderContext, Context } from "./codec";
|
||||||
|
|
||||||
export class Timestamp {
|
export class Timestamp {
|
||||||
/**
|
/**
|
||||||
* Timestamp in milliseconds.
|
* Timestamp in milliseconds.
|
@ -24,7 +24,7 @@
|
|||||||
/**
|
/**
|
||||||
* Imports.
|
* Imports.
|
||||||
*/
|
*/
|
||||||
import { Timestamp } from "../util/time";
|
import { Timestamp } from "./time.js";
|
||||||
import {
|
import {
|
||||||
AmountString,
|
AmountString,
|
||||||
Product,
|
Product,
|
||||||
@ -33,7 +33,7 @@ import {
|
|||||||
codecForInternationalizedString,
|
codecForInternationalizedString,
|
||||||
codecForMerchantInfo,
|
codecForMerchantInfo,
|
||||||
codecForProduct,
|
codecForProduct,
|
||||||
} from "./talerTypes";
|
} from "./talerTypes.js";
|
||||||
import {
|
import {
|
||||||
Codec,
|
Codec,
|
||||||
buildCodecForObject,
|
buildCodecForObject,
|
||||||
@ -41,8 +41,8 @@ import {
|
|||||||
codecForString,
|
codecForString,
|
||||||
codecForList,
|
codecForList,
|
||||||
codecForAny,
|
codecForAny,
|
||||||
} from "../util/codec";
|
} from "./codec.js";
|
||||||
import { TalerErrorDetails } from "./walletTypes";
|
import { TalerErrorDetails } from "./walletTypes.js";
|
||||||
|
|
||||||
export interface TransactionsRequest {
|
export interface TransactionsRequest {
|
||||||
/**
|
/**
|
74
packages/taler-util/src/url.ts
Normal file
74
packages/taler-util/src/url.ts
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
/*
|
||||||
|
This file is part of GNU Taler
|
||||||
|
(C) 2020 Taler Systems S.A.
|
||||||
|
|
||||||
|
GNU Taler is free software; you can redistribute it and/or modify it under the
|
||||||
|
terms of the GNU General Public License as published by the Free Software
|
||||||
|
Foundation; either version 3, or (at your option) any later version.
|
||||||
|
|
||||||
|
GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License along with
|
||||||
|
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*/
|
||||||
|
|
||||||
|
interface URL {
|
||||||
|
hash: string;
|
||||||
|
host: string;
|
||||||
|
hostname: string;
|
||||||
|
href: string;
|
||||||
|
toString(): string;
|
||||||
|
readonly origin: string;
|
||||||
|
password: string;
|
||||||
|
pathname: string;
|
||||||
|
port: string;
|
||||||
|
protocol: string;
|
||||||
|
search: string;
|
||||||
|
readonly searchParams: URLSearchParams;
|
||||||
|
username: string;
|
||||||
|
toJSON(): string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface URLSearchParams {
|
||||||
|
append(name: string, value: string): void;
|
||||||
|
delete(name: string): void;
|
||||||
|
get(name: string): string | null;
|
||||||
|
getAll(name: string): string[];
|
||||||
|
has(name: string): boolean;
|
||||||
|
set(name: string, value: string): void;
|
||||||
|
sort(): void;
|
||||||
|
toString(): string;
|
||||||
|
forEach(
|
||||||
|
callbackfn: (value: string, key: string, parent: URLSearchParams) => void,
|
||||||
|
thisArg?: any,
|
||||||
|
): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface URLSearchParamsCtor {
|
||||||
|
new (
|
||||||
|
init?: string[][] | Record<string, string> | string | URLSearchParams,
|
||||||
|
): URLSearchParams;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface URLCtor {
|
||||||
|
new (url: string, base?: string | URL): URL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
|
const _URL = globalThis.URL;
|
||||||
|
if (!_URL) {
|
||||||
|
throw Error("FATAL: URL not available");
|
||||||
|
}
|
||||||
|
|
||||||
|
export const URL: URLCtor = _URL;
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
|
const _URLSearchParams = globalThis.URLSearchParams;
|
||||||
|
|
||||||
|
if (!_URLSearchParams) {
|
||||||
|
throw Error("FATAL: URLSearchParams not available");
|
||||||
|
}
|
||||||
|
|
||||||
|
export const URLSearchParams: URLSearchParamsCtor = _URLSearchParams;
|
@ -31,14 +31,9 @@ import {
|
|||||||
AmountJson,
|
AmountJson,
|
||||||
codecForAmountJson,
|
codecForAmountJson,
|
||||||
codecForAmountString,
|
codecForAmountString,
|
||||||
} from "../util/amounts";
|
} from "./amounts.js";
|
||||||
import * as LibtoolVersion from "../util/libtoolVersion";
|
import * as LibtoolVersion from "./libtool-version.js";
|
||||||
import {
|
import { Timestamp, codecForTimestamp } from "./time.js";
|
||||||
ExchangeRecord,
|
|
||||||
ExchangeWireInfo,
|
|
||||||
DenominationSelectionInfo,
|
|
||||||
} from "./dbTypes";
|
|
||||||
import { Timestamp, codecForTimestamp } from "../util/time";
|
|
||||||
import {
|
import {
|
||||||
buildCodecForObject,
|
buildCodecForObject,
|
||||||
codecForString,
|
codecForString,
|
||||||
@ -49,14 +44,14 @@ import {
|
|||||||
codecForConstString,
|
codecForConstString,
|
||||||
codecForAny,
|
codecForAny,
|
||||||
buildCodecForUnion,
|
buildCodecForUnion,
|
||||||
} from "../util/codec";
|
} from "./codec.js";
|
||||||
import {
|
import {
|
||||||
AmountString,
|
AmountString,
|
||||||
codecForContractTerms,
|
codecForContractTerms,
|
||||||
ContractTerms,
|
ContractTerms,
|
||||||
} from "./talerTypes";
|
} from "./talerTypes.js";
|
||||||
import { OrderShortInfo, codecForOrderShortInfo } from "./transactionsTypes";
|
import { OrderShortInfo, codecForOrderShortInfo } from "./transactionsTypes";
|
||||||
import { BackupRecovery } from "../operations/backup";
|
import { BackupRecovery } from "./backupTypes.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Response for the create reserve request to the wallet.
|
* Response for the create reserve request to the wallet.
|
||||||
@ -74,92 +69,7 @@ export class CreateReserveResponse {
|
|||||||
reservePub: string;
|
reservePub: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Information about what will happen when creating a reserve.
|
|
||||||
*
|
|
||||||
* Sent to the wallet frontend to be rendered and shown to the user.
|
|
||||||
*/
|
|
||||||
export interface ExchangeWithdrawDetails {
|
|
||||||
/**
|
|
||||||
* Exchange that the reserve will be created at.
|
|
||||||
*/
|
|
||||||
exchangeInfo: ExchangeRecord;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Filtered wire info to send to the bank.
|
|
||||||
*/
|
|
||||||
exchangeWireAccounts: string[];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Selected denominations for withdraw.
|
|
||||||
*/
|
|
||||||
selectedDenoms: DenominationSelectionInfo;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fees for withdraw.
|
|
||||||
*/
|
|
||||||
withdrawFee: AmountJson;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Remaining balance that is too small to be withdrawn.
|
|
||||||
*/
|
|
||||||
overhead: AmountJson;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Wire fees from the exchange.
|
|
||||||
*/
|
|
||||||
wireFees: ExchangeWireInfo;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Does the wallet know about an auditor for
|
|
||||||
* the exchange that the reserve.
|
|
||||||
*/
|
|
||||||
isAudited: boolean;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Did the user already accept the current terms of service for the exchange?
|
|
||||||
*/
|
|
||||||
termsOfServiceAccepted: boolean;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The exchange is trusted directly.
|
|
||||||
*/
|
|
||||||
isTrusted: boolean;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The earliest deposit expiration of the selected coins.
|
|
||||||
*/
|
|
||||||
earliestDepositExpiration: Timestamp;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Number of currently offered denominations.
|
|
||||||
*/
|
|
||||||
numOfferedDenoms: number;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Public keys of trusted auditors for the currency we're withdrawing.
|
|
||||||
*/
|
|
||||||
trustedAuditorPubs: string[];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Result of checking the wallet's version
|
|
||||||
* against the exchange's version.
|
|
||||||
*
|
|
||||||
* Older exchanges don't return version information.
|
|
||||||
*/
|
|
||||||
versionMatch: LibtoolVersion.VersionMatchResult | undefined;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Libtool-style version string for the exchange or "unknown"
|
|
||||||
* for older exchanges.
|
|
||||||
*/
|
|
||||||
exchangeVersion: string;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Libtool-style version string for the wallet.
|
|
||||||
*/
|
|
||||||
walletVersion: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Balance {
|
export interface Balance {
|
||||||
available: AmountString;
|
available: AmountString;
|
27
packages/taler-util/tsconfig.json
Normal file
27
packages/taler-util/tsconfig.json
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
{
|
||||||
|
"compileOnSave": true,
|
||||||
|
"compilerOptions": {
|
||||||
|
"composite": true,
|
||||||
|
"declaration": true,
|
||||||
|
"declarationMap": false,
|
||||||
|
"target": "ES6",
|
||||||
|
"module": "ESNext",
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"sourceMap": true,
|
||||||
|
"lib": ["es6"],
|
||||||
|
"types": ["node"],
|
||||||
|
"noImplicitReturns": true,
|
||||||
|
"noFallthroughCasesInSwitch": true,
|
||||||
|
"strict": true,
|
||||||
|
"strictPropertyInitialization": false,
|
||||||
|
"outDir": "lib",
|
||||||
|
"noImplicitAny": true,
|
||||||
|
"noImplicitThis": true,
|
||||||
|
"incremental": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"importHelpers": true,
|
||||||
|
"rootDir": "./src",
|
||||||
|
"typeRoots": ["./node_modules/@types"]
|
||||||
|
},
|
||||||
|
"include": ["src/**/*"]
|
||||||
|
}
|
@ -44,6 +44,7 @@
|
|||||||
"typescript": "^4.1.3"
|
"typescript": "^4.1.3"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@gnu-taler/taler-util": "workspace:*",
|
||||||
"@gnu-taler/taler-wallet-core": "workspace:*",
|
"@gnu-taler/taler-wallet-core": "workspace:*",
|
||||||
"@types/minimatch": "^3.0.3",
|
"@types/minimatch": "^3.0.3",
|
||||||
"axios": "^0.21.1",
|
"axios": "^0.21.1",
|
||||||
|
@ -14,34 +14,16 @@
|
|||||||
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/>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Imports.
|
||||||
|
*/
|
||||||
import os from "os";
|
import os from "os";
|
||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
import {
|
import * as clk from "./clk.js";
|
||||||
getDefaultNodeWallet,
|
|
||||||
Logger,
|
|
||||||
Amounts,
|
|
||||||
Wallet,
|
|
||||||
OperationFailedAndReportedError,
|
|
||||||
OperationFailedError,
|
|
||||||
NodeHttpLib,
|
|
||||||
PreparePayResultType,
|
|
||||||
setDangerousTimetravel,
|
|
||||||
classifyTalerUri,
|
|
||||||
TalerUriType,
|
|
||||||
decodeCrock,
|
|
||||||
addPaytoQueryParams,
|
|
||||||
codecForList,
|
|
||||||
codecForString,
|
|
||||||
printTestVectors,
|
|
||||||
NodeThreadCryptoWorkerFactory,
|
|
||||||
CryptoApi,
|
|
||||||
rsaBlind,
|
|
||||||
RecoveryMergeStrategy,
|
|
||||||
stringToBytes,
|
|
||||||
} from "@gnu-taler/taler-wallet-core";
|
|
||||||
import * as clk from "./clk";
|
|
||||||
import { deepStrictEqual } from "assert";
|
import { deepStrictEqual } from "assert";
|
||||||
import { getTestInfo, runTests } from "./integrationtests/testrunner";
|
import { getTestInfo, runTests } from "./integrationtests/testrunner.js";
|
||||||
|
import { PreparePayResultType, setDangerousTimetravel, classifyTalerUri, TalerUriType, RecoveryMergeStrategy, Amounts, addPaytoQueryParams, codecForList, codecForString } from "@gnu-taler/taler-util";
|
||||||
|
import { Logger, Wallet, NodeHttpLib, getDefaultNodeWallet, OperationFailedAndReportedError, OperationFailedError, decodeCrock, rsaBlind, NodeThreadCryptoWorkerFactory, CryptoApi } from "@gnu-taler/taler-wallet-core";
|
||||||
|
|
||||||
// This module also serves as the entry point for the crypto
|
// This module also serves as the entry point for the crypto
|
||||||
// thread worker, and thus must expose these two handlers.
|
// thread worker, and thus must expose these two handlers.
|
||||||
@ -811,9 +793,6 @@ testCli
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
testCli.subcommand("vectors", "vectors").action(async (args) => {
|
|
||||||
printTestVectors();
|
|
||||||
});
|
|
||||||
|
|
||||||
async function read(stream: NodeJS.ReadStream) {
|
async function read(stream: NodeJS.ReadStream) {
|
||||||
const chunks = [];
|
const chunks = [];
|
||||||
|
@ -30,60 +30,6 @@ import * as path from "path";
|
|||||||
import * as http from "http";
|
import * as http from "http";
|
||||||
import { deepStrictEqual } from "assert";
|
import { deepStrictEqual } from "assert";
|
||||||
import { ChildProcess, spawn } from "child_process";
|
import { ChildProcess, spawn } from "child_process";
|
||||||
import {
|
|
||||||
Configuration,
|
|
||||||
AmountJson,
|
|
||||||
Amounts,
|
|
||||||
Codec,
|
|
||||||
buildCodecForObject,
|
|
||||||
codecForString,
|
|
||||||
Duration,
|
|
||||||
CoreApiResponse,
|
|
||||||
PreparePayResult,
|
|
||||||
PreparePayRequest,
|
|
||||||
codecForPreparePayResult,
|
|
||||||
OperationFailedError,
|
|
||||||
AddExchangeRequest,
|
|
||||||
ExchangesListRespose,
|
|
||||||
codecForExchangesListResponse,
|
|
||||||
GetWithdrawalDetailsForUriRequest,
|
|
||||||
WithdrawUriInfoResponse,
|
|
||||||
codecForWithdrawUriInfoResponse,
|
|
||||||
ConfirmPayRequest,
|
|
||||||
ConfirmPayResult,
|
|
||||||
codecForConfirmPayResult,
|
|
||||||
IntegrationTestArgs,
|
|
||||||
TestPayArgs,
|
|
||||||
BalancesResponse,
|
|
||||||
codecForBalancesResponse,
|
|
||||||
encodeCrock,
|
|
||||||
getRandomBytes,
|
|
||||||
EddsaKeyPair,
|
|
||||||
eddsaGetPublic,
|
|
||||||
createEddsaKeyPair,
|
|
||||||
TransactionsResponse,
|
|
||||||
codecForTransactionsResponse,
|
|
||||||
WithdrawTestBalanceRequest,
|
|
||||||
AmountString,
|
|
||||||
ApplyRefundRequest,
|
|
||||||
codecForApplyRefundResponse,
|
|
||||||
codecForAny,
|
|
||||||
CoinDumpJson,
|
|
||||||
ForceExchangeUpdateRequest,
|
|
||||||
ForceRefreshRequest,
|
|
||||||
PrepareTipResult,
|
|
||||||
PrepareTipRequest,
|
|
||||||
codecForPrepareTipResult,
|
|
||||||
AcceptTipRequest,
|
|
||||||
AbortPayWithRefundRequest,
|
|
||||||
openPromise,
|
|
||||||
parsePaytoUri,
|
|
||||||
CreateDepositGroupRequest,
|
|
||||||
CreateDepositGroupResponse,
|
|
||||||
TrackDepositGroupRequest,
|
|
||||||
TrackDepositGroupResponse,
|
|
||||||
RecoveryLoadRequest,
|
|
||||||
} from "@gnu-taler/taler-wallet-core";
|
|
||||||
import { URL } from "url";
|
import { URL } from "url";
|
||||||
import axios, { AxiosError } from "axios";
|
import axios, { AxiosError } from "axios";
|
||||||
import {
|
import {
|
||||||
@ -97,14 +43,70 @@ import {
|
|||||||
TipCreateRequest,
|
TipCreateRequest,
|
||||||
MerchantInstancesResponse,
|
MerchantInstancesResponse,
|
||||||
} from "./merchantApiTypes";
|
} from "./merchantApiTypes";
|
||||||
import { ApplyRefundResponse } from "@gnu-taler/taler-wallet-core";
|
import {
|
||||||
import { PendingOperationsResponse } from "@gnu-taler/taler-wallet-core";
|
createEddsaKeyPair,
|
||||||
import { CoinConfig } from "./denomStructures";
|
eddsaGetPublic,
|
||||||
|
EddsaKeyPair,
|
||||||
|
encodeCrock,
|
||||||
|
getRandomBytes,
|
||||||
|
openPromise,
|
||||||
|
OperationFailedError,
|
||||||
|
} from "@gnu-taler/taler-wallet-core";
|
||||||
|
import {
|
||||||
|
AmountJson,
|
||||||
|
Amounts,
|
||||||
|
Configuration,
|
||||||
|
AmountString,
|
||||||
|
Codec,
|
||||||
|
buildCodecForObject,
|
||||||
|
codecForString,
|
||||||
|
Duration,
|
||||||
|
parsePaytoUri,
|
||||||
|
CoreApiResponse,
|
||||||
|
ApplyRefundRequest,
|
||||||
|
ApplyRefundResponse,
|
||||||
|
codecForApplyRefundResponse,
|
||||||
|
PreparePayRequest,
|
||||||
|
PreparePayResult,
|
||||||
|
codecForPreparePayResult,
|
||||||
|
CreateDepositGroupRequest,
|
||||||
|
CreateDepositGroupResponse,
|
||||||
|
AbortPayWithRefundRequest,
|
||||||
|
ConfirmPayRequest,
|
||||||
|
ConfirmPayResult,
|
||||||
|
codecForConfirmPayResult,
|
||||||
|
PrepareTipRequest,
|
||||||
|
PrepareTipResult,
|
||||||
|
codecForPrepareTipResult,
|
||||||
|
AcceptTipRequest,
|
||||||
|
CoinDumpJson,
|
||||||
|
codecForAny,
|
||||||
|
AddExchangeRequest,
|
||||||
|
ForceExchangeUpdateRequest,
|
||||||
|
ForceRefreshRequest,
|
||||||
|
ExchangesListRespose,
|
||||||
|
codecForExchangesListResponse,
|
||||||
|
BalancesResponse,
|
||||||
|
codecForBalancesResponse,
|
||||||
|
TransactionsResponse,
|
||||||
|
codecForTransactionsResponse,
|
||||||
|
TrackDepositGroupRequest,
|
||||||
|
TrackDepositGroupResponse,
|
||||||
|
IntegrationTestArgs,
|
||||||
|
TestPayArgs,
|
||||||
|
WithdrawTestBalanceRequest,
|
||||||
|
GetWithdrawalDetailsForUriRequest,
|
||||||
|
WithdrawUriInfoResponse,
|
||||||
|
codecForWithdrawUriInfoResponse,
|
||||||
|
BackupRecovery,
|
||||||
|
RecoveryLoadRequest,
|
||||||
|
} from "@gnu-taler/taler-util";
|
||||||
import {
|
import {
|
||||||
AddBackupProviderRequest,
|
AddBackupProviderRequest,
|
||||||
BackupInfo,
|
BackupInfo,
|
||||||
BackupRecovery,
|
|
||||||
} from "@gnu-taler/taler-wallet-core/src/operations/backup";
|
} from "@gnu-taler/taler-wallet-core/src/operations/backup";
|
||||||
|
import { PendingOperationsResponse } from "@gnu-taler/taler-wallet-core/src/pending-types";
|
||||||
|
import { CoinConfig } from "./denomStructures.js";
|
||||||
|
|
||||||
const exec = util.promisify(require("child_process").exec);
|
const exec = util.promisify(require("child_process").exec);
|
||||||
|
|
||||||
@ -486,7 +488,7 @@ export async function pingProc(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ExchangeBankAccount {
|
export interface HarnessExchangeBankAccount {
|
||||||
accountName: string;
|
accountName: string;
|
||||||
accountPassword: string;
|
accountPassword: string;
|
||||||
accountPaytoUri: string;
|
accountPaytoUri: string;
|
||||||
@ -573,7 +575,7 @@ export namespace BankApi {
|
|||||||
export async function adminAddIncoming(
|
export async function adminAddIncoming(
|
||||||
bank: BankServiceInterface,
|
bank: BankServiceInterface,
|
||||||
params: {
|
params: {
|
||||||
exchangeBankAccount: ExchangeBankAccount;
|
exchangeBankAccount: HarnessExchangeBankAccount;
|
||||||
amount: string;
|
amount: string;
|
||||||
reservePub: string;
|
reservePub: string;
|
||||||
debitAccountPayto: string;
|
debitAccountPayto: string;
|
||||||
@ -701,7 +703,7 @@ export class BankService implements BankServiceInterface {
|
|||||||
async createExchangeAccount(
|
async createExchangeAccount(
|
||||||
accountName: string,
|
accountName: string,
|
||||||
password: string,
|
password: string,
|
||||||
): Promise<ExchangeBankAccount> {
|
): Promise<HarnessExchangeBankAccount> {
|
||||||
await sh(
|
await sh(
|
||||||
this.globalTestState,
|
this.globalTestState,
|
||||||
"taler-bank-manage_django",
|
"taler-bank-manage_django",
|
||||||
@ -944,7 +946,7 @@ export class ExchangeService implements ExchangeServiceInterface {
|
|||||||
|
|
||||||
async addBankAccount(
|
async addBankAccount(
|
||||||
localName: string,
|
localName: string,
|
||||||
exchangeBankAccount: ExchangeBankAccount,
|
exchangeBankAccount: HarnessExchangeBankAccount,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const config = Configuration.load(this.configFilename);
|
const config = Configuration.load(this.configFilename);
|
||||||
config.setString(
|
config.setString(
|
||||||
|
@ -23,39 +23,39 @@
|
|||||||
/**
|
/**
|
||||||
* Imports
|
* Imports
|
||||||
*/
|
*/
|
||||||
import {
|
|
||||||
GlobalTestState,
|
|
||||||
DbInfo,
|
|
||||||
ExchangeService,
|
|
||||||
WalletCli,
|
|
||||||
MerchantService,
|
|
||||||
setupDb,
|
|
||||||
BankService,
|
|
||||||
ExchangeBankAccount,
|
|
||||||
MerchantServiceInterface,
|
|
||||||
BankApi,
|
|
||||||
BankAccessApi,
|
|
||||||
MerchantPrivateApi,
|
|
||||||
ExchangeServiceInterface,
|
|
||||||
} from "./harness";
|
|
||||||
import {
|
|
||||||
AmountString,
|
|
||||||
Duration,
|
|
||||||
PreparePayResultType,
|
|
||||||
ConfirmPayResultType,
|
|
||||||
ContractTerms,
|
|
||||||
} from "@gnu-taler/taler-wallet-core";
|
|
||||||
import {
|
import {
|
||||||
FaultInjectedExchangeService,
|
FaultInjectedExchangeService,
|
||||||
FaultInjectedMerchantService,
|
FaultInjectedMerchantService,
|
||||||
} from "./faultInjection";
|
} from "./faultInjection";
|
||||||
import { CoinConfig, defaultCoinConfig } from "./denomStructures";
|
import { CoinConfig, defaultCoinConfig } from "./denomStructures";
|
||||||
|
import {
|
||||||
|
AmountString,
|
||||||
|
Duration,
|
||||||
|
ContractTerms,
|
||||||
|
PreparePayResultType,
|
||||||
|
ConfirmPayResultType,
|
||||||
|
} from "@gnu-taler/taler-util";
|
||||||
|
import {
|
||||||
|
DbInfo,
|
||||||
|
BankService,
|
||||||
|
ExchangeService,
|
||||||
|
MerchantService,
|
||||||
|
WalletCli,
|
||||||
|
GlobalTestState,
|
||||||
|
setupDb,
|
||||||
|
ExchangeServiceInterface,
|
||||||
|
BankApi,
|
||||||
|
BankAccessApi,
|
||||||
|
MerchantServiceInterface,
|
||||||
|
MerchantPrivateApi,
|
||||||
|
HarnessExchangeBankAccount,
|
||||||
|
} from "./harness.js";
|
||||||
|
|
||||||
export interface SimpleTestEnvironment {
|
export interface SimpleTestEnvironment {
|
||||||
commonDb: DbInfo;
|
commonDb: DbInfo;
|
||||||
bank: BankService;
|
bank: BankService;
|
||||||
exchange: ExchangeService;
|
exchange: ExchangeService;
|
||||||
exchangeBankAccount: ExchangeBankAccount;
|
exchangeBankAccount: HarnessExchangeBankAccount;
|
||||||
merchant: MerchantService;
|
merchant: MerchantService;
|
||||||
wallet: WalletCli;
|
wallet: WalletCli;
|
||||||
}
|
}
|
||||||
@ -154,7 +154,7 @@ export interface FaultyMerchantTestEnvironment {
|
|||||||
bank: BankService;
|
bank: BankService;
|
||||||
exchange: ExchangeService;
|
exchange: ExchangeService;
|
||||||
faultyExchange: FaultInjectedExchangeService;
|
faultyExchange: FaultInjectedExchangeService;
|
||||||
exchangeBankAccount: ExchangeBankAccount;
|
exchangeBankAccount: HarnessExchangeBankAccount;
|
||||||
merchant: MerchantService;
|
merchant: MerchantService;
|
||||||
faultyMerchant: FaultInjectedMerchantService;
|
faultyMerchant: FaultInjectedMerchantService;
|
||||||
wallet: WalletCli;
|
wallet: WalletCli;
|
||||||
|
@ -41,7 +41,7 @@ import {
|
|||||||
Timestamp,
|
Timestamp,
|
||||||
CoinPublicKeyString,
|
CoinPublicKeyString,
|
||||||
EddsaPublicKeyString,
|
EddsaPublicKeyString,
|
||||||
} from "@gnu-taler/taler-wallet-core";
|
} from "@gnu-taler/taler-util";
|
||||||
import { codecForAmountString } from "@gnu-taler/taler-wallet-core/lib/util/amounts";
|
import { codecForAmountString } from "@gnu-taler/taler-wallet-core/lib/util/amounts";
|
||||||
|
|
||||||
export interface PostOrderRequest {
|
export interface PostOrderRequest {
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
* Imports.
|
* Imports.
|
||||||
*/
|
*/
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { Configuration, URL } from "@gnu-taler/taler-wallet-core";
|
import { URL } from "@gnu-taler/taler-wallet-core";
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import * as util from "util";
|
import * as util from "util";
|
||||||
import {
|
import {
|
||||||
@ -30,6 +30,7 @@ import {
|
|||||||
setupDb,
|
setupDb,
|
||||||
sh,
|
sh,
|
||||||
} from "./harness";
|
} from "./harness";
|
||||||
|
import { Configuration } from "@gnu-taler/taler-util";
|
||||||
|
|
||||||
const exec = util.promisify(require("child_process").exec);
|
const exec = util.promisify(require("child_process").exec);
|
||||||
|
|
||||||
|
@ -28,11 +28,9 @@ import {
|
|||||||
BankAccessApi,
|
BankAccessApi,
|
||||||
} from "./harness";
|
} from "./harness";
|
||||||
import {
|
import {
|
||||||
PreparePayResultType,
|
|
||||||
ExchangesListRespose,
|
|
||||||
URL,
|
URL,
|
||||||
TalerErrorCode,
|
|
||||||
} from "@gnu-taler/taler-wallet-core";
|
} from "@gnu-taler/taler-wallet-core";
|
||||||
|
import { ExchangesListRespose, TalerErrorCode } from "@gnu-taler/taler-util";
|
||||||
import {
|
import {
|
||||||
FaultInjectedExchangeService,
|
FaultInjectedExchangeService,
|
||||||
FaultInjectionResponseContext,
|
FaultInjectionResponseContext,
|
||||||
|
@ -17,11 +17,11 @@
|
|||||||
/**
|
/**
|
||||||
* Imports.
|
* Imports.
|
||||||
*/
|
*/
|
||||||
import { CoreApiResponse } from "@gnu-taler/taler-wallet-core";
|
import { CoreApiResponse } from "@gnu-taler/taler-util";
|
||||||
import { CoinConfig, defaultCoinConfig } from "./denomStructures";
|
import { CoinConfig, defaultCoinConfig } from "./denomStructures";
|
||||||
import {
|
import {
|
||||||
DbInfo,
|
DbInfo,
|
||||||
ExchangeBankAccount,
|
HarnessExchangeBankAccount,
|
||||||
ExchangeService,
|
ExchangeService,
|
||||||
GlobalTestState,
|
GlobalTestState,
|
||||||
MerchantService,
|
MerchantService,
|
||||||
@ -44,7 +44,7 @@ const merchantIban = "DE42500105171245624648";
|
|||||||
export interface LibeufinTestEnvironment {
|
export interface LibeufinTestEnvironment {
|
||||||
commonDb: DbInfo;
|
commonDb: DbInfo;
|
||||||
exchange: ExchangeService;
|
exchange: ExchangeService;
|
||||||
exchangeBankAccount: ExchangeBankAccount;
|
exchangeBankAccount: HarnessExchangeBankAccount;
|
||||||
merchant: MerchantService;
|
merchant: MerchantService;
|
||||||
wallet: WalletCli;
|
wallet: WalletCli;
|
||||||
libeufinSandbox: LibeufinSandboxService;
|
libeufinSandbox: LibeufinSandboxService;
|
||||||
@ -181,7 +181,7 @@ export async function createLibeufinTestEnvironment(
|
|||||||
database: db.connStr,
|
database: db.connStr,
|
||||||
});
|
});
|
||||||
|
|
||||||
const exchangeBankAccount: ExchangeBankAccount = {
|
const exchangeBankAccount: HarnessExchangeBankAccount = {
|
||||||
accountName: "twguser",
|
accountName: "twguser",
|
||||||
accountPassword: "twgpw",
|
accountPassword: "twgpw",
|
||||||
accountPaytoUri: `payto://iban/${exchangeIban}?receiver-name=Exchange`,
|
accountPaytoUri: `payto://iban/${exchangeIban}?receiver-name=Exchange`,
|
||||||
|
@ -17,15 +17,11 @@
|
|||||||
/**
|
/**
|
||||||
* Imports.
|
* Imports.
|
||||||
*/
|
*/
|
||||||
import { CoreApiResponse } from "@gnu-taler/taler-wallet-core";
|
|
||||||
import { CoinConfig, defaultCoinConfig } from "./denomStructures";
|
|
||||||
import { GlobalTestState } from "./harness";
|
import { GlobalTestState } from "./harness";
|
||||||
import { getRandomIban } from "./helpers";
|
|
||||||
import {
|
import {
|
||||||
SandboxUserBundle,
|
SandboxUserBundle,
|
||||||
NexusUserBundle,
|
NexusUserBundle,
|
||||||
launchLibeufinServices,
|
launchLibeufinServices,
|
||||||
LibeufinNexusApi,
|
|
||||||
LibeufinSandboxApi,
|
LibeufinSandboxApi,
|
||||||
} from "./libeufin";
|
} from "./libeufin";
|
||||||
|
|
||||||
|
@ -17,13 +17,9 @@
|
|||||||
/**
|
/**
|
||||||
* Imports.
|
* Imports.
|
||||||
*/
|
*/
|
||||||
import { CoreApiResponse } from "@gnu-taler/taler-wallet-core";
|
|
||||||
import { CoinConfig, defaultCoinConfig } from "./denomStructures";
|
|
||||||
import { GlobalTestState } from "./harness";
|
import { GlobalTestState } from "./harness";
|
||||||
import {
|
import {
|
||||||
LibeufinNexusApi,
|
|
||||||
LibeufinNexusService,
|
LibeufinNexusService,
|
||||||
LibeufinSandboxApi,
|
|
||||||
LibeufinSandboxService,
|
LibeufinSandboxService,
|
||||||
LibeufinCli,
|
LibeufinCli,
|
||||||
} from "./libeufin";
|
} from "./libeufin";
|
||||||
|
@ -35,8 +35,7 @@ import {
|
|||||||
PreparePayResultType,
|
PreparePayResultType,
|
||||||
codecForMerchantOrderStatusUnpaid,
|
codecForMerchantOrderStatusUnpaid,
|
||||||
ConfirmPayResultType,
|
ConfirmPayResultType,
|
||||||
URL,
|
} from "@gnu-taler/taler-util";
|
||||||
} from "@gnu-taler/taler-wallet-core";
|
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import {
|
import {
|
||||||
FaultInjectedExchangeService,
|
FaultInjectedExchangeService,
|
||||||
|
@ -23,9 +23,9 @@ import {
|
|||||||
PreparePayResultType,
|
PreparePayResultType,
|
||||||
codecForMerchantOrderStatusUnpaid,
|
codecForMerchantOrderStatusUnpaid,
|
||||||
ConfirmPayResultType,
|
ConfirmPayResultType,
|
||||||
URL,
|
} from "@gnu-taler/taler-util";
|
||||||
} from "@gnu-taler/taler-wallet-core";
|
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
|
import { URL } from "@gnu-taler/taler-wallet-core";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run test for basic, bank-integrated withdrawal.
|
* Run test for basic, bank-integrated withdrawal.
|
||||||
|
@ -33,9 +33,9 @@ import {
|
|||||||
import {
|
import {
|
||||||
durationFromSpec,
|
durationFromSpec,
|
||||||
PreparePayResultType,
|
PreparePayResultType,
|
||||||
URL,
|
} from "@gnu-taler/taler-util";
|
||||||
} from "@gnu-taler/taler-wallet-core";
|
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
|
import { URL } from "@gnu-taler/taler-wallet-core";
|
||||||
|
|
||||||
async function testRefundApiWithFulfillmentUrl(
|
async function testRefundApiWithFulfillmentUrl(
|
||||||
t: GlobalTestState,
|
t: GlobalTestState,
|
||||||
|
@ -22,9 +22,8 @@
|
|||||||
/**
|
/**
|
||||||
* Imports.
|
* Imports.
|
||||||
*/
|
*/
|
||||||
|
import { PreparePayResultType, TalerErrorCode } from "@gnu-taler/taler-util";
|
||||||
import {
|
import {
|
||||||
PreparePayResultType,
|
|
||||||
TalerErrorCode,
|
|
||||||
URL,
|
URL,
|
||||||
} from "@gnu-taler/taler-wallet-core";
|
} from "@gnu-taler/taler-wallet-core";
|
||||||
import {
|
import {
|
||||||
|
@ -26,10 +26,10 @@ import {
|
|||||||
PreparePayResultType,
|
PreparePayResultType,
|
||||||
codecForMerchantOrderStatusUnpaid,
|
codecForMerchantOrderStatusUnpaid,
|
||||||
ConfirmPayResultType,
|
ConfirmPayResultType,
|
||||||
URL,
|
} from "@gnu-taler/taler-util";
|
||||||
} from "@gnu-taler/taler-wallet-core";
|
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { FaultInjectionRequestContext } from "./faultInjection";
|
import { FaultInjectionRequestContext } from "./faultInjection";
|
||||||
|
import { URL } from "@gnu-taler/taler-wallet-core";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run test for the wallets repurchase detection mechanism
|
* Run test for the wallets repurchase detection mechanism
|
||||||
|
@ -21,8 +21,8 @@ import { GlobalTestState, MerchantPrivateApi, WalletCli } from "./harness";
|
|||||||
import { createSimpleTestkudosEnvironment, withdrawViaBank } from "./helpers";
|
import { createSimpleTestkudosEnvironment, withdrawViaBank } from "./helpers";
|
||||||
import {
|
import {
|
||||||
PreparePayResultType,
|
PreparePayResultType,
|
||||||
TalerErrorCode,
|
} from "@gnu-taler/taler-util";
|
||||||
} from "@gnu-taler/taler-wallet-core";
|
import { TalerErrorCode } from "@gnu-taler/taler-util";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run test for basic, bank-integrated withdrawal.
|
* Run test for basic, bank-integrated withdrawal.
|
||||||
|
@ -37,7 +37,7 @@ import {
|
|||||||
FaultInjectionRequestContext,
|
FaultInjectionRequestContext,
|
||||||
FaultInjectionResponseContext,
|
FaultInjectionResponseContext,
|
||||||
} from "./faultInjection";
|
} from "./faultInjection";
|
||||||
import { CoreApiResponse } from "@gnu-taler/taler-wallet-core";
|
import { CoreApiResponse } from "@gnu-taler/taler-util";
|
||||||
import { defaultCoinConfig } from "./denomStructures";
|
import { defaultCoinConfig } from "./denomStructures";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
*/
|
*/
|
||||||
import { GlobalTestState, MerchantPrivateApi } from "./harness";
|
import { GlobalTestState, MerchantPrivateApi } from "./harness";
|
||||||
import { createSimpleTestkudosEnvironment, withdrawViaBank } from "./helpers";
|
import { createSimpleTestkudosEnvironment, withdrawViaBank } from "./helpers";
|
||||||
import { PreparePayResultType } from "@gnu-taler/taler-wallet-core";
|
import { PreparePayResultType } from "@gnu-taler/taler-util";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the wallet-core payment API, especially that repeated operations
|
* Test the wallet-core payment API, especially that repeated operations
|
||||||
|
@ -22,20 +22,13 @@ import {
|
|||||||
withdrawViaBank,
|
withdrawViaBank,
|
||||||
createFaultInjectedMerchantTestkudosEnvironment,
|
createFaultInjectedMerchantTestkudosEnvironment,
|
||||||
} from "./helpers";
|
} from "./helpers";
|
||||||
import {
|
|
||||||
PreparePayResultType,
|
|
||||||
codecForMerchantOrderStatusUnpaid,
|
|
||||||
ConfirmPayResultType,
|
|
||||||
URL,
|
|
||||||
codecForExchangeKeysJson,
|
|
||||||
TalerErrorDetails,
|
|
||||||
TalerErrorCode,
|
|
||||||
} from "@gnu-taler/taler-wallet-core";
|
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import {
|
import {
|
||||||
FaultInjectionRequestContext,
|
FaultInjectionRequestContext,
|
||||||
FaultInjectionResponseContext,
|
FaultInjectionResponseContext,
|
||||||
} from "./faultInjection";
|
} from "./faultInjection";
|
||||||
|
import { codecForMerchantOrderStatusUnpaid, ConfirmPayResultType, PreparePayResultType, TalerErrorCode, TalerErrorDetails } from "@gnu-taler/taler-util";
|
||||||
|
import { URL } from "@gnu-taler/taler-wallet-core";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run test for a payment where the merchant has a transient
|
* Run test for a payment where the merchant has a transient
|
||||||
|
@ -23,7 +23,7 @@ import {
|
|||||||
PreparePayResultType,
|
PreparePayResultType,
|
||||||
codecForMerchantOrderStatusUnpaid,
|
codecForMerchantOrderStatusUnpaid,
|
||||||
ConfirmPayResultType,
|
ConfirmPayResultType,
|
||||||
} from "@gnu-taler/taler-wallet-core";
|
} from "@gnu-taler/taler-util";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
*/
|
*/
|
||||||
import { GlobalTestState, MerchantPrivateApi } from "./harness";
|
import { GlobalTestState, MerchantPrivateApi } from "./harness";
|
||||||
import { createSimpleTestkudosEnvironment, withdrawViaBank } from "./helpers";
|
import { createSimpleTestkudosEnvironment, withdrawViaBank } from "./helpers";
|
||||||
import { durationFromSpec } from "@gnu-taler/taler-wallet-core";
|
import { durationFromSpec } from "@gnu-taler/taler-util";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run test for basic, bank-integrated withdrawal.
|
* Run test for basic, bank-integrated withdrawal.
|
||||||
|
@ -28,7 +28,7 @@ import {
|
|||||||
timestampAddDuration,
|
timestampAddDuration,
|
||||||
getTimestampNow,
|
getTimestampNow,
|
||||||
timestampTruncateToSecond,
|
timestampTruncateToSecond,
|
||||||
} from "@gnu-taler/taler-wallet-core";
|
} from "@gnu-taler/taler-util";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run test for basic, bank-integrated withdrawal.
|
* Run test for basic, bank-integrated withdrawal.
|
||||||
|
@ -23,7 +23,7 @@ import {
|
|||||||
TransactionType,
|
TransactionType,
|
||||||
Amounts,
|
Amounts,
|
||||||
durationFromSpec,
|
durationFromSpec,
|
||||||
} from "@gnu-taler/taler-wallet-core";
|
} from "@gnu-taler/taler-util";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run test for basic, bank-integrated withdrawal.
|
* Run test for basic, bank-integrated withdrawal.
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
/**
|
/**
|
||||||
* Imports.
|
* Imports.
|
||||||
*/
|
*/
|
||||||
import { durationFromSpec } from "@gnu-taler/taler-wallet-core";
|
import { durationFromSpec } from "@gnu-taler/taler-util";
|
||||||
import { GlobalTestState, MerchantPrivateApi } from "./harness";
|
import { GlobalTestState, MerchantPrivateApi } from "./harness";
|
||||||
import { createSimpleTestkudosEnvironment, withdrawViaBank } from "./helpers";
|
import { createSimpleTestkudosEnvironment, withdrawViaBank } from "./helpers";
|
||||||
|
|
||||||
|
@ -21,9 +21,9 @@ import {
|
|||||||
ConfirmPayResultType,
|
ConfirmPayResultType,
|
||||||
Duration,
|
Duration,
|
||||||
durationFromSpec,
|
durationFromSpec,
|
||||||
PendingOperationsResponse,
|
|
||||||
PreparePayResultType,
|
PreparePayResultType,
|
||||||
} from "@gnu-taler/taler-wallet-core";
|
} from "@gnu-taler/taler-util";
|
||||||
|
import { PendingOperationsResponse } from "@gnu-taler/taler-wallet-core";
|
||||||
import { makeNoFeeCoinConfig } from "./denomStructures";
|
import { makeNoFeeCoinConfig } from "./denomStructures";
|
||||||
import {
|
import {
|
||||||
BankService,
|
BankService,
|
||||||
|
@ -23,7 +23,7 @@ import {
|
|||||||
withdrawViaBank,
|
withdrawViaBank,
|
||||||
startWithdrawViaBank,
|
startWithdrawViaBank,
|
||||||
} from "./helpers";
|
} from "./helpers";
|
||||||
import { Duration, TransactionType } from "@gnu-taler/taler-wallet-core";
|
import { Duration, TransactionType } from "@gnu-taler/taler-util";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Basic time travel test.
|
* Basic time travel test.
|
||||||
|
@ -17,12 +17,9 @@
|
|||||||
/**
|
/**
|
||||||
* Imports.
|
* Imports.
|
||||||
*/
|
*/
|
||||||
import { PreparePayResultType } from "@gnu-taler/taler-wallet-core";
|
import { PreparePayResultType } from "@gnu-taler/taler-util";
|
||||||
import { testPay } from "@gnu-taler/taler-wallet-core/src/operations/testing";
|
|
||||||
import {
|
import {
|
||||||
GlobalTestState,
|
GlobalTestState,
|
||||||
BankApi,
|
|
||||||
BankAccessApi,
|
|
||||||
WalletCli,
|
WalletCli,
|
||||||
MerchantPrivateApi,
|
MerchantPrivateApi,
|
||||||
} from "./harness";
|
} from "./harness";
|
||||||
|
@ -17,12 +17,9 @@
|
|||||||
/**
|
/**
|
||||||
* Imports.
|
* Imports.
|
||||||
*/
|
*/
|
||||||
|
import { TalerErrorCode } from "@gnu-taler/taler-util";
|
||||||
import { GlobalTestState, BankApi, BankAccessApi } from "./harness";
|
import { GlobalTestState, BankApi, BankAccessApi } from "./harness";
|
||||||
import { createSimpleTestkudosEnvironment } from "./helpers";
|
import { createSimpleTestkudosEnvironment } from "./helpers";
|
||||||
import {
|
|
||||||
codecForBalancesResponse,
|
|
||||||
TalerErrorCode,
|
|
||||||
} from "@gnu-taler/taler-wallet-core";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run test for basic, bank-integrated withdrawal.
|
* Run test for basic, bank-integrated withdrawal.
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
*/
|
*/
|
||||||
import { GlobalTestState, BankApi, BankAccessApi } from "./harness";
|
import { GlobalTestState, BankApi, BankAccessApi } from "./harness";
|
||||||
import { createSimpleTestkudosEnvironment } from "./helpers";
|
import { createSimpleTestkudosEnvironment } from "./helpers";
|
||||||
import { codecForBalancesResponse } from "@gnu-taler/taler-wallet-core";
|
import { codecForBalancesResponse } from "@gnu-taler/taler-util";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run test for basic, bank-integrated withdrawal.
|
* Run test for basic, bank-integrated withdrawal.
|
||||||
|
@ -19,8 +19,8 @@
|
|||||||
*/
|
*/
|
||||||
import { GlobalTestState, BankApi } from "./harness";
|
import { GlobalTestState, BankApi } from "./harness";
|
||||||
import { createSimpleTestkudosEnvironment } from "./helpers";
|
import { createSimpleTestkudosEnvironment } from "./helpers";
|
||||||
import { CoreApiResponse } from "@gnu-taler/taler-wallet-core";
|
import { CoreApiResponse } from "@gnu-taler/taler-util";
|
||||||
import { codecForBalancesResponse } from "@gnu-taler/taler-wallet-core";
|
import { codecForBalancesResponse } from "@gnu-taler/taler-util";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run test for basic, bank-integrated withdrawal.
|
* Run test for basic, bank-integrated withdrawal.
|
||||||
|
@ -25,6 +25,9 @@
|
|||||||
"references": [
|
"references": [
|
||||||
{
|
{
|
||||||
"path": "../taler-wallet-core/"
|
"path": "../taler-wallet-core/"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "../taler-util/"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -58,6 +58,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@gnu-taler/idb-bridge": "workspace:*",
|
"@gnu-taler/idb-bridge": "workspace:*",
|
||||||
|
"@gnu-taler/taler-util": "workspace:*",
|
||||||
"@types/node": "^14.14.22",
|
"@types/node": "^14.14.22",
|
||||||
"axios": "^0.21.1",
|
"axios": "^0.21.1",
|
||||||
"big-integer": "^1.6.48",
|
"big-integer": "^1.6.48",
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
/**
|
/**
|
||||||
* Imports.
|
* Imports.
|
||||||
*/
|
*/
|
||||||
import { AmountJson } from "../util/amounts";
|
import { AmountJson } from "@gnu-taler/taler-util";
|
||||||
|
|
||||||
export interface RefreshNewDenomInfo {
|
export interface RefreshNewDenomInfo {
|
||||||
count: number;
|
count: number;
|
@ -22,11 +22,11 @@
|
|||||||
/**
|
/**
|
||||||
* Imports.
|
* Imports.
|
||||||
*/
|
*/
|
||||||
import { CoinRecord, DenominationRecord, WireFee } from "../../types/dbTypes";
|
import { CoinRecord, DenominationRecord, WireFee } from "../../db";
|
||||||
|
|
||||||
import { CryptoWorker } from "./cryptoWorker";
|
import { CryptoWorker } from "./cryptoWorker";
|
||||||
|
|
||||||
import { RecoupRequest, CoinDepositPermission } from "../../types/talerTypes";
|
import { RecoupRequest, CoinDepositPermission } from "@gnu-taler/taler-util";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
BenchmarkResult,
|
BenchmarkResult,
|
||||||
@ -34,7 +34,7 @@ import {
|
|||||||
PlanchetCreationRequest,
|
PlanchetCreationRequest,
|
||||||
DepositInfo,
|
DepositInfo,
|
||||||
MakeSyncSignatureRequest,
|
MakeSyncSignatureRequest,
|
||||||
} from "../../types/walletTypes";
|
} from "@gnu-taler/taler-util";
|
||||||
|
|
||||||
import * as timer from "../../util/timer";
|
import * as timer from "../../util/timer";
|
||||||
import { Logger } from "../../util/logging";
|
import { Logger } from "../../util/logging";
|
||||||
@ -44,7 +44,7 @@ import {
|
|||||||
DeriveRefreshSessionRequest,
|
DeriveRefreshSessionRequest,
|
||||||
DeriveTipRequest,
|
DeriveTipRequest,
|
||||||
SignTrackTransactionRequest,
|
SignTrackTransactionRequest,
|
||||||
} from "../../types/cryptoTypes";
|
} from "../cryptoTypes.js";
|
||||||
|
|
||||||
const logger = new Logger("cryptoApi.ts");
|
const logger = new Logger("cryptoApi.ts");
|
||||||
|
|
||||||
|
@ -26,23 +26,25 @@
|
|||||||
* Imports.
|
* Imports.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// FIXME: Crypto should not use DB Types!
|
||||||
import {
|
import {
|
||||||
CoinRecord,
|
CoinRecord,
|
||||||
DenominationRecord,
|
DenominationRecord,
|
||||||
RefreshPlanchet,
|
RefreshPlanchet,
|
||||||
WireFee,
|
WireFee,
|
||||||
CoinSourceType,
|
CoinSourceType,
|
||||||
} from "../../types/dbTypes";
|
} from "../../db.js";
|
||||||
|
|
||||||
import { CoinDepositPermission, RecoupRequest } from "../../types/talerTypes";
|
import { CoinDepositPermission, RecoupRequest } from "@gnu-taler/taler-util";
|
||||||
|
// FIXME: These types should be internal to the wallet!
|
||||||
import {
|
import {
|
||||||
BenchmarkResult,
|
BenchmarkResult,
|
||||||
PlanchetCreationResult,
|
PlanchetCreationResult,
|
||||||
PlanchetCreationRequest,
|
PlanchetCreationRequest,
|
||||||
DepositInfo,
|
DepositInfo,
|
||||||
MakeSyncSignatureRequest,
|
MakeSyncSignatureRequest,
|
||||||
} from "../../types/walletTypes";
|
} from "@gnu-taler/taler-util";
|
||||||
import { AmountJson, Amounts } from "../../util/amounts";
|
import { AmountJson, Amounts } from "@gnu-taler/taler-util";
|
||||||
import * as timer from "../../util/timer";
|
import * as timer from "../../util/timer";
|
||||||
import {
|
import {
|
||||||
encodeCrock,
|
encodeCrock,
|
||||||
@ -64,7 +66,7 @@ import {
|
|||||||
} from "../talerCrypto";
|
} from "../talerCrypto";
|
||||||
import { randomBytes } from "../primitives/nacl-fast";
|
import { randomBytes } from "../primitives/nacl-fast";
|
||||||
import { kdf } from "../primitives/kdf";
|
import { kdf } from "../primitives/kdf";
|
||||||
import { Timestamp, timestampTruncateToSecond } from "../../util/time";
|
import { Timestamp, timestampTruncateToSecond } from "@gnu-taler/taler-util";
|
||||||
|
|
||||||
import { Logger } from "../../util/logging";
|
import { Logger } from "../../util/logging";
|
||||||
import {
|
import {
|
||||||
@ -73,7 +75,7 @@ import {
|
|||||||
DeriveRefreshSessionRequest,
|
DeriveRefreshSessionRequest,
|
||||||
DeriveTipRequest,
|
DeriveTipRequest,
|
||||||
SignTrackTransactionRequest,
|
SignTrackTransactionRequest,
|
||||||
} from "../../types/cryptoTypes";
|
} from "../cryptoTypes.js";
|
||||||
|
|
||||||
const logger = new Logger("cryptoImplementation.ts");
|
const logger = new Logger("cryptoImplementation.ts");
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -28,11 +28,10 @@ import {
|
|||||||
import { RequestThrottler } from "../util/RequestThrottler";
|
import { RequestThrottler } from "../util/RequestThrottler";
|
||||||
import Axios, { AxiosResponse } from "axios";
|
import Axios, { AxiosResponse } from "axios";
|
||||||
import { OperationFailedError, makeErrorDetails } from "../operations/errors";
|
import { OperationFailedError, makeErrorDetails } from "../operations/errors";
|
||||||
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";
|
||||||
import { j2s } from "../util/helpers";
|
import { TalerErrorCode } from "@gnu-taler/taler-util";
|
||||||
|
|
||||||
const logger = new Logger("NodeHttpLib.ts");
|
const logger = new Logger("NodeHttpLib.ts");
|
||||||
|
|
||||||
|
@ -23,18 +23,20 @@
|
|||||||
* Imports.
|
* Imports.
|
||||||
*/
|
*/
|
||||||
import { Wallet } from "../wallet";
|
import { Wallet } from "../wallet";
|
||||||
import { MemoryBackend, BridgeIDBFactory, shimIndexedDB } from "@gnu-taler/idb-bridge";
|
import {
|
||||||
|
MemoryBackend,
|
||||||
|
BridgeIDBFactory,
|
||||||
|
shimIndexedDB,
|
||||||
|
} from "@gnu-taler/idb-bridge";
|
||||||
import { openTalerDatabase } from "../db";
|
import { openTalerDatabase } from "../db";
|
||||||
import { HttpRequestLibrary } from "../util/http";
|
import { HttpRequestLibrary } from "../util/http";
|
||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
import { NodeThreadCryptoWorkerFactory } from "../crypto/workers/nodeThreadWorker";
|
import { NodeThreadCryptoWorkerFactory } from "../crypto/workers/nodeThreadWorker";
|
||||||
import { WalletNotification } from "../types/notifications";
|
|
||||||
import { Database } from "../util/query";
|
|
||||||
import { NodeHttpLib } from "./NodeHttpLib";
|
import { NodeHttpLib } from "./NodeHttpLib";
|
||||||
import { Logger } from "../util/logging";
|
import { Logger } from "../util/logging";
|
||||||
import { SynchronousCryptoWorkerFactory } from "../crypto/workers/synchronousWorker";
|
import { SynchronousCryptoWorkerFactory } from "../crypto/workers/synchronousWorker";
|
||||||
import type { IDBFactory } from "@gnu-taler/idb-bridge/lib/idbtypes";
|
import type { IDBFactory } from "@gnu-taler/idb-bridge";
|
||||||
import { Stores } from "../types/dbTypes";
|
import { WalletNotification } from "@gnu-taler/taler-util";
|
||||||
|
|
||||||
const logger = new Logger("headless/helpers.ts");
|
const logger = new Logger("headless/helpers.ts");
|
||||||
|
|
||||||
|
@ -21,7 +21,6 @@
|
|||||||
export { Wallet } from "./wallet";
|
export { Wallet } from "./wallet";
|
||||||
|
|
||||||
// Errors
|
// Errors
|
||||||
export { TalerErrorCode } from "./TalerErrorCode";
|
|
||||||
export * from "./operations/errors";
|
export * from "./operations/errors";
|
||||||
|
|
||||||
// Utils for using the wallet under node
|
// Utils for using the wallet under node
|
||||||
@ -34,7 +33,6 @@ export {
|
|||||||
export * from "./operations/versions";
|
export * from "./operations/versions";
|
||||||
|
|
||||||
export * from "./db";
|
export * from "./db";
|
||||||
export * from "./types/dbTypes";
|
|
||||||
|
|
||||||
// Internationalization
|
// Internationalization
|
||||||
export * from "./i18n";
|
export * from "./i18n";
|
||||||
@ -47,22 +45,10 @@ export { CryptoWorkerFactory, CryptoApi } from "./crypto/workers/cryptoApi";
|
|||||||
export * from "./crypto/talerCrypto";
|
export * from "./crypto/talerCrypto";
|
||||||
|
|
||||||
// Util functionality
|
// Util functionality
|
||||||
export { Amounts, AmountJson } from "./util/amounts";
|
|
||||||
export { Logger } from "./util/logging";
|
export { Logger } from "./util/logging";
|
||||||
export { Configuration } from "./util/talerconfig";
|
|
||||||
export { URL } from "./util/url";
|
export { URL } from "./util/url";
|
||||||
export * from "./util/codec";
|
|
||||||
export * from "./util/promiseUtils";
|
export * from "./util/promiseUtils";
|
||||||
export * from "./util/query";
|
export * from "./util/query";
|
||||||
export * from "./util/http";
|
export * from "./util/http";
|
||||||
export * from "./util/payto";
|
|
||||||
export * from "./util/testvectors";
|
|
||||||
export * from "./util/taleruri";
|
|
||||||
export * from "./util/time";
|
|
||||||
|
|
||||||
// Types
|
export * from "./pending-types";
|
||||||
export * from "./types/talerTypes";
|
|
||||||
export * from "./types/walletTypes";
|
|
||||||
export * from "./types/notifications";
|
|
||||||
export * from "./types/transactionsTypes";
|
|
||||||
export * from "./types/pendingTypes";
|
|
@ -14,12 +14,14 @@
|
|||||||
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 { Stores, Amounts, CoinSourceType, CoinStatus, RefundState, AbortStatus, ProposalStatus, getTimestampNow, encodeCrock, stringToBytes, getRandomBytes } from "../..";
|
|
||||||
import { hash } from "../../crypto/primitives/nacl-fast";
|
import { hash } from "../../crypto/primitives/nacl-fast";
|
||||||
import { WalletBackupContentV1, BackupExchange, BackupCoin, BackupDenomination, BackupReserve, BackupPurchase, BackupProposal, BackupRefreshGroup, BackupBackupProvider, BackupTip, BackupRecoupGroup, BackupWithdrawalGroup, BackupBackupProviderTerms, BackupCoinSource, BackupCoinSourceType, BackupExchangeWireFee, BackupRefundItem, BackupRefundState, BackupProposalStatus, BackupRefreshOldCoin, BackupRefreshSession } from "../../types/backupTypes";
|
import { WalletBackupContentV1, BackupExchange, BackupCoin, BackupDenomination, BackupReserve, BackupPurchase, BackupProposal, BackupRefreshGroup, BackupBackupProvider, BackupTip, BackupRecoupGroup, BackupWithdrawalGroup, BackupBackupProviderTerms, BackupCoinSource, BackupCoinSourceType, BackupExchangeWireFee, BackupRefundItem, BackupRefundState, BackupProposalStatus, BackupRefreshOldCoin, BackupRefreshSession } from "@gnu-taler/taler-util";
|
||||||
import { canonicalizeBaseUrl, canonicalJson } from "../../util/helpers";
|
import { canonicalizeBaseUrl, canonicalJson } from "../../util/helpers";
|
||||||
import { InternalWalletState } from "../state";
|
import { InternalWalletState } from "../state";
|
||||||
import { provideBackupState, getWalletBackupState, WALLET_BACKUP_STATE_KEY } from "./state";
|
import { provideBackupState, getWalletBackupState, WALLET_BACKUP_STATE_KEY } from "./state";
|
||||||
|
import { Amounts, getTimestampNow } from "@gnu-taler/taler-util";
|
||||||
|
import { Stores, CoinSourceType, CoinStatus, RefundState, AbortStatus, ProposalStatus } from "../../db.js";
|
||||||
|
import { encodeCrock, stringToBytes, getRandomBytes } from "../../index.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of wallet backups (export/import/upload) and sync
|
* Implementation of wallet backups (export/import/upload) and sync
|
||||||
|
@ -14,40 +14,9 @@
|
|||||||
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 {
|
import { BackupPurchase, AmountJson, Amounts, BackupDenomSel, WalletBackupContentV1, getTimestampNow, BackupCoinSourceType, BackupProposalStatus, codecForContractTerms, BackupRefundState, RefreshReason, BackupRefreshReason } from "@gnu-taler/taler-util";
|
||||||
AbortStatus,
|
import { Stores, WalletContractData, DenomSelectionState, ExchangeWireInfo, ExchangeUpdateStatus, DenominationStatus, CoinSource, CoinSourceType, CoinStatus, ReserveBankInfo, ReserveRecordStatus, ProposalDownload, ProposalStatus, WalletRefundItem, RefundState, AbortStatus, RefreshSessionRecord } from "../../db.js";
|
||||||
AmountJson,
|
import { TransactionHandle } from "../../index.js";
|
||||||
Amounts,
|
|
||||||
codecForContractTerms,
|
|
||||||
CoinSource,
|
|
||||||
CoinSourceType,
|
|
||||||
CoinStatus,
|
|
||||||
DenominationStatus,
|
|
||||||
DenomSelectionState,
|
|
||||||
ExchangeUpdateStatus,
|
|
||||||
ExchangeWireInfo,
|
|
||||||
getTimestampNow,
|
|
||||||
ProposalDownload,
|
|
||||||
ProposalStatus,
|
|
||||||
RefreshReason,
|
|
||||||
RefreshSessionRecord,
|
|
||||||
RefundState,
|
|
||||||
ReserveBankInfo,
|
|
||||||
ReserveRecordStatus,
|
|
||||||
Stores,
|
|
||||||
TransactionHandle,
|
|
||||||
WalletContractData,
|
|
||||||
WalletRefundItem,
|
|
||||||
} from "../..";
|
|
||||||
import {
|
|
||||||
BackupCoinSourceType,
|
|
||||||
BackupDenomSel,
|
|
||||||
BackupProposalStatus,
|
|
||||||
BackupPurchase,
|
|
||||||
BackupRefreshReason,
|
|
||||||
BackupRefundState,
|
|
||||||
WalletBackupContentV1,
|
|
||||||
} from "../../types/backupTypes";
|
|
||||||
import { PayCoinSelection } from "../../util/coinSelection";
|
import { PayCoinSelection } from "../../util/coinSelection";
|
||||||
import { j2s } from "../../util/helpers";
|
import { j2s } from "../../util/helpers";
|
||||||
import { checkDbInvariant, checkLogicInvariant } from "../../util/invariants";
|
import { checkDbInvariant, checkLogicInvariant } from "../../util/invariants";
|
||||||
|
@ -25,15 +25,14 @@
|
|||||||
* Imports.
|
* Imports.
|
||||||
*/
|
*/
|
||||||
import { InternalWalletState } from "../state";
|
import { InternalWalletState } from "../state";
|
||||||
import { WalletBackupContentV1 } from "../../types/backupTypes";
|
import { AmountString, BackupRecovery, codecForAmountString, WalletBackupContentV1 } from "@gnu-taler/taler-util";
|
||||||
import { TransactionHandle } from "../../util/query";
|
import { TransactionHandle } from "../../util/query";
|
||||||
import {
|
import {
|
||||||
BackupProviderRecord,
|
BackupProviderRecord,
|
||||||
ConfigRecord,
|
ConfigRecord,
|
||||||
Stores,
|
Stores,
|
||||||
} from "../../types/dbTypes";
|
} from "../../db.js";
|
||||||
import { checkDbInvariant, checkLogicInvariant } from "../../util/invariants";
|
import { checkDbInvariant, checkLogicInvariant } from "../../util/invariants";
|
||||||
import { codecForAmountString } from "../../util/amounts";
|
|
||||||
import {
|
import {
|
||||||
bytesToString,
|
bytesToString,
|
||||||
decodeCrock,
|
decodeCrock,
|
||||||
@ -51,9 +50,8 @@ import {
|
|||||||
getTimestampNow,
|
getTimestampNow,
|
||||||
Timestamp,
|
Timestamp,
|
||||||
timestampAddDuration,
|
timestampAddDuration,
|
||||||
} from "../../util/time";
|
} from "@gnu-taler/taler-util";
|
||||||
import { URL } from "../../util/url";
|
import { URL } from "../../util/url";
|
||||||
import { AmountString } from "../../types/talerTypes";
|
|
||||||
import {
|
import {
|
||||||
buildCodecForObject,
|
buildCodecForObject,
|
||||||
Codec,
|
Codec,
|
||||||
@ -61,7 +59,7 @@ import {
|
|||||||
codecForNumber,
|
codecForNumber,
|
||||||
codecForString,
|
codecForString,
|
||||||
codecOptional,
|
codecOptional,
|
||||||
} from "../../util/codec";
|
} from "@gnu-taler/taler-util";
|
||||||
import {
|
import {
|
||||||
HttpResponseStatus,
|
HttpResponseStatus,
|
||||||
readSuccessResponseJsonOrThrow,
|
readSuccessResponseJsonOrThrow,
|
||||||
@ -77,7 +75,7 @@ import {
|
|||||||
RecoveryLoadRequest,
|
RecoveryLoadRequest,
|
||||||
RecoveryMergeStrategy,
|
RecoveryMergeStrategy,
|
||||||
TalerErrorDetails,
|
TalerErrorDetails,
|
||||||
} from "../../types/walletTypes";
|
} from "@gnu-taler/taler-util";
|
||||||
import { CryptoApi } from "../../crypto/workers/cryptoApi";
|
import { CryptoApi } from "../../crypto/workers/cryptoApi";
|
||||||
import { secretbox, secretbox_open } from "../../crypto/primitives/nacl-fast";
|
import { secretbox, secretbox_open } from "../../crypto/primitives/nacl-fast";
|
||||||
import { checkPaymentByProposalId, confirmPay, preparePayForUri } from "../pay";
|
import { checkPaymentByProposalId, confirmPay, preparePayForUri } from "../pay";
|
||||||
@ -89,7 +87,6 @@ import {
|
|||||||
getWalletBackupState,
|
getWalletBackupState,
|
||||||
WalletBackupConfState,
|
WalletBackupConfState,
|
||||||
} from "./state";
|
} from "./state";
|
||||||
import { PaymentStatus } from "../../types/transactionsTypes";
|
|
||||||
|
|
||||||
const logger = new Logger("operations/backup.ts");
|
const logger = new Logger("operations/backup.ts");
|
||||||
|
|
||||||
@ -639,13 +636,6 @@ export async function getBackupInfo(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface BackupRecovery {
|
|
||||||
walletRootPriv: string;
|
|
||||||
providers: {
|
|
||||||
url: string;
|
|
||||||
}[];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get information about the current state of wallet backups.
|
* Get information about the current state of wallet backups.
|
||||||
*/
|
*/
|
||||||
|
@ -14,14 +14,9 @@
|
|||||||
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 {
|
import { Timestamp } from "@gnu-taler/taler-util";
|
||||||
ConfigRecord,
|
import { ConfigRecord, Stores } from "../../db.js";
|
||||||
encodeCrock,
|
import { getRandomBytes, encodeCrock, TransactionHandle } from "../../index.js";
|
||||||
getRandomBytes,
|
|
||||||
Stores,
|
|
||||||
Timestamp,
|
|
||||||
TransactionHandle,
|
|
||||||
} from "../..";
|
|
||||||
import { checkDbInvariant } from "../../util/invariants";
|
import { checkDbInvariant } from "../../util/invariants";
|
||||||
import { InternalWalletState } from "../state";
|
import { InternalWalletState } from "../state";
|
||||||
|
|
||||||
|
@ -17,13 +17,11 @@
|
|||||||
/**
|
/**
|
||||||
* Imports.
|
* Imports.
|
||||||
*/
|
*/
|
||||||
import { BalancesResponse } from "../types/walletTypes";
|
import { AmountJson, BalancesResponse, Amounts } from "@gnu-taler/taler-util";
|
||||||
import { TransactionHandle } from "../util/query";
|
import { Stores, CoinStatus } from "../db.js";
|
||||||
import { InternalWalletState } from "./state";
|
import { TransactionHandle } from "../index.js";
|
||||||
import { Stores, CoinStatus } from "../types/dbTypes";
|
|
||||||
import * as Amounts from "../util/amounts";
|
|
||||||
import { AmountJson } from "../util/amounts";
|
|
||||||
import { Logger } from "../util/logging";
|
import { Logger } from "../util/logging";
|
||||||
|
import { InternalWalletState } from "./state.js";
|
||||||
|
|
||||||
const logger = new Logger("withdraw.ts");
|
const logger = new Logger("withdraw.ts");
|
||||||
|
|
||||||
|
@ -14,42 +14,37 @@
|
|||||||
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 {
|
|
||||||
Amounts,
|
|
||||||
CreateDepositGroupRequest,
|
|
||||||
guardOperationException,
|
|
||||||
Logger,
|
|
||||||
NotificationType,
|
|
||||||
TalerErrorDetails,
|
|
||||||
} from "..";
|
|
||||||
import { kdf } from "../crypto/primitives/kdf";
|
import { kdf } from "../crypto/primitives/kdf";
|
||||||
import {
|
import {
|
||||||
encodeCrock,
|
encodeCrock,
|
||||||
getRandomBytes,
|
getRandomBytes,
|
||||||
stringToBytes,
|
stringToBytes,
|
||||||
} from "../crypto/talerCrypto";
|
} from "../crypto/talerCrypto";
|
||||||
import { DepositGroupRecord, Stores } from "../types/dbTypes";
|
|
||||||
import { ContractTerms } from "../types/talerTypes";
|
|
||||||
import { CreateDepositGroupResponse, TrackDepositGroupRequest, TrackDepositGroupResponse } from "../types/walletTypes";
|
|
||||||
import {
|
|
||||||
buildCodecForObject,
|
|
||||||
Codec,
|
|
||||||
codecForString,
|
|
||||||
codecOptional,
|
|
||||||
} from "../util/codec";
|
|
||||||
import { selectPayCoins } from "../util/coinSelection";
|
import { selectPayCoins } from "../util/coinSelection";
|
||||||
import { canonicalJson } from "../util/helpers";
|
import { canonicalJson } from "../util/helpers";
|
||||||
import { readSuccessResponseJsonOrThrow } from "../util/http";
|
import { readSuccessResponseJsonOrThrow } from "../util/http";
|
||||||
import { parsePaytoUri } from "../util/payto";
|
|
||||||
import { initRetryInfo, updateRetryInfoTimeout } from "../util/retries";
|
import { initRetryInfo, updateRetryInfoTimeout } from "../util/retries";
|
||||||
import {
|
import {
|
||||||
|
Amounts,
|
||||||
|
buildCodecForObject,
|
||||||
|
Codec,
|
||||||
|
codecForString,
|
||||||
codecForTimestamp,
|
codecForTimestamp,
|
||||||
|
codecOptional,
|
||||||
|
ContractTerms,
|
||||||
|
CreateDepositGroupRequest,
|
||||||
|
CreateDepositGroupResponse,
|
||||||
durationFromSpec,
|
durationFromSpec,
|
||||||
getTimestampNow,
|
getTimestampNow,
|
||||||
|
NotificationType,
|
||||||
|
parsePaytoUri,
|
||||||
|
TalerErrorDetails,
|
||||||
Timestamp,
|
Timestamp,
|
||||||
timestampAddDuration,
|
timestampAddDuration,
|
||||||
timestampTruncateToSecond,
|
timestampTruncateToSecond,
|
||||||
} from "../util/time";
|
TrackDepositGroupRequest,
|
||||||
|
TrackDepositGroupResponse,
|
||||||
|
} from "@gnu-taler/taler-util";
|
||||||
import { URL } from "../util/url";
|
import { URL } from "../util/url";
|
||||||
import {
|
import {
|
||||||
applyCoinSpend,
|
applyCoinSpend,
|
||||||
@ -60,6 +55,9 @@ import {
|
|||||||
getTotalPaymentCost,
|
getTotalPaymentCost,
|
||||||
} from "./pay";
|
} from "./pay";
|
||||||
import { InternalWalletState } from "./state";
|
import { InternalWalletState } from "./state";
|
||||||
|
import { Logger } from "../util/logging.js";
|
||||||
|
import { DepositGroupRecord, Stores } from "../db.js";
|
||||||
|
import { guardOperationException } from "./errors.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logger.
|
* Logger.
|
||||||
@ -242,7 +240,6 @@ async function processDepositGroupImpl(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export async function trackDepositGroup(
|
export async function trackDepositGroup(
|
||||||
ws: InternalWalletState,
|
ws: InternalWalletState,
|
||||||
req: TrackDepositGroupRequest,
|
req: TrackDepositGroupRequest,
|
||||||
@ -384,7 +381,6 @@ export async function createDepositGroup(
|
|||||||
prevPayCoins: [],
|
prevPayCoins: [],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
if (!payCoinSel) {
|
if (!payCoinSel) {
|
||||||
throw Error("insufficient funds");
|
throw Error("insufficient funds");
|
||||||
}
|
}
|
||||||
@ -437,4 +433,4 @@ export async function createDepositGroup(
|
|||||||
await ws.db.put(Stores.depositGroups, depositGroup);
|
await ws.db.put(Stores.depositGroups, depositGroup);
|
||||||
|
|
||||||
return { depositGroupId };
|
return { depositGroupId };
|
||||||
}
|
}
|
@ -23,8 +23,7 @@
|
|||||||
/**
|
/**
|
||||||
* Imports.
|
* Imports.
|
||||||
*/
|
*/
|
||||||
import { TalerErrorDetails } from "../types/walletTypes";
|
import { TalerErrorCode, TalerErrorDetails } from "@gnu-taler/taler-util";
|
||||||
import { TalerErrorCode } from "../TalerErrorCode";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This exception is there to let the caller know that an error happened,
|
* This exception is there to let the caller know that an error happened,
|
||||||
|
@ -14,54 +14,54 @@
|
|||||||
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 { InternalWalletState } from "./state";
|
/**
|
||||||
|
* Imports.
|
||||||
|
*/
|
||||||
import {
|
import {
|
||||||
Denomination,
|
Amounts,
|
||||||
codecForExchangeKeysJson,
|
codecForExchangeKeysJson,
|
||||||
codecForExchangeWireJson,
|
codecForExchangeWireJson,
|
||||||
} from "../types/talerTypes";
|
compare,
|
||||||
import { TalerErrorDetails } from "../types/walletTypes";
|
Denomination,
|
||||||
|
Duration,
|
||||||
|
durationFromSpec,
|
||||||
|
getTimestampNow,
|
||||||
|
isTimestampExpired,
|
||||||
|
NotificationType,
|
||||||
|
parsePaytoUri,
|
||||||
|
TalerErrorCode,
|
||||||
|
TalerErrorDetails,
|
||||||
|
} from "@gnu-taler/taler-util";
|
||||||
import {
|
import {
|
||||||
ExchangeRecord,
|
|
||||||
ExchangeUpdateStatus,
|
|
||||||
Stores,
|
|
||||||
DenominationRecord,
|
DenominationRecord,
|
||||||
DenominationStatus,
|
DenominationStatus,
|
||||||
|
Stores,
|
||||||
|
ExchangeRecord,
|
||||||
|
ExchangeUpdateStatus,
|
||||||
WireFee,
|
WireFee,
|
||||||
ExchangeUpdateReason,
|
ExchangeUpdateReason,
|
||||||
MetaStores,
|
} from "../db.js";
|
||||||
} from "../types/dbTypes";
|
|
||||||
import { canonicalizeBaseUrl, j2s } from "../util/helpers";
|
|
||||||
import * as Amounts from "../util/amounts";
|
|
||||||
import { parsePaytoUri } from "../util/payto";
|
|
||||||
import {
|
import {
|
||||||
|
Logger,
|
||||||
|
URL,
|
||||||
|
readSuccessResponseJsonOrThrow,
|
||||||
|
getExpiryTimestamp,
|
||||||
|
readSuccessResponseTextOrThrow,
|
||||||
|
} from "../index.js";
|
||||||
|
import { j2s, canonicalizeBaseUrl } from "../util/helpers.js";
|
||||||
|
import { checkDbInvariant } from "../util/invariants.js";
|
||||||
|
import { updateRetryInfoTimeout, initRetryInfo } from "../util/retries.js";
|
||||||
|
import {
|
||||||
|
makeErrorDetails,
|
||||||
OperationFailedAndReportedError,
|
OperationFailedAndReportedError,
|
||||||
guardOperationException,
|
guardOperationException,
|
||||||
makeErrorDetails,
|
} from "./errors.js";
|
||||||
} from "./errors";
|
import { createRecoupGroup, processRecoupGroup } from "./recoup.js";
|
||||||
|
import { InternalWalletState } from "./state.js";
|
||||||
import {
|
import {
|
||||||
WALLET_CACHE_BREAKER_CLIENT_VERSION,
|
WALLET_CACHE_BREAKER_CLIENT_VERSION,
|
||||||
WALLET_EXCHANGE_PROTOCOL_VERSION,
|
WALLET_EXCHANGE_PROTOCOL_VERSION,
|
||||||
} from "./versions";
|
} from "./versions.js";
|
||||||
import {
|
|
||||||
getTimestampNow,
|
|
||||||
Duration,
|
|
||||||
isTimestampExpired,
|
|
||||||
durationFromSpec,
|
|
||||||
} from "../util/time";
|
|
||||||
import { compare } from "../util/libtoolVersion";
|
|
||||||
import { createRecoupGroup, processRecoupGroup } from "./recoup";
|
|
||||||
import { TalerErrorCode } from "../TalerErrorCode";
|
|
||||||
import {
|
|
||||||
readSuccessResponseJsonOrThrow,
|
|
||||||
readSuccessResponseTextOrThrow,
|
|
||||||
getExpiryTimestamp,
|
|
||||||
} from "../util/http";
|
|
||||||
import { Logger } from "../util/logging";
|
|
||||||
import { URL } from "../util/url";
|
|
||||||
import { checkDbInvariant } from "../util/invariants";
|
|
||||||
import { NotificationType } from "../types/notifications";
|
|
||||||
import { updateRetryInfoTimeout, initRetryInfo } from "../util/retries";
|
|
||||||
|
|
||||||
const logger = new Logger("exchanges.ts");
|
const logger = new Logger("exchanges.ts");
|
||||||
|
|
||||||
|
@ -24,77 +24,14 @@
|
|||||||
/**
|
/**
|
||||||
* Imports.
|
* Imports.
|
||||||
*/
|
*/
|
||||||
|
import { AmountJson, Amounts, timestampIsBetween, getTimestampNow, isTimestampExpired, Timestamp, RefreshReason, CoinDepositPermission, NotificationType, TalerErrorDetails, Duration, durationMax, durationMin, durationMul, ContractTerms, codecForProposal, TalerErrorCode, codecForContractTerms, timestampAddDuration, ConfirmPayResult, ConfirmPayResultType, codecForMerchantPayResponse, PreparePayResult, PreparePayResultType, parsePayUri } from "@gnu-taler/taler-util";
|
||||||
import { encodeCrock, getRandomBytes } from "../crypto/talerCrypto";
|
import { encodeCrock, getRandomBytes } from "../crypto/talerCrypto";
|
||||||
import {
|
import { AbortStatus, AllowedAuditorInfo, AllowedExchangeInfo, CoinRecord, CoinStatus, DenominationRecord, getHttpResponseErrorDetails, guardOperationException, HttpResponseStatus, Logger, makeErrorDetails, OperationFailedAndReportedError, OperationFailedError, ProposalRecord, ProposalStatus, PurchaseRecord, readSuccessResponseJsonOrErrorCode, readSuccessResponseJsonOrThrow, readTalerErrorResponse, Stores, throwUnexpectedRequestError, TransactionHandle, URL, WalletContractData } from "../index.js";
|
||||||
CoinStatus,
|
import { PayCoinSelection, CoinCandidateSelection, AvailableCoinInfo, selectPayCoins } from "../util/coinSelection.js";
|
||||||
ProposalRecord,
|
import { canonicalJson } from "../util/helpers.js";
|
||||||
ProposalStatus,
|
import { initRetryInfo, updateRetryInfoTimeout, getRetryDuration } from "../util/retries.js";
|
||||||
PurchaseRecord,
|
import { getTotalRefreshCost, createRefreshGroup } from "./refresh.js";
|
||||||
Stores,
|
import { InternalWalletState, EXCHANGE_COINS_LOCK } from "./state.js";
|
||||||
WalletContractData,
|
|
||||||
CoinRecord,
|
|
||||||
DenominationRecord,
|
|
||||||
AbortStatus,
|
|
||||||
AllowedExchangeInfo,
|
|
||||||
AllowedAuditorInfo,
|
|
||||||
} from "../types/dbTypes";
|
|
||||||
import { NotificationType } from "../types/notifications";
|
|
||||||
import {
|
|
||||||
codecForProposal,
|
|
||||||
codecForContractTerms,
|
|
||||||
CoinDepositPermission,
|
|
||||||
codecForMerchantPayResponse,
|
|
||||||
ContractTerms,
|
|
||||||
} from "../types/talerTypes";
|
|
||||||
import {
|
|
||||||
ConfirmPayResult,
|
|
||||||
TalerErrorDetails,
|
|
||||||
PreparePayResult,
|
|
||||||
RefreshReason,
|
|
||||||
PreparePayResultType,
|
|
||||||
ConfirmPayResultType,
|
|
||||||
} from "../types/walletTypes";
|
|
||||||
import { Amounts } from "../util/amounts";
|
|
||||||
import { AmountJson } from "../util/amounts";
|
|
||||||
import { Logger } from "../util/logging";
|
|
||||||
import { parsePayUri } from "../util/taleruri";
|
|
||||||
import {
|
|
||||||
guardOperationException,
|
|
||||||
makeErrorDetails,
|
|
||||||
OperationFailedAndReportedError,
|
|
||||||
OperationFailedError,
|
|
||||||
} from "./errors";
|
|
||||||
import { createRefreshGroup, getTotalRefreshCost } from "./refresh";
|
|
||||||
import { InternalWalletState, EXCHANGE_COINS_LOCK } from "./state";
|
|
||||||
import {
|
|
||||||
getTimestampNow,
|
|
||||||
timestampAddDuration,
|
|
||||||
Duration,
|
|
||||||
durationMax,
|
|
||||||
durationMin,
|
|
||||||
isTimestampExpired,
|
|
||||||
durationMul,
|
|
||||||
Timestamp,
|
|
||||||
timestampIsBetween,
|
|
||||||
} from "../util/time";
|
|
||||||
import { strcmp, canonicalJson } from "../util/helpers";
|
|
||||||
import {
|
|
||||||
readSuccessResponseJsonOrThrow,
|
|
||||||
throwUnexpectedRequestError,
|
|
||||||
getHttpResponseErrorDetails,
|
|
||||||
readSuccessResponseJsonOrErrorCode,
|
|
||||||
HttpResponseStatus,
|
|
||||||
readTalerErrorResponse,
|
|
||||||
} from "../util/http";
|
|
||||||
import { TalerErrorCode } from "../TalerErrorCode";
|
|
||||||
import { URL } from "../util/url";
|
|
||||||
import {
|
|
||||||
initRetryInfo,
|
|
||||||
updateRetryInfoTimeout,
|
|
||||||
getRetryDuration,
|
|
||||||
} from "../util/retries";
|
|
||||||
import { TransactionHandle } from "../util/query";
|
|
||||||
import { PayCoinSelection, CoinCandidateSelection, AvailableCoinInfo, selectPayCoins } from "../util/coinSelection";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logger.
|
* Logger.
|
||||||
|
@ -23,20 +23,20 @@ import {
|
|||||||
ReserveRecordStatus,
|
ReserveRecordStatus,
|
||||||
Stores,
|
Stores,
|
||||||
AbortStatus,
|
AbortStatus,
|
||||||
} from "../types/dbTypes";
|
} from "../db.js";
|
||||||
import {
|
import {
|
||||||
PendingOperationsResponse,
|
PendingOperationsResponse,
|
||||||
PendingOperationType,
|
PendingOperationType,
|
||||||
ExchangeUpdateOperationStage,
|
ExchangeUpdateOperationStage,
|
||||||
ReserveType,
|
ReserveType,
|
||||||
} from "../types/pendingTypes";
|
} from "../pending-types";
|
||||||
import {
|
import {
|
||||||
Duration,
|
Duration,
|
||||||
getTimestampNow,
|
getTimestampNow,
|
||||||
Timestamp,
|
Timestamp,
|
||||||
getDurationRemaining,
|
getDurationRemaining,
|
||||||
durationMin,
|
durationMin,
|
||||||
} from "../util/time";
|
} from "@gnu-taler/taler-util";
|
||||||
import { Store, TransactionHandle } from "../util/query";
|
import { Store, TransactionHandle } from "../util/query";
|
||||||
import { InternalWalletState } from "./state";
|
import { InternalWalletState } from "./state";
|
||||||
import { getBalancesInsideTransaction } from "./balance";
|
import { getBalancesInsideTransaction } from "./balance";
|
||||||
|
@ -24,26 +24,14 @@
|
|||||||
/**
|
/**
|
||||||
* Imports.
|
* Imports.
|
||||||
*/
|
*/
|
||||||
|
import { Amounts, codecForRecoupConfirmation, getTimestampNow, NotificationType, RefreshReason, TalerErrorDetails } from "@gnu-taler/taler-util";
|
||||||
import { encodeCrock, getRandomBytes } from "../crypto/talerCrypto";
|
import { encodeCrock, getRandomBytes } from "../crypto/talerCrypto";
|
||||||
import {
|
import { CoinRecord, CoinSourceType, CoinStatus, RecoupGroupRecord, RefreshCoinSource, ReserveRecordStatus, Stores, WithdrawCoinSource } from "../db.js";
|
||||||
CoinRecord,
|
|
||||||
CoinSourceType,
|
|
||||||
CoinStatus,
|
|
||||||
RecoupGroupRecord,
|
|
||||||
RefreshCoinSource,
|
|
||||||
ReserveRecordStatus,
|
|
||||||
Stores,
|
|
||||||
WithdrawCoinSource,
|
|
||||||
} from "../types/dbTypes";
|
|
||||||
import { NotificationType } from "../types/notifications";
|
|
||||||
import { codecForRecoupConfirmation } from "../types/talerTypes";
|
|
||||||
import { RefreshReason, TalerErrorDetails } from "../types/walletTypes";
|
|
||||||
import { Amounts } from "../util/amounts";
|
|
||||||
import { readSuccessResponseJsonOrThrow } from "../util/http";
|
import { readSuccessResponseJsonOrThrow } from "../util/http";
|
||||||
import { Logger } from "../util/logging";
|
import { Logger } from "../util/logging";
|
||||||
import { TransactionHandle } from "../util/query";
|
import { TransactionHandle } from "../util/query";
|
||||||
import { initRetryInfo, updateRetryInfoTimeout } from "../util/retries";
|
import { initRetryInfo, updateRetryInfoTimeout } from "../util/retries";
|
||||||
import { getTimestampNow } from "../util/time";
|
|
||||||
import { URL } from "../util/url";
|
import { URL } from "../util/url";
|
||||||
import { guardOperationException } from "./errors";
|
import { guardOperationException } from "./errors";
|
||||||
import { createRefreshGroup, processRefreshGroup } from "./refresh";
|
import { createRefreshGroup, processRefreshGroup } from "./refresh";
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { encodeCrock, getRandomBytes } from "../crypto/talerCrypto";
|
import { encodeCrock, getRandomBytes } from "../crypto/talerCrypto";
|
||||||
import { RefreshNewDenomInfo } from "../types/cryptoTypes";
|
|
||||||
import {
|
import {
|
||||||
CoinRecord,
|
CoinRecord,
|
||||||
CoinSourceType,
|
CoinSourceType,
|
||||||
@ -24,19 +23,17 @@ import {
|
|||||||
RefreshGroupRecord,
|
RefreshGroupRecord,
|
||||||
RefreshPlanchet,
|
RefreshPlanchet,
|
||||||
Stores,
|
Stores,
|
||||||
} from "../types/dbTypes";
|
} from "../db.js";
|
||||||
import { NotificationType } from "../types/notifications";
|
|
||||||
import {
|
import {
|
||||||
codecForExchangeMeltResponse,
|
codecForExchangeMeltResponse,
|
||||||
codecForExchangeRevealResponse,
|
codecForExchangeRevealResponse,
|
||||||
} from "../types/talerTypes";
|
|
||||||
import {
|
|
||||||
CoinPublicKey,
|
CoinPublicKey,
|
||||||
|
NotificationType,
|
||||||
RefreshGroupId,
|
RefreshGroupId,
|
||||||
RefreshReason,
|
RefreshReason,
|
||||||
TalerErrorDetails,
|
TalerErrorDetails,
|
||||||
} from "../types/walletTypes";
|
} from "@gnu-taler/taler-util";
|
||||||
import { AmountJson, Amounts } from "../util/amounts";
|
import { AmountJson, Amounts } from "@gnu-taler/taler-util";
|
||||||
import { amountToPretty } from "../util/helpers";
|
import { amountToPretty } from "../util/helpers";
|
||||||
import { readSuccessResponseJsonOrThrow } from "../util/http";
|
import { readSuccessResponseJsonOrThrow } from "../util/http";
|
||||||
import { checkDbInvariant } from "../util/invariants";
|
import { checkDbInvariant } from "../util/invariants";
|
||||||
@ -53,12 +50,13 @@ import {
|
|||||||
timestampAddDuration,
|
timestampAddDuration,
|
||||||
timestampDifference,
|
timestampDifference,
|
||||||
timestampMin,
|
timestampMin,
|
||||||
} from "../util/time";
|
} from "@gnu-taler/taler-util";
|
||||||
import { URL } from "../util/url";
|
import { URL } from "../util/url";
|
||||||
import { guardOperationException } from "./errors";
|
import { guardOperationException } from "./errors";
|
||||||
import { updateExchangeFromUrl } from "./exchanges";
|
import { updateExchangeFromUrl } from "./exchanges";
|
||||||
import { EXCHANGE_COINS_LOCK, InternalWalletState } from "./state";
|
import { EXCHANGE_COINS_LOCK, InternalWalletState } from "./state";
|
||||||
import { isWithdrawableDenom, selectWithdrawalDenominations } from "./withdraw";
|
import { isWithdrawableDenom, selectWithdrawalDenominations } from "./withdraw";
|
||||||
|
import { RefreshNewDenomInfo } from "../crypto/cryptoTypes.js";
|
||||||
|
|
||||||
const logger = new Logger("refresh.ts");
|
const logger = new Logger("refresh.ts");
|
||||||
|
|
||||||
|
@ -24,48 +24,37 @@
|
|||||||
* Imports.
|
* Imports.
|
||||||
*/
|
*/
|
||||||
import { InternalWalletState } from "./state";
|
import { InternalWalletState } from "./state";
|
||||||
import {
|
|
||||||
TalerErrorDetails,
|
|
||||||
RefreshReason,
|
|
||||||
CoinPublicKey,
|
|
||||||
ApplyRefundResponse,
|
|
||||||
} from "../types/walletTypes";
|
|
||||||
import {
|
|
||||||
Stores,
|
|
||||||
CoinStatus,
|
|
||||||
RefundReason,
|
|
||||||
RefundState,
|
|
||||||
PurchaseRecord,
|
|
||||||
AbortStatus,
|
|
||||||
} from "../types/dbTypes";
|
|
||||||
import { NotificationType } from "../types/notifications";
|
|
||||||
import { parseRefundUri } from "../util/taleruri";
|
|
||||||
import { createRefreshGroup, getTotalRefreshCost } from "./refresh";
|
|
||||||
import { Amounts, AmountJson } from "../util/amounts";
|
|
||||||
import {
|
|
||||||
MerchantCoinRefundStatus,
|
|
||||||
MerchantCoinRefundSuccessStatus,
|
|
||||||
MerchantCoinRefundFailureStatus,
|
|
||||||
codecForMerchantOrderRefundPickupResponse,
|
|
||||||
AbortRequest,
|
|
||||||
AbortingCoin,
|
|
||||||
codecForMerchantAbortPayRefundStatus,
|
|
||||||
codecForAbortResponse,
|
|
||||||
} from "../types/talerTypes";
|
|
||||||
import { guardOperationException } from "./errors";
|
import { guardOperationException } from "./errors";
|
||||||
import {
|
import {
|
||||||
getTimestampNow,
|
getTimestampNow,
|
||||||
Timestamp,
|
Timestamp,
|
||||||
durationAdd,
|
durationAdd,
|
||||||
timestampAddDuration,
|
timestampAddDuration,
|
||||||
} from "../util/time";
|
TalerErrorDetails,
|
||||||
|
AbortingCoin,
|
||||||
|
AbortRequest,
|
||||||
|
AmountJson,
|
||||||
|
Amounts,
|
||||||
|
ApplyRefundResponse,
|
||||||
|
codecForAbortResponse,
|
||||||
|
codecForMerchantOrderRefundPickupResponse,
|
||||||
|
CoinPublicKey,
|
||||||
|
MerchantCoinRefundFailureStatus,
|
||||||
|
MerchantCoinRefundStatus,
|
||||||
|
MerchantCoinRefundSuccessStatus,
|
||||||
|
NotificationType,
|
||||||
|
parseRefundUri,
|
||||||
|
RefreshReason,
|
||||||
|
} from "@gnu-taler/taler-util";
|
||||||
import { Logger } from "../util/logging";
|
import { Logger } from "../util/logging";
|
||||||
import { readSuccessResponseJsonOrThrow } from "../util/http";
|
import { readSuccessResponseJsonOrThrow } from "../util/http";
|
||||||
import { TransactionHandle } from "../util/query";
|
import { TransactionHandle } from "../util/query";
|
||||||
import { URL } from "../util/url";
|
import { URL } from "../util/url";
|
||||||
import { updateRetryInfoTimeout, initRetryInfo } from "../util/retries";
|
import { updateRetryInfoTimeout, initRetryInfo } from "../util/retries";
|
||||||
import { checkDbInvariant } from "../util/invariants";
|
import { checkDbInvariant } from "../util/invariants";
|
||||||
import { TalerErrorCode } from "../TalerErrorCode";
|
import { TalerErrorCode } from "@gnu-taler/taler-util";
|
||||||
|
import { Stores, PurchaseRecord, CoinStatus, RefundState, AbortStatus, RefundReason } from "../db.js";
|
||||||
|
import { getTotalRefreshCost, createRefreshGroup } from "./refresh.js";
|
||||||
|
|
||||||
const logger = new Logger("refund.ts");
|
const logger = new Logger("refund.ts");
|
||||||
|
|
||||||
|
@ -19,69 +19,29 @@ import {
|
|||||||
CreateReserveResponse,
|
CreateReserveResponse,
|
||||||
TalerErrorDetails,
|
TalerErrorDetails,
|
||||||
AcceptWithdrawalResponse,
|
AcceptWithdrawalResponse,
|
||||||
} from "../types/walletTypes";
|
Amounts,
|
||||||
import { canonicalizeBaseUrl } from "../util/helpers";
|
|
||||||
import { InternalWalletState } from "./state";
|
|
||||||
import {
|
|
||||||
ReserveRecordStatus,
|
|
||||||
ReserveRecord,
|
|
||||||
CurrencyRecord,
|
|
||||||
Stores,
|
|
||||||
WithdrawalGroupRecord,
|
|
||||||
ReserveBankInfo,
|
|
||||||
} from "../types/dbTypes";
|
|
||||||
import { Logger } from "../util/logging";
|
|
||||||
import { Amounts } from "../util/amounts";
|
|
||||||
import {
|
|
||||||
updateExchangeFromUrl,
|
|
||||||
getExchangeTrust,
|
|
||||||
getExchangePaytoUri,
|
|
||||||
} from "./exchanges";
|
|
||||||
import {
|
|
||||||
codecForWithdrawOperationStatusResponse,
|
|
||||||
codecForBankWithdrawalOperationPostResponse,
|
codecForBankWithdrawalOperationPostResponse,
|
||||||
} from "../types/talerTypes";
|
codecForReserveStatus,
|
||||||
import { assertUnreachable } from "../util/assertUnreachable";
|
codecForWithdrawOperationStatusResponse,
|
||||||
import { encodeCrock, getRandomBytes } from "../crypto/talerCrypto";
|
|
||||||
import { randomBytes } from "../crypto/primitives/nacl-fast";
|
|
||||||
import {
|
|
||||||
processWithdrawGroup,
|
|
||||||
getBankWithdrawalInfo,
|
|
||||||
denomSelectionInfoToState,
|
|
||||||
updateWithdrawalDenoms,
|
|
||||||
selectWithdrawalDenominations,
|
|
||||||
getCandidateWithdrawalDenoms,
|
|
||||||
} from "./withdraw";
|
|
||||||
import {
|
|
||||||
guardOperationException,
|
|
||||||
OperationFailedAndReportedError,
|
|
||||||
makeErrorDetails,
|
|
||||||
OperationFailedError,
|
|
||||||
} from "./errors";
|
|
||||||
import { NotificationType } from "../types/notifications";
|
|
||||||
import { codecForReserveStatus } from "../types/ReserveStatus";
|
|
||||||
import {
|
|
||||||
getTimestampNow,
|
|
||||||
Duration,
|
Duration,
|
||||||
durationMin,
|
|
||||||
durationMax,
|
durationMax,
|
||||||
} from "../util/time";
|
durationMin,
|
||||||
import { TransactionHandle } from "../util/query";
|
getTimestampNow,
|
||||||
import { addPaytoQueryParams } from "../util/payto";
|
NotificationType,
|
||||||
import { TalerErrorCode } from "../TalerErrorCode";
|
ReserveTransactionType,
|
||||||
import {
|
TalerErrorCode,
|
||||||
readSuccessResponseJsonOrErrorCode,
|
addPaytoQueryParams,
|
||||||
throwUnexpectedRequestError,
|
} from "@gnu-taler/taler-util";
|
||||||
readSuccessResponseJsonOrThrow,
|
import { randomBytes } from "../crypto/primitives/nacl-fast.js";
|
||||||
} from "../util/http";
|
import { Stores, ReserveRecordStatus, ReserveBankInfo, ReserveRecord, CurrencyRecord, WithdrawalGroupRecord } from "../db.js";
|
||||||
import { codecForAny } from "../util/codec";
|
import { Logger, encodeCrock, getRandomBytes, readSuccessResponseJsonOrThrow, URL, readSuccessResponseJsonOrErrorCode, throwUnexpectedRequestError, TransactionHandle } from "../index.js";
|
||||||
import { URL } from "../util/url";
|
import { assertUnreachable } from "../util/assertUnreachable.js";
|
||||||
import {
|
import { canonicalizeBaseUrl } from "../util/helpers.js";
|
||||||
initRetryInfo,
|
import { initRetryInfo, getRetryDuration, updateRetryInfoTimeout } from "../util/retries.js";
|
||||||
getRetryDuration,
|
import { guardOperationException, OperationFailedError } from "./errors.js";
|
||||||
updateRetryInfoTimeout,
|
import { updateExchangeFromUrl, getExchangeTrust, getExchangePaytoUri } from "./exchanges.js";
|
||||||
} from "../util/retries";
|
import { InternalWalletState } from "./state.js";
|
||||||
import { ReserveTransactionType } from "../types/ReserveTransaction";
|
import { updateWithdrawalDenoms, getCandidateWithdrawalDenoms, selectWithdrawalDenominations, denomSelectionInfoToState, processWithdrawGroup, getBankWithdrawalInfo } from "./withdraw.js";
|
||||||
|
|
||||||
const logger = new Logger("reserves.ts");
|
const logger = new Logger("reserves.ts");
|
||||||
|
|
||||||
|
@ -14,16 +14,15 @@
|
|||||||
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/>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Imports.
|
||||||
|
*/
|
||||||
|
import { WalletNotification, BalancesResponse } from "@gnu-taler/taler-util";
|
||||||
|
import { Stores } from "../db.js";
|
||||||
|
import { Logger, CryptoApi, OpenedPromise, Database, CryptoWorkerFactory, openPromise } from "../index.js";
|
||||||
|
import { PendingOperationsResponse } from "../pending-types.js";
|
||||||
|
import { AsyncOpMemoMap, AsyncOpMemoSingle } from "../util/asyncMemo.js";
|
||||||
import { HttpRequestLibrary } from "../util/http";
|
import { HttpRequestLibrary } from "../util/http";
|
||||||
import { BalancesResponse } from "../types/walletTypes";
|
|
||||||
import { CryptoApi, CryptoWorkerFactory } from "../crypto/workers/cryptoApi";
|
|
||||||
import { AsyncOpMemoMap, AsyncOpMemoSingle } from "../util/asyncMemo";
|
|
||||||
import { Logger } from "../util/logging";
|
|
||||||
import { PendingOperationsResponse } from "../types/pendingTypes";
|
|
||||||
import { WalletNotification } from "../types/notifications";
|
|
||||||
import { Database } from "../util/query";
|
|
||||||
import { openPromise, OpenedPromise } from "../util/promiseUtils";
|
|
||||||
import { Stores } from "../types/dbTypes";
|
|
||||||
|
|
||||||
type NotificationListener = (n: WalletNotification) => void;
|
type NotificationListener = (n: WalletNotification) => void;
|
||||||
|
|
||||||
|
@ -14,28 +14,20 @@
|
|||||||
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/>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Imports.
|
||||||
|
*/
|
||||||
import { Logger } from "../util/logging";
|
import { Logger } from "../util/logging";
|
||||||
import {
|
import {
|
||||||
HttpRequestLibrary,
|
HttpRequestLibrary,
|
||||||
readSuccessResponseJsonOrThrow,
|
readSuccessResponseJsonOrThrow,
|
||||||
checkSuccessResponseOrThrow,
|
checkSuccessResponseOrThrow,
|
||||||
} from "../util/http";
|
} from "../util/http";
|
||||||
import { codecForAny } from "../util/codec";
|
import { AmountString, codecForAny, CheckPaymentResponse, codecForCheckPaymentResponse, IntegrationTestArgs, Amounts, TestPayArgs, PreparePayResultType } from "@gnu-taler/taler-util";
|
||||||
import {
|
import { URL } from "../index.js";
|
||||||
AmountString,
|
import { Wallet } from "../wallet.js";
|
||||||
CheckPaymentResponse,
|
import { createTalerWithdrawReserve } from "./reserves.js";
|
||||||
codecForCheckPaymentResponse,
|
import { InternalWalletState } from "./state.js";
|
||||||
} from "../types/talerTypes";
|
|
||||||
import { InternalWalletState } from "./state";
|
|
||||||
import { createTalerWithdrawReserve } from "./reserves";
|
|
||||||
import { URL } from "../util/url";
|
|
||||||
import { Wallet } from "../wallet";
|
|
||||||
import { Amounts } from "../util/amounts";
|
|
||||||
import {
|
|
||||||
TestPayArgs,
|
|
||||||
PreparePayResultType,
|
|
||||||
IntegrationTestArgs,
|
|
||||||
} from "../types/walletTypes";
|
|
||||||
|
|
||||||
const logger = new Logger("operations/testing.ts");
|
const logger = new Logger("operations/testing.ts");
|
||||||
|
|
||||||
|
@ -14,45 +14,50 @@
|
|||||||
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 { InternalWalletState } from "./state";
|
/**
|
||||||
import { parseTipUri } from "../util/taleruri";
|
* Imports.
|
||||||
import { PrepareTipResult, TalerErrorDetails } from "../types/walletTypes";
|
*/
|
||||||
import {
|
import {
|
||||||
TipPlanchetDetail,
|
PrepareTipResult,
|
||||||
|
parseTipUri,
|
||||||
codecForTipPickupGetResponse,
|
codecForTipPickupGetResponse,
|
||||||
|
Amounts,
|
||||||
|
getTimestampNow,
|
||||||
|
TalerErrorDetails,
|
||||||
|
NotificationType,
|
||||||
|
TipPlanchetDetail,
|
||||||
|
TalerErrorCode,
|
||||||
codecForTipResponse,
|
codecForTipResponse,
|
||||||
} from "../types/talerTypes";
|
} from "@gnu-taler/taler-util";
|
||||||
import * as Amounts from "../util/amounts";
|
import { DerivedTipPlanchet } from "../crypto/cryptoTypes.js";
|
||||||
import {
|
import {
|
||||||
Stores,
|
Stores,
|
||||||
|
DenominationRecord,
|
||||||
CoinRecord,
|
CoinRecord,
|
||||||
CoinSourceType,
|
CoinSourceType,
|
||||||
CoinStatus,
|
CoinStatus,
|
||||||
DenominationRecord,
|
} from "../db.js";
|
||||||
} from "../types/dbTypes";
|
import {
|
||||||
|
Logger,
|
||||||
|
URL,
|
||||||
|
readSuccessResponseJsonOrThrow,
|
||||||
|
encodeCrock,
|
||||||
|
getRandomBytes,
|
||||||
|
getHttpResponseErrorDetails,
|
||||||
|
} from "../index.js";
|
||||||
|
import { j2s } from "../util/helpers.js";
|
||||||
|
import { checkDbInvariant, checkLogicInvariant } from "../util/invariants.js";
|
||||||
|
import { initRetryInfo, updateRetryInfoTimeout } from "../util/retries.js";
|
||||||
|
import { guardOperationException, makeErrorDetails } from "./errors.js";
|
||||||
|
import { updateExchangeFromUrl } from "./exchanges.js";
|
||||||
|
import { InternalWalletState } from "./state";
|
||||||
import {
|
import {
|
||||||
getExchangeWithdrawalInfo,
|
getExchangeWithdrawalInfo,
|
||||||
denomSelectionInfoToState,
|
|
||||||
updateWithdrawalDenoms,
|
updateWithdrawalDenoms,
|
||||||
getCandidateWithdrawalDenoms,
|
getCandidateWithdrawalDenoms,
|
||||||
selectWithdrawalDenominations,
|
selectWithdrawalDenominations,
|
||||||
} from "./withdraw";
|
denomSelectionInfoToState,
|
||||||
import { updateExchangeFromUrl } from "./exchanges";
|
} from "./withdraw.js";
|
||||||
import { getRandomBytes, encodeCrock } from "../crypto/talerCrypto";
|
|
||||||
import { guardOperationException, makeErrorDetails } from "./errors";
|
|
||||||
import { NotificationType } from "../types/notifications";
|
|
||||||
import { getTimestampNow } from "../util/time";
|
|
||||||
import {
|
|
||||||
getHttpResponseErrorDetails,
|
|
||||||
readSuccessResponseJsonOrThrow,
|
|
||||||
} from "../util/http";
|
|
||||||
import { URL } from "../util/url";
|
|
||||||
import { Logger } from "../util/logging";
|
|
||||||
import { checkDbInvariant, checkLogicInvariant } from "../util/invariants";
|
|
||||||
import { TalerErrorCode } from "../TalerErrorCode";
|
|
||||||
import { initRetryInfo, updateRetryInfoTimeout } from "../util/retries";
|
|
||||||
import { j2s } from "../util/helpers";
|
|
||||||
import { DerivedTipPlanchet } from "../types/cryptoTypes";
|
|
||||||
|
|
||||||
const logger = new Logger("operations/tip.ts");
|
const logger = new Logger("operations/tip.ts");
|
||||||
|
|
||||||
|
@ -24,9 +24,8 @@ import {
|
|||||||
RefundState,
|
RefundState,
|
||||||
ReserveRecordStatus,
|
ReserveRecordStatus,
|
||||||
AbortStatus,
|
AbortStatus,
|
||||||
} from "../types/dbTypes";
|
} from "../db.js";
|
||||||
import { Amounts, AmountJson } from "../util/amounts";
|
import { AmountJson, Amounts, timestampCmp } from "@gnu-taler/taler-util";
|
||||||
import { timestampCmp } from "../util/time";
|
|
||||||
import {
|
import {
|
||||||
TransactionsRequest,
|
TransactionsRequest,
|
||||||
TransactionsResponse,
|
TransactionsResponse,
|
||||||
@ -36,9 +35,8 @@ import {
|
|||||||
WithdrawalType,
|
WithdrawalType,
|
||||||
WithdrawalDetails,
|
WithdrawalDetails,
|
||||||
OrderShortInfo,
|
OrderShortInfo,
|
||||||
} from "../types/transactionsTypes";
|
} from "@gnu-taler/taler-util";
|
||||||
import { getFundingPaytoUris } from "./reserves";
|
import { getFundingPaytoUris } from "./reserves";
|
||||||
import { TipResponse } from "../types/talerTypes";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an event ID from the type and the primary key for the event.
|
* Create an event ID from the type and the primary key for the event.
|
||||||
|
@ -14,10 +14,10 @@
|
|||||||
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 { Amounts } from "@gnu-taler/taler-util";
|
||||||
import test from "ava";
|
import test from "ava";
|
||||||
|
import { DenominationRecord, DenominationStatus } from "../db.js";
|
||||||
import { selectWithdrawalDenominations } from "./withdraw";
|
import { selectWithdrawalDenominations } from "./withdraw";
|
||||||
import { Amounts } from "../util/amounts";
|
|
||||||
import { DenominationRecord, DenominationStatus } from "../types/dbTypes";
|
|
||||||
|
|
||||||
test("withdrawal selection bug repro", (t) => {
|
test("withdrawal selection bug repro", (t) => {
|
||||||
const amount = {
|
const amount = {
|
||||||
|
@ -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 { AmountJson, Amounts } from "../util/amounts";
|
import { AmountJson, Amounts, parseWithdrawUri, Timestamp } from "@gnu-taler/taler-util";
|
||||||
import {
|
import {
|
||||||
DenominationRecord,
|
DenominationRecord,
|
||||||
Stores,
|
Stores,
|
||||||
@ -25,22 +25,22 @@ import {
|
|||||||
DenominationSelectionInfo,
|
DenominationSelectionInfo,
|
||||||
PlanchetRecord,
|
PlanchetRecord,
|
||||||
DenomSelectionState,
|
DenomSelectionState,
|
||||||
} from "../types/dbTypes";
|
ExchangeRecord,
|
||||||
|
ExchangeWireInfo,
|
||||||
|
} from "../db";
|
||||||
import {
|
import {
|
||||||
BankWithdrawDetails,
|
BankWithdrawDetails,
|
||||||
ExchangeWithdrawDetails,
|
|
||||||
TalerErrorDetails,
|
TalerErrorDetails,
|
||||||
ExchangeListItem,
|
ExchangeListItem,
|
||||||
WithdrawUriInfoResponse,
|
WithdrawUriInfoResponse,
|
||||||
} from "../types/walletTypes";
|
} from "@gnu-taler/taler-util";
|
||||||
import {
|
import {
|
||||||
codecForWithdrawOperationStatusResponse,
|
codecForWithdrawOperationStatusResponse,
|
||||||
codecForWithdrawResponse,
|
codecForWithdrawResponse,
|
||||||
WithdrawResponse,
|
WithdrawResponse,
|
||||||
codecForTalerConfigResponse,
|
codecForTalerConfigResponse,
|
||||||
} from "../types/talerTypes";
|
} from "@gnu-taler/taler-util";
|
||||||
import { InternalWalletState } from "./state";
|
import { InternalWalletState } from "./state";
|
||||||
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 {
|
import {
|
||||||
@ -48,29 +48,115 @@ import {
|
|||||||
WALLET_BANK_INTEGRATION_PROTOCOL_VERSION,
|
WALLET_BANK_INTEGRATION_PROTOCOL_VERSION,
|
||||||
} from "./versions";
|
} from "./versions";
|
||||||
|
|
||||||
import * as LibtoolVersion from "../util/libtoolVersion";
|
import * as LibtoolVersion from "@gnu-taler/taler-util";
|
||||||
import {
|
import {
|
||||||
guardOperationException,
|
guardOperationException,
|
||||||
makeErrorDetails,
|
makeErrorDetails,
|
||||||
OperationFailedError,
|
OperationFailedError,
|
||||||
} from "./errors";
|
} from "./errors";
|
||||||
import { NotificationType } from "../types/notifications";
|
import { NotificationType } from "@gnu-taler/taler-util";
|
||||||
import {
|
import {
|
||||||
getTimestampNow,
|
getTimestampNow,
|
||||||
getDurationRemaining,
|
getDurationRemaining,
|
||||||
timestampCmp,
|
timestampCmp,
|
||||||
timestampSubtractDuraction,
|
timestampSubtractDuraction,
|
||||||
} from "../util/time";
|
} from "@gnu-taler/taler-util";
|
||||||
import { readSuccessResponseJsonOrThrow } from "../util/http";
|
import { readSuccessResponseJsonOrThrow } from "../util/http";
|
||||||
import { URL } from "../util/url";
|
import { URL } from "../util/url";
|
||||||
import { TalerErrorCode } from "../TalerErrorCode";
|
import { TalerErrorCode } from "@gnu-taler/taler-util";
|
||||||
import { encodeCrock } from "../crypto/talerCrypto";
|
|
||||||
import { updateRetryInfoTimeout, initRetryInfo } from "../util/retries";
|
import { updateRetryInfoTimeout, initRetryInfo } from "../util/retries";
|
||||||
import { compare } from "../util/libtoolVersion";
|
import { compare } from "@gnu-taler/taler-util";
|
||||||
import { j2s } from "../util/helpers";
|
|
||||||
|
|
||||||
const logger = new Logger("withdraw.ts");
|
const logger = new Logger("withdraw.ts");
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Information about what will happen when creating a reserve.
|
||||||
|
*
|
||||||
|
* Sent to the wallet frontend to be rendered and shown to the user.
|
||||||
|
*/
|
||||||
|
interface ExchangeWithdrawDetails {
|
||||||
|
/**
|
||||||
|
* Exchange that the reserve will be created at.
|
||||||
|
*/
|
||||||
|
exchangeInfo: ExchangeRecord;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filtered wire info to send to the bank.
|
||||||
|
*/
|
||||||
|
exchangeWireAccounts: string[];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Selected denominations for withdraw.
|
||||||
|
*/
|
||||||
|
selectedDenoms: DenominationSelectionInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fees for withdraw.
|
||||||
|
*/
|
||||||
|
withdrawFee: AmountJson;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remaining balance that is too small to be withdrawn.
|
||||||
|
*/
|
||||||
|
overhead: AmountJson;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wire fees from the exchange.
|
||||||
|
*/
|
||||||
|
wireFees: ExchangeWireInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Does the wallet know about an auditor for
|
||||||
|
* the exchange that the reserve.
|
||||||
|
*/
|
||||||
|
isAudited: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Did the user already accept the current terms of service for the exchange?
|
||||||
|
*/
|
||||||
|
termsOfServiceAccepted: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The exchange is trusted directly.
|
||||||
|
*/
|
||||||
|
isTrusted: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The earliest deposit expiration of the selected coins.
|
||||||
|
*/
|
||||||
|
earliestDepositExpiration: Timestamp;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Number of currently offered denominations.
|
||||||
|
*/
|
||||||
|
numOfferedDenoms: number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Public keys of trusted auditors for the currency we're withdrawing.
|
||||||
|
*/
|
||||||
|
trustedAuditorPubs: string[];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Result of checking the wallet's version
|
||||||
|
* against the exchange's version.
|
||||||
|
*
|
||||||
|
* Older exchanges don't return version information.
|
||||||
|
*/
|
||||||
|
versionMatch: LibtoolVersion.VersionMatchResult | undefined;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Libtool-style version string for the exchange or "unknown"
|
||||||
|
* for older exchanges.
|
||||||
|
*/
|
||||||
|
exchangeVersion: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Libtool-style version string for the wallet.
|
||||||
|
*/
|
||||||
|
walletVersion: string;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a denom is withdrawable based on the expiration time
|
* Check if a denom is withdrawable based on the expiration time
|
||||||
* and revocation state.
|
* and revocation state.
|
||||||
|
@ -16,15 +16,17 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Type and schema definitions for pending operations in the wallet.
|
* Type and schema definitions for pending operations in the wallet.
|
||||||
|
*
|
||||||
|
* These are only used internally, and are not part of the public
|
||||||
|
* interface to the wallet.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Imports.
|
* Imports.
|
||||||
*/
|
*/
|
||||||
import { TalerErrorDetails, BalancesResponse } from "./walletTypes";
|
import { TalerErrorDetails, BalancesResponse, Duration, Timestamp } from "@gnu-taler/taler-util";
|
||||||
import { ReserveRecordStatus } from "./dbTypes";
|
import { ReserveRecordStatus } from "./db.js";
|
||||||
import { Timestamp, Duration } from "../util/time";
|
import { RetryInfo } from "./util/retries.js";
|
||||||
import { RetryInfo } from "../util/retries";
|
|
||||||
|
|
||||||
export enum PendingOperationType {
|
export enum PendingOperationType {
|
||||||
Bug = "bug",
|
Bug = "bug",
|
File diff suppressed because it is too large
Load Diff
@ -25,7 +25,7 @@ import {
|
|||||||
getTimestampNow,
|
getTimestampNow,
|
||||||
timestampDifference,
|
timestampDifference,
|
||||||
timestampCmp,
|
timestampCmp,
|
||||||
} from "../util/time";
|
} from "@gnu-taler/taler-util";
|
||||||
import { URL } from "./url";
|
import { URL } from "./url";
|
||||||
import { Logger } from "./logging";
|
import { Logger } from "./logging";
|
||||||
|
|
||||||
|
@ -17,8 +17,8 @@
|
|||||||
/**
|
/**
|
||||||
* Imports.
|
* Imports.
|
||||||
*/
|
*/
|
||||||
|
import { AmountJson, Amounts } from "@gnu-taler/taler-util";
|
||||||
import test from "ava";
|
import test from "ava";
|
||||||
import { AmountJson, Amounts } from "..";
|
|
||||||
import { AvailableCoinInfo, selectPayCoins } from "./coinSelection";
|
import { AvailableCoinInfo, selectPayCoins } from "./coinSelection";
|
||||||
|
|
||||||
function a(x: string): AmountJson {
|
function a(x: string): AmountJson {
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
/**
|
/**
|
||||||
* Imports.
|
* Imports.
|
||||||
*/
|
*/
|
||||||
import { AmountJson, Amounts } from "./amounts";
|
import { AmountJson, Amounts } from "@gnu-taler/taler-util";
|
||||||
import { strcmp } from "./helpers";
|
import { strcmp } from "./helpers";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -21,8 +21,7 @@
|
|||||||
/**
|
/**
|
||||||
* Imports.
|
* Imports.
|
||||||
*/
|
*/
|
||||||
import { AmountJson } from "./amounts";
|
import { AmountJson, Amounts } from "@gnu-taler/taler-util";
|
||||||
import * as Amounts from "./amounts";
|
|
||||||
import { URL } from "./url";
|
import { URL } from "./url";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -24,19 +24,18 @@
|
|||||||
/**
|
/**
|
||||||
* Imports
|
* Imports
|
||||||
*/
|
*/
|
||||||
import { Codec } from "./codec";
|
|
||||||
import { OperationFailedError, makeErrorDetails } from "../operations/errors";
|
import { OperationFailedError, makeErrorDetails } from "../operations/errors";
|
||||||
import { TalerErrorCode } from "../TalerErrorCode";
|
|
||||||
import { Logger } from "./logging";
|
import { Logger } from "./logging";
|
||||||
import {
|
import {
|
||||||
Duration,
|
Duration,
|
||||||
Timestamp,
|
Timestamp,
|
||||||
getTimestampNow,
|
getTimestampNow,
|
||||||
timestampAddDuration,
|
timestampAddDuration,
|
||||||
timestampMin,
|
|
||||||
timestampMax,
|
timestampMax,
|
||||||
} from "./time";
|
TalerErrorDetails,
|
||||||
import { TalerErrorDetails } from "..";
|
Codec,
|
||||||
|
} from "@gnu-taler/taler-util";
|
||||||
|
import { TalerErrorCode } from "@gnu-taler/taler-util";
|
||||||
|
|
||||||
const logger = new Logger("http.ts");
|
const logger = new Logger("http.ts");
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
/**
|
/**
|
||||||
* Imports.
|
* Imports.
|
||||||
*/
|
*/
|
||||||
import { Timestamp, Duration, getTimestampNow } from "./time";
|
import { Timestamp, Duration, getTimestampNow } from "@gnu-taler/taler-util";
|
||||||
|
|
||||||
export interface RetryInfo {
|
export interface RetryInfo {
|
||||||
firstTry: Timestamp;
|
firstTry: Timestamp;
|
||||||
|
@ -1,36 +0,0 @@
|
|||||||
/*
|
|
||||||
This file is part of GNU Taler
|
|
||||||
(C) 2020 Taler Systems S.A.
|
|
||||||
|
|
||||||
GNU Taler is free software; you can redistribute it and/or modify it under the
|
|
||||||
terms of the GNU General Public License as published by the Free Software
|
|
||||||
Foundation; either version 3, or (at your option) any later version.
|
|
||||||
|
|
||||||
GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
||||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
||||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License along with
|
|
||||||
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Imports
|
|
||||||
*/
|
|
||||||
import {
|
|
||||||
setupRefreshPlanchet,
|
|
||||||
encodeCrock,
|
|
||||||
getRandomBytes,
|
|
||||||
} from "../crypto/talerCrypto";
|
|
||||||
|
|
||||||
export function printTestVectors() {
|
|
||||||
const secretSeed = getRandomBytes(64);
|
|
||||||
const coinIndex = Math.ceil(Math.random() * 100);
|
|
||||||
const p = setupRefreshPlanchet(secretSeed, coinIndex);
|
|
||||||
console.log("setupRefreshPlanchet");
|
|
||||||
console.log(` (in) secret seed: ${encodeCrock(secretSeed)}`);
|
|
||||||
console.log(` (in) coin index: ${coinIndex}`);
|
|
||||||
console.log(` (out) blinding secret: ${encodeCrock(p.bks)}`);
|
|
||||||
console.log(` (out) coin priv: ${encodeCrock(p.coinPriv)}`);
|
|
||||||
console.log(` (out) coin pub: ${encodeCrock(p.coinPub)}`);
|
|
||||||
}
|
|
@ -24,7 +24,7 @@
|
|||||||
/**
|
/**
|
||||||
* Imports.
|
* Imports.
|
||||||
*/
|
*/
|
||||||
import { Duration } from "./time";
|
import { Duration } from "@gnu-taler/taler-util";
|
||||||
import { Logger } from "./logging";
|
import { Logger } from "./logging";
|
||||||
|
|
||||||
const logger = new Logger("timer.ts");
|
const logger = new Logger("timer.ts");
|
||||||
|
@ -1,51 +0,0 @@
|
|||||||
/*
|
|
||||||
This file is part of TALER
|
|
||||||
(C) 2017 GNUnet e.V.
|
|
||||||
|
|
||||||
TALER is free software; you can redistribute it and/or modify it under the
|
|
||||||
terms of the GNU General Public License as published by the Free Software
|
|
||||||
Foundation; either version 3, or (at your option) any later version.
|
|
||||||
|
|
||||||
TALER is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
||||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
||||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License along with
|
|
||||||
TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Display and manipulate wire information.
|
|
||||||
*
|
|
||||||
* Right now, all types are hard-coded. In the future, there might be plugins / configurable
|
|
||||||
* methods or support for the "payto://" URI scheme.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Imports.
|
|
||||||
*/
|
|
||||||
import * as i18n from "../i18n";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Short summary of the wire information.
|
|
||||||
*
|
|
||||||
* Might abbreviate and return the same summary for different
|
|
||||||
* wire details.
|
|
||||||
*/
|
|
||||||
export function summarizeWire(w: any): string {
|
|
||||||
if (!w.type) {
|
|
||||||
return i18n.str`Invalid Wire`;
|
|
||||||
}
|
|
||||||
switch (w.type.toLowerCase()) {
|
|
||||||
case "test":
|
|
||||||
if (!w.account_number && w.account_number !== 0) {
|
|
||||||
return i18n.str`Invalid Test Wire Detail`;
|
|
||||||
}
|
|
||||||
if (!w.bank_uri) {
|
|
||||||
return i18n.str`Invalid Test Wire Detail`;
|
|
||||||
}
|
|
||||||
return i18n.str`Test Wire Acct #${w.account_number} on ${w.bank_uri}`;
|
|
||||||
default:
|
|
||||||
return i18n.str`Unknown Wire Detail`;
|
|
||||||
}
|
|
||||||
}
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user