aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2020-04-06 21:15:41 +0530
committerFlorian Dold <florian.dold@gmail.com>2020-04-06 21:15:41 +0530
commitf36bb7a04eabe0330cb166bf9ce5021c92f38dc8 (patch)
tree9a242a06bd5353c8b167600c31776c9f16d9d21c
parent07f25566ca51b7faf6462a57d15f4ebbfc733ab0 (diff)
linter
-rw-r--r--.eslintrc.js1
-rw-r--r--src/android/index.ts2
-rw-r--r--src/crypto/primitives/nacl-fast.ts234
-rw-r--r--src/crypto/primitives/sha256.ts10
-rw-r--r--src/crypto/talerCrypto-test.ts2
-rw-r--r--src/crypto/workers/cryptoApi.ts8
-rw-r--r--src/crypto/workers/cryptoImplementation.ts6
-rw-r--r--src/headless/clk.ts24
-rw-r--r--src/headless/helpers.ts6
-rw-r--r--src/headless/integrationtest.ts10
-rw-r--r--src/headless/taler-wallet-cli.ts2
-rw-r--r--src/i18n/strings-prelude2
-rw-r--r--src/i18n/strings.ts2
-rw-r--r--src/operations/exchanges.ts8
-rw-r--r--src/operations/history.ts2
-rw-r--r--src/operations/pay.ts10
-rw-r--r--src/operations/pending.ts16
-rw-r--r--src/operations/recoup.ts6
-rw-r--r--src/operations/refresh.ts4
-rw-r--r--src/operations/refund.ts6
-rw-r--r--src/operations/reserves.ts8
-rw-r--r--src/operations/tip.ts4
-rw-r--r--src/operations/withdraw.ts4
-rw-r--r--src/types/dbTypes.ts2
-rw-r--r--src/util/amounts.ts2
-rw-r--r--src/util/query.ts6
-rw-r--r--src/util/time.ts2
-rw-r--r--src/util/timer.ts2
-rw-r--r--src/wallet.ts12
-rw-r--r--src/webex/chromeBadge.ts8
-rw-r--r--src/webex/i18n.tsx2
-rw-r--r--src/webex/notify.ts4
-rw-r--r--src/webex/pages/benchmark.tsx2
-rw-r--r--src/webex/pages/popup.tsx6
-rw-r--r--src/webex/renderHtml.tsx2
-rw-r--r--src/webex/wxBackend.ts4
36 files changed, 216 insertions, 215 deletions
diff --git a/.eslintrc.js b/.eslintrc.js
index 3ced40923..acc5305f4 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -9,4 +9,5 @@ module.exports = {
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
],
+ rules: {},
};
diff --git a/src/android/index.ts b/src/android/index.ts
index e984ce4db..9c7efc0e1 100644
--- a/src/android/index.ts
+++ b/src/android/index.ts
@@ -44,7 +44,7 @@ export {
} from "../crypto/workers/nodeThreadWorker";
export class AndroidHttpLib implements HttpRequestLibrary {
- useNfcTunnel: boolean = false;
+ useNfcTunnel = false;
private nodeHttpLib: HttpRequestLibrary = new NodeHttpLib();
diff --git a/src/crypto/primitives/nacl-fast.ts b/src/crypto/primitives/nacl-fast.ts
index 23d8378b4..1defe1ad0 100644
--- a/src/crypto/primitives/nacl-fast.ts
+++ b/src/crypto/primitives/nacl-fast.ts
@@ -127,7 +127,7 @@ function ts64(x: Uint8Array, i: number, h: number, l: number) {
}
function vn(x: Uint8Array, xi: number, y: Uint8Array, yi: number, n: number) {
- var i,
+ let i,
d = 0;
for (i = 0; i < n; i++) d |= x[xi + i] ^ y[yi + i];
return (1 & ((d - 1) >>> 8)) - 1;
@@ -153,7 +153,7 @@ function crypto_verify_32(
// prettier-ignore
function core_salsa20(o: Uint8Array, p: Uint8Array, k: Uint8Array, c: Uint8Array) {
- var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,
+ const j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,
j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,
j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,
j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,
@@ -170,11 +170,11 @@ function core_salsa20(o: Uint8Array, p: Uint8Array, k: Uint8Array, c: Uint8Array
j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,
j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;
- var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,
+ let x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,
x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,
x15 = j15, u;
- for (var i = 0; i < 20; i += 2) {
+ for (let i = 0; i < 20; i += 2) {
u = x0 + x12 | 0;
x4 ^= u<<7 | u>>>(32-7);
u = x4 + x0 | 0;
@@ -351,7 +351,7 @@ function core_hsalsa20(
k: Uint8Array,
c: Uint8Array,
) {
- var j0 =
+ const j0 =
(c[0] & 0xff) |
((c[1] & 0xff) << 8) |
((c[2] & 0xff) << 16) |
@@ -432,7 +432,7 @@ function core_hsalsa20(
((c[14] & 0xff) << 16) |
((c[15] & 0xff) << 24);
- var x0 = j0,
+ let x0 = j0,
x1 = j1,
x2 = j2,
x3 = j3,
@@ -450,7 +450,7 @@ function core_hsalsa20(
x15 = j15,
u;
- for (var i = 0; i < 20; i += 2) {
+ for (let i = 0; i < 20; i += 2) {
u = (x0 + x12) | 0;
x4 ^= (u << 7) | (u >>> (32 - 7));
u = (x4 + x0) | 0;
@@ -583,7 +583,7 @@ function crypto_core_hsalsa20(
core_hsalsa20(out, inp, k, c);
}
-var sigma = new Uint8Array([
+const sigma = new Uint8Array([
101,
120,
112,
@@ -612,9 +612,9 @@ function crypto_stream_salsa20_xor(
n: Uint8Array,
k: Uint8Array,
) {
- var z = new Uint8Array(16),
+ const z = new Uint8Array(16),
x = new Uint8Array(64);
- var u, i;
+ let u, i;
for (i = 0; i < 16; i++) z[i] = 0;
for (i = 0; i < 8; i++) z[i] = n[i];
while (b >= 64) {
@@ -644,9 +644,9 @@ function crypto_stream_salsa20(
n: Uint8Array,
k: Uint8Array,
) {
- var z = new Uint8Array(16),
+ const z = new Uint8Array(16),
x = new Uint8Array(64);
- var u, i;
+ let u, i;
for (i = 0; i < 16; i++) z[i] = 0;
for (i = 0; i < 8; i++) z[i] = n[i];
while (b >= 64) {
@@ -675,10 +675,10 @@ function crypto_stream(
n: Uint8Array,
k: Uint8Array,
) {
- var s = new Uint8Array(32);
+ const s = new Uint8Array(32);
crypto_core_hsalsa20(s, n, k, sigma);
- var sn = new Uint8Array(8);
- for (var i = 0; i < 8; i++) sn[i] = n[i + 16];
+ const sn = new Uint8Array(8);
+ for (let i = 0; i < 8; i++) sn[i] = n[i + 16];
return crypto_stream_salsa20(c, cpos, d, sn, s);
}
@@ -691,10 +691,10 @@ function crypto_stream_xor(
n: Uint8Array,
k: Uint8Array,
) {
- var s = new Uint8Array(32);
+ const s = new Uint8Array(32);
crypto_core_hsalsa20(s, n, k, sigma);
- var sn = new Uint8Array(8);
- for (var i = 0; i < 8; i++) sn[i] = n[i + 16];
+ const sn = new Uint8Array(8);
+ for (let i = 0; i < 8; i++) sn[i] = n[i + 16];
return crypto_stream_salsa20_xor(c, cpos, m, mpos, d, sn, s);
}
@@ -712,7 +712,7 @@ class poly1305 {
fin = 0;
constructor(key: Uint8Array) {
- var t0, t1, t2, t3, t4, t5, t6, t7;
+ let t0, t1, t2, t3, t4, t5, t6, t7;
t0 = (key[0] & 0xff) | ((key[1] & 0xff) << 8);
this.r[0] = t0 & 0x1fff;
@@ -744,11 +744,11 @@ class poly1305 {
}
blocks(m: Uint8Array, mpos: number, bytes: number) {
- var hibit = this.fin ? 0 : 1 << 11;
- var t0, t1, t2, t3, t4, t5, t6, t7, c;
- var d0, d1, d2, d3, d4, d5, d6, d7, d8, d9;
+ const hibit = this.fin ? 0 : 1 << 11;
+ let t0, t1, t2, t3, t4, t5, t6, t7, c;
+ let d0, d1, d2, d3, d4, d5, d6, d7, d8, d9;
- var h0 = this.h[0],
+ let h0 = this.h[0],
h1 = this.h[1],
h2 = this.h[2],
h3 = this.h[3],
@@ -759,7 +759,7 @@ class poly1305 {
h8 = this.h[8],
h9 = this.h[9];
- var r0 = this.r[0],
+ const r0 = this.r[0],
r1 = this.r[1],
r2 = this.r[2],
r3 = this.r[3],
@@ -985,8 +985,8 @@ class poly1305 {
}
finish(mac: Uint8Array, macpos: number) {
- var g = new Uint16Array(10);
- var c, mask, f, i;
+ const g = new Uint16Array(10);
+ let c, mask, f, i;
if (this.leftover) {
i = this.leftover;
@@ -1062,7 +1062,7 @@ class poly1305 {
}
update(m: Uint8Array, mpos: number, bytes: number) {
- var i, want;
+ let i, want;
if (this.leftover) {
want = 16 - this.leftover;
@@ -1098,7 +1098,7 @@ function crypto_onetimeauth(
n: number,
k: Uint8Array,
) {
- var s = new poly1305(k);
+ const s = new poly1305(k);
s.update(m, mpos, n);
s.finish(out, outpos);
return 0;
@@ -1112,7 +1112,7 @@ function crypto_onetimeauth_verify(
n: number,
k: Uint8Array,
) {
- var x = new Uint8Array(16);
+ const x = new Uint8Array(16);
crypto_onetimeauth(x, 0, m, mpos, n, k);
return crypto_verify_16(h, hpos, x, 0);
}
@@ -1124,7 +1124,7 @@ function crypto_secretbox(
n: Uint8Array,
k: Uint8Array,
) {
- var i;
+ let i;
if (d < 32) return -1;
crypto_stream_xor(c, 0, m, 0, d, n, k);
crypto_onetimeauth(c, 16, c, 32, d - 32, c);
@@ -1139,8 +1139,8 @@ function crypto_secretbox_open(
n: Uint8Array,
k: Uint8Array,
) {
- var i;
- var x = new Uint8Array(32);
+ let i;
+ const x = new Uint8Array(32);
if (d < 32) return -1;
crypto_stream(x, 0, 32, n, k);
if (crypto_onetimeauth_verify(c, 16, c, 32, d - 32, x) !== 0) return -1;
@@ -1150,12 +1150,12 @@ function crypto_secretbox_open(
}
function set25519(r: Float64Array, a: Float64Array) {
- var i;
+ let i;
for (i = 0; i < 16; i++) r[i] = a[i] | 0;
}
function car25519(o: Float64Array) {
- var i,
+ let i,
v,
c = 1;
for (i = 0; i < 16; i++) {
@@ -1167,9 +1167,9 @@ function car25519(o: Float64Array) {
}
function sel25519(p: Float64Array, q: Float64Array, b: number) {
- var t,
+ let t,
c = ~(b - 1);
- for (var i = 0; i < 16; i++) {
+ for (let i = 0; i < 16; i++) {
t = c & (p[i] ^ q[i]);
p[i] ^= t;
q[i] ^= t;
@@ -1177,8 +1177,8 @@ function sel25519(p: Float64Array, q: Float64Array, b: number) {
}
function pack25519(o: Uint8Array, n: Float64Array) {
- var i, j, b;
- var m = gf(),
+ let i, j, b;
+ const m = gf(),
t = gf();
for (i = 0; i < 16; i++) t[i] = n[i];
car25519(t);
@@ -1202,7 +1202,7 @@ function pack25519(o: Uint8Array, n: Float64Array) {
}
function neq25519(a: Float64Array, b: Float64Array) {
- var c = new Uint8Array(32),
+ const c = new Uint8Array(32),
d = new Uint8Array(32);
pack25519(c, a);
pack25519(d, b);
@@ -1210,27 +1210,27 @@ function neq25519(a: Float64Array, b: Float64Array) {
}
function par25519(a: Float64Array) {
- var d = new Uint8Array(32);
+ const d = new Uint8Array(32);
pack25519(d, a);
return d[0] & 1;
}
function unpack25519(o: Float64Array, n: Uint8Array) {
- var i;
+ let i;
for (i = 0; i < 16; i++) o[i] = n[2 * i] + (n[2 * i + 1] << 8);
o[15] &= 0x7fff;
}
function A(o: Float64Array, a: Float64Array, b: Float64Array) {
- for (var i = 0; i < 16; i++) o[i] = a[i] + b[i];
+ for (let i = 0; i < 16; i++) o[i] = a[i] + b[i];
}
function Z(o: Float64Array, a: Float64Array, b: Float64Array) {
- for (var i = 0; i < 16; i++) o[i] = a[i] - b[i];
+ for (let i = 0; i < 16; i++) o[i] = a[i] - b[i];
}
function M(o: Float64Array, a: Float64Array, b: Float64Array) {
- var v,
+ let v,
c,
t0 = 0,
t1 = 0,
@@ -1697,8 +1697,8 @@ function S(o: Float64Array, a: Float64Array) {
}
function inv25519(o: Float64Array, i: Float64Array) {
- var c = gf();
- var a;
+ const c = gf();
+ let a;
for (a = 0; a < 16; a++) c[a] = i[a];
for (a = 253; a >= 0; a--) {
S(c, c);
@@ -1708,8 +1708,8 @@ function inv25519(o: Float64Array, i: Float64Array) {
}
function pow2523(o: Float64Array, i: Float64Array) {
- var c = gf();
- var a;
+ const c = gf();
+ let a;
for (a = 0; a < 16; a++) c[a] = i[a];
for (a = 250; a >= 0; a--) {
S(c, c);
@@ -1719,11 +1719,11 @@ function pow2523(o: Float64Array, i: Float64Array) {
}
function crypto_scalarmult(q: Uint8Array, n: Uint8Array, p: Uint8Array) {
- var z = new Uint8Array(32);
- var x = new Float64Array(80),
+ const z = new Uint8Array(32);
+ let x = new Float64Array(80),
r,
i;
- var a = gf(),
+ const a = gf(),
b = gf(),
c = gf(),
d = gf(),
@@ -1769,8 +1769,8 @@ function crypto_scalarmult(q: Uint8Array, n: Uint8Array, p: Uint8Array) {
x[i + 48] = b[i];
x[i + 64] = d[i];
}
- var x32 = x.subarray(32);
- var x16 = x.subarray(16);
+ const x32 = x.subarray(32);
+ const x16 = x.subarray(16);
inv25519(x32, x32);
M(x16, x16, x32);
pack25519(q, x16);
@@ -1787,13 +1787,13 @@ function crypto_box_keypair(y: Uint8Array, x: Uint8Array) {
}
function crypto_box_beforenm(k: Uint8Array, y: Uint8Array, x: Uint8Array) {
- var s = new Uint8Array(32);
+ const s = new Uint8Array(32);
crypto_scalarmult(s, x, y);
return crypto_core_hsalsa20(k, _0, s, sigma);
}
-var crypto_box_afternm = crypto_secretbox;
-var crypto_box_open_afternm = crypto_secretbox_open;
+const crypto_box_afternm = crypto_secretbox;
+const crypto_box_open_afternm = crypto_secretbox_open;
function crypto_box(
c: Uint8Array,
@@ -1803,7 +1803,7 @@ function crypto_box(
y: Uint8Array,
x: Uint8Array,
) {
- var k = new Uint8Array(32);
+ const k = new Uint8Array(32);
crypto_box_beforenm(k, y, x);
return crypto_box_afternm(c, m, d, n, k);
}
@@ -1816,13 +1816,13 @@ function crypto_box_open(
y: Uint8Array,
x: Uint8Array,
) {
- var k = new Uint8Array(32);
+ const k = new Uint8Array(32);
crypto_box_beforenm(k, y, x);
return crypto_box_open_afternm(m, c, d, n, k);
}
// prettier-ignore
-var K = [
+const K = [
0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,
0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,
0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,
@@ -1871,7 +1871,7 @@ function crypto_hashblocks_hl(
m: Uint8Array,
n: number,
) {
- var wh = new Int32Array(16),
+ let wh = new Int32Array(16),
wl = new Int32Array(16),
bh0,
bh1,
@@ -1900,7 +1900,7 @@ function crypto_hashblocks_hl(
c,
d;
- var ah0 = hh[0],
+ let ah0 = hh[0],
ah1 = hh[1],
ah2 = hh[2],
ah3 = hh[3],
@@ -1917,7 +1917,7 @@ function crypto_hashblocks_hl(
al6 = hl[6],
al7 = hl[7];
- var pos = 0;
+ let pos = 0;
while (n >= 128) {
for (i = 0; i < 16; i++) {
j = 8 * i + pos;
@@ -2342,7 +2342,7 @@ function crypto_hash(out: Uint8Array, m: Uint8Array, n: number) {
const hh = new Int32Array(8);
const hl = new Int32Array(8);
const x = new Uint8Array(256);
- let b = n;
+ const b = n;
hh[0] = 0x6a09e667;
hh[1] = 0xbb67ae85;
@@ -2436,7 +2436,7 @@ export class HashState {
const out = new Uint8Array(64);
let n = this.p;
const x = new Uint8Array(256);
- let b = this.total;
+ const b = this.total;
for (let i = 0; i < n; i++) x[i] = this.next[i];
x[n] = 128;
@@ -2451,7 +2451,7 @@ export class HashState {
}
function add(p: Float64Array[], q: Float64Array[]) {
- var a = gf(),
+ const a = gf(),
b = gf(),
c = gf(),
d = gf(),
@@ -2483,14 +2483,14 @@ function add(p: Float64Array[], q: Float64Array[]) {
}
function cswap(p: Float64Array[], q: Float64Array[], b: number) {
- var i;
+ let i;
for (i = 0; i < 4; i++) {
sel25519(p[i], q[i], b);
}
}
function pack(r: Uint8Array, p: Float64Array[]) {
- var tx = gf(),
+ const tx = gf(),
ty = gf(),
zi = gf();
inv25519(zi, p[2]);
@@ -2501,7 +2501,7 @@ function pack(r: Uint8Array, p: Float64Array[]) {
}
function scalarmult(p: Float64Array[], q: Float64Array[], s: Uint8Array) {
- var b, i;
+ let b, i;
set25519(p[0], gf0);
set25519(p[1], gf1);
set25519(p[2], gf1);
@@ -2545,7 +2545,7 @@ function crypto_sign_keypair(
return 0;
}
-var L = new Float64Array([
+const L = new Float64Array([
0xed,
0xd3,
0xf5,
@@ -2581,7 +2581,7 @@ var L = new Float64Array([
]);
function modL(r: Uint8Array, x: Float64Array) {
- var carry, i, j, k;
+ let carry, i, j, k;
for (i = 63; i >= 32; --i) {
carry = 0;
for (j = i - 32, k = i - 12; j < k; ++j) {
@@ -2614,20 +2614,20 @@ function reduce(r: Uint8Array) {
// Note: difference from C - smlen returned, not passed as argument.
function crypto_sign(sm: Uint8Array, m: Uint8Array, n: number, sk: Uint8Array) {
- var d = new Uint8Array(64),
+ const d = new Uint8Array(64),
h = new Uint8Array(64),
r = new Uint8Array(64);
- var i,
+ let i,
j,
x = new Float64Array(64);
- var p = [gf(), gf(), gf(), gf()];
+ const p = [gf(), gf(), gf(), gf()];
crypto_hash(d, sk, 32);
d[0] &= 248;
d[31] &= 127;
d[31] |= 64;
- var smlen = n + 64;
+ const smlen = n + 64;
for (i = 0; i < n; i++) sm[64 + i] = m[i];
for (i = 0; i < 32; i++) sm[32 + i] = d[32 + i];
@@ -2700,10 +2700,10 @@ function crypto_sign_open(
n: number,
pk: Uint8Array,
) {
- var i, mlen;
- var t = new Uint8Array(32),
+ let i, mlen;
+ const t = new Uint8Array(32),
h = new Uint8Array(64);
- var p = [gf(), gf(), gf(), gf()],
+ const p = [gf(), gf(), gf(), gf()],
q = [gf(), gf(), gf(), gf()];
mlen = -1;
@@ -2732,7 +2732,7 @@ function crypto_sign_open(
return mlen;
}
-var crypto_secretbox_KEYBYTES = 32,
+const crypto_secretbox_KEYBYTES = 32,
crypto_secretbox_NONCEBYTES = 24,
crypto_secretbox_ZEROBYTES = 32,
crypto_secretbox_BOXZEROBYTES = 16,
@@ -2809,18 +2809,18 @@ function checkBoxLengths(pk: Uint8Array, sk: Uint8Array) {
}
function checkArrayTypes(...args: Uint8Array[]) {
- for (var i = 0; i < args.length; i++) {
+ for (let i = 0; i < args.length; i++) {
if (!(args[i] instanceof Uint8Array))
throw new TypeError("unexpected type, use Uint8Array");
}
}
function cleanup(arr: Uint8Array) {
- for (var i = 0; i < arr.length; i++) arr[i] = 0;
+ for (let i = 0; i < arr.length; i++) arr[i] = 0;
}
export function randomBytes(n: number) {
- var b = new Uint8Array(n);
+ const b = new Uint8Array(n);
randombytes(b, n);
return b;
}
@@ -2828,9 +2828,9 @@ export function randomBytes(n: number) {
export function secretbox(msg: Uint8Array, nonce: Uint8Array, key: Uint8Array) {
checkArrayTypes(msg, nonce, key);
checkLengths(key, nonce);
- var m = new Uint8Array(crypto_secretbox_ZEROBYTES + msg.length);
- var c = new Uint8Array(m.length);
- for (var i = 0; i < msg.length; i++)
+ const m = new Uint8Array(crypto_secretbox_ZEROBYTES + msg.length);
+ const c = new Uint8Array(m.length);
+ for (let i = 0; i < msg.length; i++)
m[i + crypto_secretbox_ZEROBYTES] = msg[i];
crypto_secretbox(c, m, m.length, nonce, key);
return c.subarray(crypto_secretbox_BOXZEROBYTES);
@@ -2843,9 +2843,9 @@ export function secretbox_open(
) {
checkArrayTypes(box, nonce, key);
checkLengths(key, nonce);
- var c = new Uint8Array(crypto_secretbox_BOXZEROBYTES + box.length);
- var m = new Uint8Array(c.length);
- for (var i = 0; i < box.length; i++)
+ const c = new Uint8Array(crypto_secretbox_BOXZEROBYTES + box.length);
+ const m = new Uint8Array(c.length);
+ for (let i = 0; i < box.length; i++)
c[i + crypto_secretbox_BOXZEROBYTES] = box[i];
if (c.length < 32) return null;
if (crypto_secretbox_open(m, c, c.length, nonce, key) !== 0) return null;
@@ -2860,7 +2860,7 @@ export function scalarMult(n: Uint8Array, p: Uint8Array) {
checkArrayTypes(n, p);
if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error("bad n size");
if (p.length !== crypto_scalarmult_BYTES) throw new Error("bad p size");
- var q = new Uint8Array(crypto_scalarmult_BYTES);
+ const q = new Uint8Array(crypto_scalarmult_BYTES);
crypto_scalarmult(q, n, p);
return q;
}
@@ -2868,7 +2868,7 @@ export function scalarMult(n: Uint8Array, p: Uint8Array) {
export function scalarMult_base(n: Uint8Array) {
checkArrayTypes(n);
if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error("bad n size");
- var q = new Uint8Array(crypto_scalarmult_BYTES);
+ const q = new Uint8Array(crypto_scalarmult_BYTES);
crypto_scalarmult_base(q, n);
return q;
}
@@ -2882,14 +2882,14 @@ export function box(
publicKey: Uint8Array,
secretKey: Uint8Array,
) {
- var k = box_before(publicKey, secretKey);
+ const k = box_before(publicKey, secretKey);
return secretbox(msg, nonce, k);
}
export function box_before(publicKey: Uint8Array, secretKey: Uint8Array) {
checkArrayTypes(publicKey, secretKey);
checkBoxLengths(publicKey, secretKey);
- var k = new Uint8Array(crypto_box_BEFORENMBYTES);
+ const k = new Uint8Array(crypto_box_BEFORENMBYTES);
crypto_box_beforenm(k, publicKey, secretKey);
return k;
}
@@ -2902,15 +2902,15 @@ export function box_open(
publicKey: Uint8Array,
secretKey: Uint8Array,
) {
- var k = box_before(publicKey, secretKey);
+ const k = box_before(publicKey, secretKey);
return secretbox_open(msg, nonce, k);
}
export const box_open_after = secretbox_open;
export function box_keyPair() {
- var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);
- var sk = new Uint8Array(crypto_box_SECRETKEYBYTES);
+ const pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);
+ const sk = new Uint8Array(crypto_box_SECRETKEYBYTES);
crypto_box_keypair(pk, sk);
return { publicKey: pk, secretKey: sk };
}
@@ -2919,7 +2919,7 @@ export function box_keyPair_fromSecretKey(secretKey: Uint8Array) {
checkArrayTypes(secretKey);
if (secretKey.length !== crypto_box_SECRETKEYBYTES)
throw new Error("bad secret key size");
- var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);
+ const pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);
crypto_scalarmult_base(pk, secretKey);
return { publicKey: pk, secretKey: new Uint8Array(secretKey) };
}
@@ -2934,7 +2934,7 @@ export function sign(msg: Uint8Array, secretKey: Uint8Array) {
checkArrayTypes(msg, secretKey);
if (secretKey.length !== crypto_sign_SECRETKEYBYTES)
throw new Error("bad secret key size");
- var signedMsg = new Uint8Array(crypto_sign_BYTES + msg.length);
+ const signedMsg = new Uint8Array(crypto_sign_BYTES + msg.length);
crypto_sign(signedMsg, msg, msg.length, secretKey);
return signedMsg;
}
@@ -2943,18 +2943,18 @@ export function sign_open(signedMsg: Uint8Array, publicKey: Uint8Array) {
checkArrayTypes(signedMsg, publicKey);
if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)
throw new Error("bad public key size");
- var tmp = new Uint8Array(signedMsg.length);
- var mlen = crypto_sign_open(tmp, signedMsg, signedMsg.length, publicKey);
+ const tmp = new Uint8Array(signedMsg.length);
+ const mlen = crypto_sign_open(tmp, signedMsg, signedMsg.length, publicKey);
if (mlen < 0) return null;
- var m = new Uint8Array(mlen);
- for (var i = 0; i < m.length; i++) m[i] = tmp[i];
+ const m = new Uint8Array(mlen);
+ for (let i = 0; i < m.length; i++) m[i] = tmp[i];
return m;
}
export function sign_detached(msg: Uint8Array, secretKey: Uint8Array) {
- var signedMsg = sign(msg, secretKey);
- var sig = new Uint8Array(crypto_sign_BYTES);
- for (var i = 0; i < sig.length; i++) sig[i] = signedMsg[i];
+ const signedMsg = sign(msg, secretKey);
+ const sig = new Uint8Array(crypto_sign_BYTES);
+ for (let i = 0; i < sig.length; i++) sig[i] = signedMsg[i];
return sig;
}
@@ -2967,17 +2967,17 @@ export function sign_detached_verify(
if (sig.length !== crypto_sign_BYTES) throw new Error("bad signature size");
if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)
throw new Error("bad public key size");
- var sm = new Uint8Array(crypto_sign_BYTES + msg.length);
- var m = new Uint8Array(crypto_sign_BYTES + msg.length);
- var i;
+ const sm = new Uint8Array(crypto_sign_BYTES + msg.length);
+ const m = new Uint8Array(crypto_sign_BYTES + msg.length);
+ let i;
for (i = 0; i < crypto_sign_BYTES; i++) sm[i] = sig[i];
for (i = 0; i < msg.length; i++) sm[i + crypto_sign_BYTES] = msg[i];
return crypto_sign_open(m, sm, sm.length, publicKey) >= 0;
}
export function sign_keyPair() {
- var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);
- var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);
+ const pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);
+ const sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);
crypto_sign_keypair(pk, sk, false);
return { publicKey: pk, secretKey: sk };
}
@@ -3009,17 +3009,17 @@ export function sign_keyPair_fromSecretKey(secretKey: Uint8Array) {
checkArrayTypes(secretKey);
if (secretKey.length !== crypto_sign_SECRETKEYBYTES)
throw new Error("bad secret key size");
- var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);
- for (var i = 0; i < pk.length; i++) pk[i] = secretKey[32 + i];
+ const pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);
+ for (let i = 0; i < pk.length; i++) pk[i] = secretKey[32 + i];
return { publicKey: pk, secretKey: new Uint8Array(secretKey) };
}
export function sign_keyPair_fromSeed(seed: Uint8Array) {
checkArrayTypes(seed);
if (seed.length !== crypto_sign_SEEDBYTES) throw new Error("bad seed size");
- var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);
- var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);
- for (var i = 0; i < 32; i++) sk[i] = seed[i];
+ const pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);
+ const sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);
+ for (let i = 0; i < 32; i++) sk[i] = seed[i];
crypto_sign_keypair(pk, sk, true);
return { publicKey: pk, secretKey: sk };
}
@@ -3031,7 +3031,7 @@ export const sign_signatureLength = crypto_sign_BYTES;
export function hash(msg: Uint8Array) {
checkArrayTypes(msg);
- var h = new Uint8Array(crypto_hash_BYTES);
+ const h = new Uint8Array(crypto_hash_BYTES);
crypto_hash(h, msg, msg.length);
return h;
}
@@ -3082,9 +3082,9 @@ export function sign_ed25519_pk_to_curve25519(
typeof self !== "undefined" ? self.crypto || (self as any).msCrypto : null;
if (cr && cr.getRandomValues) {
// Browsers.
- var QUOTA = 65536;
+ const QUOTA = 65536;
setPRNG(function (x: Uint8Array, n: number) {
- var i,
+ let i,
v = new Uint8Array(n);
for (i = 0; i < n; i += QUOTA) {
cr.getRandomValues(v.subarray(i, i + Math.min(n - i, QUOTA)));
@@ -3097,7 +3097,7 @@ export function sign_ed25519_pk_to_curve25519(
const cr = require("crypto");
if (cr && cr.randomBytes) {
setPRNG(function (x: Uint8Array, n: number) {
- var i,
+ let i,
v = cr.randomBytes(n);
for (i = 0; i < n; i++) x[i] = v[i];
cleanup(v);
diff --git a/src/crypto/primitives/sha256.ts b/src/crypto/primitives/sha256.ts
index c0f245bb3..ed88b5ffd 100644
--- a/src/crypto/primitives/sha256.ts
+++ b/src/crypto/primitives/sha256.ts
@@ -11,8 +11,8 @@
// Classes:
//
// new sha256.Hash()
-export const digestLength: number = 32;
-export const blockSize: number = 64;
+export const digestLength = 32;
+export const blockSize = 64;
// SHA-256 constants
const K = new Uint32Array([
@@ -188,10 +188,10 @@ export class HashSha256 {
private state: Int32Array = new Int32Array(8); // hash state
private temp: Int32Array = new Int32Array(64); // temporary state
private buffer: Uint8Array = new Uint8Array(128); // buffer for data to hash
- private bufferLength: number = 0; // number of bytes in buffer
- private bytesHashed: number = 0; // number of total bytes hashed
+ private bufferLength = 0; // number of bytes in buffer
+ private bytesHashed = 0; // number of total bytes hashed
- finished: boolean = false; // indicates whether the hash was finalized
+ finished = false; // indicates whether the hash was finalized
constructor() {
this.reset();
diff --git a/src/crypto/talerCrypto-test.ts b/src/crypto/talerCrypto-test.ts
index 11068f7d4..1efa766f3 100644
--- a/src/crypto/talerCrypto-test.ts
+++ b/src/crypto/talerCrypto-test.ts
@@ -40,7 +40,7 @@ function hexToBytes(hex: string) {
function bytesToHex(bytes: Uint8Array): string {
for (var hex = [], i = 0; i < bytes.length; i++) {
- var current = bytes[i] < 0 ? bytes[i] + 256 : bytes[i];
+ const current = bytes[i] < 0 ? bytes[i] + 256 : bytes[i];
hex.push((current >>> 4).toString(16));
hex.push((current & 0xf).toString(16));
}
diff --git a/src/crypto/workers/cryptoApi.ts b/src/crypto/workers/cryptoApi.ts
index 46dc7dfaf..24a43ff47 100644
--- a/src/crypto/workers/cryptoApi.ts
+++ b/src/crypto/workers/cryptoApi.ts
@@ -133,7 +133,7 @@ export class BrowserCryptoWorkerFactory implements CryptoWorkerFactory {
* for the execution of expensive operations.
*/
export class CryptoApi {
- private nextRpcId: number = 1;
+ private nextRpcId = 1;
private workers: WorkerState[];
private workQueues: WorkItem[][];
@@ -142,12 +142,12 @@ export class CryptoApi {
/**
* Number of busy workers.
*/
- private numBusy: number = 0;
+ private numBusy = 0;
/**
* Did we stop accepting new requests?
*/
- private stopped: boolean = false;
+ private stopped = false;
static enableTracing = false;
@@ -155,7 +155,7 @@ export class CryptoApi {
* Terminate all worker threads.
*/
terminateWorkers() {
- for (let worker of this.workers) {
+ for (const worker of this.workers) {
if (worker.w) {
CryptoApi.enableTracing && console.log("terminating worker");
worker.w.terminate();
diff --git a/src/crypto/workers/cryptoImplementation.ts b/src/crypto/workers/cryptoImplementation.ts
index eef8f5955..0a3c217ab 100644
--- a/src/crypto/workers/cryptoImplementation.ts
+++ b/src/crypto/workers/cryptoImplementation.ts
@@ -123,13 +123,13 @@ class SignaturePurposeBuilder {
build(): Uint8Array {
let payloadLen = 0;
- for (let c of this.chunks) {
+ for (const c of this.chunks) {
payloadLen += c.byteLength;
}
const buf = new ArrayBuffer(4 + 4 + payloadLen);
const u8buf = new Uint8Array(buf);
let p = 8;
- for (let c of this.chunks) {
+ for (const c of this.chunks) {
u8buf.set(c, p);
p += c.byteLength;
}
@@ -158,7 +158,7 @@ function checkSignKeyOkay(
}
export class CryptoImplementation {
- static enableTracing: boolean = false;
+ static enableTracing = false;
constructor() {}
diff --git a/src/headless/clk.ts b/src/headless/clk.ts
index 7c99384bb..09f758ad4 100644
--- a/src/headless/clk.ts
+++ b/src/headless/clk.ts
@@ -23,8 +23,8 @@ import readline from "readline";
class Converter<T> {}
-export let INT = new Converter<number>();
-export let STRING: Converter<string> = new Converter<string>();
+export const INT = new Converter<number>();
+export const STRING: Converter<string> = new Converter<string>();
export interface OptionArgs<T> {
help?: string;
@@ -90,7 +90,7 @@ function splitOpt(opt: string): { key: string; value?: string } {
}
function formatListing(key: string, value?: string): string {
- let res = " " + key;
+ const res = " " + key;
if (!value) {
return res;
}
@@ -139,7 +139,7 @@ export class CommandGroup<GN extends keyof any, TG> {
name: name as string,
};
this.options.push(def);
- for (let flag of flagspec) {
+ for (const flag of flagspec) {
if (flag.startsWith("--")) {
const flagname = flag.substring(2);
this.longOptions[flagname] = def;
@@ -168,7 +168,7 @@ export class CommandGroup<GN extends keyof any, TG> {
name: name as string,
};
this.options.push(def);
- for (let flag of flagspec) {
+ for (const flag of flagspec) {
if (flag.startsWith("--")) {
const flagname = flag.substring(2);
this.longOptions[flagname] = def;
@@ -225,7 +225,7 @@ export class CommandGroup<GN extends keyof any, TG> {
name: name as string,
};
this.options.push(def);
- for (let flag of flagspec) {
+ for (const flag of flagspec) {
if (flag.startsWith("--")) {
const flagname = flag.substring(2);
this.longOptions[flagname] = def;
@@ -271,7 +271,7 @@ export class CommandGroup<GN extends keyof any, TG> {
printHelp(progName: string, parents: CommandGroup<any, any>[]) {
let usageSpec = "";
- for (let p of parents) {
+ for (const p of parents) {
usageSpec += (p.name ?? progName) + " ";
if (p.arguments.length >= 1) {
usageSpec += "<ARGS...> ";
@@ -281,7 +281,7 @@ export class CommandGroup<GN extends keyof any, TG> {
if (this.subcommands.length != 0) {
usageSpec += "COMMAND ";
}
- for (let a of this.arguments) {
+ for (const a of this.arguments) {
const argName = a.args.metavar ?? a.name;
usageSpec += `<${argName}> `;
}
@@ -294,7 +294,7 @@ export class CommandGroup<GN extends keyof any, TG> {
if (this.options.length != 0) {
console.log();
console.log("Options:");
- for (let opt of this.options) {
+ for (const opt of this.options) {
let optSpec = opt.flagspec.join(", ");
if (!opt.isFlag) {
optSpec = optSpec + "=VALUE";
@@ -306,7 +306,7 @@ export class CommandGroup<GN extends keyof any, TG> {
if (this.subcommands.length != 0) {
console.log();
console.log("Commands:");
- for (let subcmd of this.subcommands) {
+ for (const subcmd of this.subcommands) {
console.log(formatListing(subcmd.name, subcmd.args.help));
}
}
@@ -444,7 +444,7 @@ export class CommandGroup<GN extends keyof any, TG> {
}
}
- for (let option of this.options) {
+ for (const option of this.options) {
if (option.isFlag == false && option.required == true) {
if (!foundOptions[option.name]) {
if (option.args.default !== undefined) {
@@ -459,7 +459,7 @@ export class CommandGroup<GN extends keyof any, TG> {
}
}
- for (let option of this.options) {
+ for (const option of this.options) {
const ph = option.args.onPresentHandler;
if (ph && foundOptions[option.name]) {
ph(myArgs[option.name]);
diff --git a/src/headless/helpers.ts b/src/headless/helpers.ts
index 053332b37..11e2c90de 100644
--- a/src/headless/helpers.ts
+++ b/src/headless/helpers.ts
@@ -138,9 +138,9 @@ export async function getDefaultNodeWallet(
export async function withdrawTestBalance(
myWallet: Wallet,
- amount: string = "TESTKUDOS:10",
- bankBaseUrl: string = "https://bank.test.taler.net/",
- exchangeBaseUrl: string = "https://exchange.test.taler.net/",
+ amount = "TESTKUDOS:10",
+ bankBaseUrl = "https://bank.test.taler.net/",
+ exchangeBaseUrl = "https://exchange.test.taler.net/",
) {
const reserveResponse = await myWallet.createReserve({
amount: amounts.parseOrThrow(amount),
diff --git a/src/headless/integrationtest.ts b/src/headless/integrationtest.ts
index 6e45b76e2..9934f2048 100644
--- a/src/headless/integrationtest.ts
+++ b/src/headless/integrationtest.ts
@@ -43,7 +43,7 @@ async function makePayment(
amount: string,
summary: string,
): Promise<{ orderId: string }> {
- let orderResp = await merchant.createOrder(
+ const orderResp = await merchant.createOrder(
amount,
summary,
"taler://fulfillment-success/thx",
@@ -60,7 +60,7 @@ async function makePayment(
throw Error("no taler://pay/ URI in payment response");
}
- let preparePayResult = await wallet.preparePayForUri(talerPayUri);
+ const preparePayResult = await wallet.preparePayForUri(talerPayUri);
console.log("prepare pay result", preparePayResult);
@@ -68,7 +68,7 @@ async function makePayment(
throw Error("payment not possible");
}
- let confirmPayResult = await wallet.confirmPay(
+ const confirmPayResult = await wallet.confirmPay(
preparePayResult.proposalId,
undefined,
);
@@ -159,7 +159,7 @@ export async function runIntegrationTest(args: IntegrationTestArgs) {
// Wait until the withdraw is done
await myWallet.runUntilDone();
- let { orderId: refundOrderId } = await makePayment(
+ const { orderId: refundOrderId } = await makePayment(
myWallet,
myMerchant,
Amounts.stringify(spendAmountTwo),
@@ -299,7 +299,7 @@ export async function runIntegrationTestBasic(cfg: Configuration) {
// Wait until the withdraw is done
await myWallet.runUntilDone();
- let { orderId: refundOrderId } = await makePayment(
+ const { orderId: refundOrderId } = await makePayment(
myWallet,
myMerchant,
Amounts.stringify(spendAmountTwo),
diff --git a/src/headless/taler-wallet-cli.ts b/src/headless/taler-wallet-cli.ts
index c7909948f..a7dcce9a3 100644
--- a/src/headless/taler-wallet-cli.ts
+++ b/src/headless/taler-wallet-cli.ts
@@ -593,7 +593,7 @@ testCli
})
.action(async (args) => {
applyVerbose(args.wallet.verbose);
- let cmdObj = args.integrationtestCmd;
+ const cmdObj = args.integrationtestCmd;
try {
await runIntegrationTest({
diff --git a/src/i18n/strings-prelude b/src/i18n/strings-prelude
index 147b6c939..aa6602bd4 100644
--- a/src/i18n/strings-prelude
+++ b/src/i18n/strings-prelude
@@ -14,4 +14,4 @@
TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
-export let strings: {[s: string]: any} = {};
+export const strings: {[s: string]: any} = {};
diff --git a/src/i18n/strings.ts b/src/i18n/strings.ts
index 289dcbedc..06fb7a896 100644
--- a/src/i18n/strings.ts
+++ b/src/i18n/strings.ts
@@ -14,7 +14,7 @@
TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
-export let strings: { [s: string]: any } = {};
+export const strings: { [s: string]: any } = {};
strings["de"] = {
domain: "messages",
locale_data: {
diff --git a/src/operations/exchanges.ts b/src/operations/exchanges.ts
index b9806bb62..53b250a8e 100644
--- a/src/operations/exchanges.ts
+++ b/src/operations/exchanges.ts
@@ -198,7 +198,7 @@ async function updateExchangeWithKeys(
),
);
- let recoupGroupId: string | undefined = undefined;
+ const recoupGroupId: string | undefined = undefined;
await ws.db.runWithWriteTransaction(
[Stores.exchanges, Stores.denominations, Stores.recoupGroups, Stores.coins],
@@ -459,7 +459,7 @@ async function updateExchangeWithWireInfo(
export async function updateExchangeFromUrl(
ws: InternalWalletState,
baseUrl: string,
- forceNow: boolean = false,
+ forceNow = false,
): Promise<ExchangeRecord> {
const onOpErr = (e: OperationError) => setExchangeError(ws, baseUrl, e);
return await guardOperationException(
@@ -476,7 +476,7 @@ export async function updateExchangeFromUrl(
async function updateExchangeFromUrlImpl(
ws: InternalWalletState,
baseUrl: string,
- forceNow: boolean = false,
+ forceNow = false,
): Promise<ExchangeRecord> {
const now = getTimestampNow();
baseUrl = canonicalizeBaseUrl(baseUrl);
@@ -583,7 +583,7 @@ export async function getExchangePaytoUri(
if (!exchangeWireInfo) {
throw Error(`Exchange wire info for '${exchangeBaseUrl}' not found.`);
}
- for (let account of exchangeWireInfo.accounts) {
+ for (const account of exchangeWireInfo.accounts) {
const res = parsePaytoUri(account.payto_uri);
if (!res) {
continue;
diff --git a/src/operations/history.ts b/src/operations/history.ts
index edb4d9f27..b043e4a90 100644
--- a/src/operations/history.ts
+++ b/src/operations/history.ts
@@ -333,7 +333,7 @@ export async function getHistory(
amountsRaw.push(c.currentAmount);
}
}
- let amountRefreshedRaw = Amounts.sum(amountsRaw).amount;
+ const amountRefreshedRaw = Amounts.sum(amountsRaw).amount;
let amountRefreshedEffective: AmountJson;
if (amountsEffective.length == 0) {
amountRefreshedEffective = Amounts.getZero(
diff --git a/src/operations/pay.ts b/src/operations/pay.ts
index 9b9d2fa9f..3a629e9c2 100644
--- a/src/operations/pay.ts
+++ b/src/operations/pay.ts
@@ -198,8 +198,8 @@ export function selectPayCoins(
let totalFees = Amounts.getZero(currency);
let amountPayRemaining = paymentAmount;
let amountDepositFeeLimitRemaining = depositFeeLimit;
- let customerWireFees = Amounts.getZero(currency);
- let customerDepositFees = Amounts.getZero(currency);
+ const customerWireFees = Amounts.getZero(currency);
+ const customerDepositFees = Amounts.getZero(currency);
for (const aci of acis) {
// Don't use this coin if depositing it is more expensive than
// the amount it would give the merchant.
@@ -283,7 +283,7 @@ async function getCoinsForPayment(
const exchanges = await ws.db.iter(Stores.exchanges).toArray();
for (const exchange of exchanges) {
- let isOkay: boolean = false;
+ let isOkay = false;
const exchangeDetails = exchange.details;
if (!exchangeDetails) {
continue;
@@ -618,7 +618,7 @@ async function incrementPurchasePayRetry(
export async function processDownloadProposal(
ws: InternalWalletState,
proposalId: string,
- forceNow: boolean = false,
+ forceNow = false,
): Promise<void> {
const onOpErr = (err: OperationError) =>
incrementProposalRetry(ws, proposalId, err);
@@ -1106,7 +1106,7 @@ export async function confirmPay(
export async function processPurchasePay(
ws: InternalWalletState,
proposalId: string,
- forceNow: boolean = false,
+ forceNow = false,
): Promise<void> {
const onOpErr = (e: OperationError) =>
incrementPurchasePayRetry(ws, proposalId, e);
diff --git a/src/operations/pending.ts b/src/operations/pending.ts
index 106e5053c..cee929aa2 100644
--- a/src/operations/pending.ts
+++ b/src/operations/pending.ts
@@ -54,7 +54,7 @@ async function gatherExchangePending(
tx: TransactionHandle,
now: Timestamp,
resp: PendingOperationsResponse,
- onlyDue: boolean = false,
+ onlyDue = false,
): Promise<void> {
if (onlyDue) {
// FIXME: exchanges should also be updated regularly
@@ -146,7 +146,7 @@ async function gatherReservePending(
tx: TransactionHandle,
now: Timestamp,
resp: PendingOperationsResponse,
- onlyDue: boolean = false,
+ onlyDue = false,
): Promise<void> {
// FIXME: this should be optimized by using an index for "onlyDue==true".
await tx.iter(Stores.reserves).forEach((reserve) => {
@@ -215,7 +215,7 @@ async function gatherRefreshPending(
tx: TransactionHandle,
now: Timestamp,
resp: PendingOperationsResponse,
- onlyDue: boolean = false,
+ onlyDue = false,
): Promise<void> {
await tx.iter(Stores.refreshGroups).forEach((r) => {
if (r.timestampFinished) {
@@ -244,7 +244,7 @@ async function gatherWithdrawalPending(
tx: TransactionHandle,
now: Timestamp,
resp: PendingOperationsResponse,
- onlyDue: boolean = false,
+ onlyDue = false,
): Promise<void> {
await tx.iter(Stores.withdrawalGroups).forEach((wsr) => {
if (wsr.timestampFinish) {
@@ -279,7 +279,7 @@ async function gatherProposalPending(
tx: TransactionHandle,
now: Timestamp,
resp: PendingOperationsResponse,
- onlyDue: boolean = false,
+ onlyDue = false,
): Promise<void> {
await tx.iter(Stores.proposals).forEach((proposal) => {
if (proposal.proposalStatus == ProposalStatus.PROPOSED) {
@@ -320,7 +320,7 @@ async function gatherTipPending(
tx: TransactionHandle,
now: Timestamp,
resp: PendingOperationsResponse,
- onlyDue: boolean = false,
+ onlyDue = false,
): Promise<void> {
await tx.iter(Stores.tips).forEach((tip) => {
if (tip.pickedUp) {
@@ -350,7 +350,7 @@ async function gatherPurchasePending(
tx: TransactionHandle,
now: Timestamp,
resp: PendingOperationsResponse,
- onlyDue: boolean = false,
+ onlyDue = false,
): Promise<void> {
await tx.iter(Stores.purchases).forEach((pr) => {
if (pr.paymentSubmitPending) {
@@ -413,7 +413,7 @@ async function gatherRecoupPending(
tx: TransactionHandle,
now: Timestamp,
resp: PendingOperationsResponse,
- onlyDue: boolean = false,
+ onlyDue = false,
): Promise<void> {
await tx.iter(Stores.recoupGroups).forEach((rg) => {
if (rg.timestampFinished) {
diff --git a/src/operations/recoup.ts b/src/operations/recoup.ts
index e13ae3c1f..97bc39564 100644
--- a/src/operations/recoup.ts
+++ b/src/operations/recoup.ts
@@ -291,7 +291,7 @@ async function resetRecoupGroupRetry(
export async function processRecoupGroup(
ws: InternalWalletState,
recoupGroupId: string,
- forceNow: boolean = false,
+ forceNow = false,
): Promise<void> {
await ws.memoProcessRecoup.memo(recoupGroupId, async () => {
const onOpErr = (e: OperationError) =>
@@ -306,7 +306,7 @@ export async function processRecoupGroup(
async function processRecoupGroupImpl(
ws: InternalWalletState,
recoupGroupId: string,
- forceNow: boolean = false,
+ forceNow = false,
): Promise<void> {
if (forceNow) {
await resetRecoupGroupRetry(ws, recoupGroupId);
@@ -386,7 +386,7 @@ async function processRecoup(
const coinPub = recoupGroup.coinPubs[coinIdx];
- let coin = await ws.db.get(Stores.coins, coinPub);
+ const coin = await ws.db.get(Stores.coins, coinPub);
if (!coin) {
throw Error(`Coin ${coinPub} not found, can't request payback`);
}
diff --git a/src/operations/refresh.ts b/src/operations/refresh.ts
index be4f5c5af..23d192e0a 100644
--- a/src/operations/refresh.ts
+++ b/src/operations/refresh.ts
@@ -446,7 +446,7 @@ async function refreshReveal(
rg.timestampFinished = getTimestampNow();
rg.retryInfo = initRetryInfo(false);
}
- for (let coin of coins) {
+ for (const coin of coins) {
await tx.put(Stores.coins, coin);
}
await tx.put(Stores.refreshGroups, rg);
@@ -482,7 +482,7 @@ async function incrementRefreshRetry(
export async function processRefreshGroup(
ws: InternalWalletState,
refreshGroupId: string,
- forceNow: boolean = false,
+ forceNow = false,
): Promise<void> {
await ws.memoProcessRefresh.memo(refreshGroupId, async () => {
const onOpErr = (e: OperationError) =>
diff --git a/src/operations/refund.ts b/src/operations/refund.ts
index f0fec4065..74d4b848e 100644
--- a/src/operations/refund.ts
+++ b/src/operations/refund.ts
@@ -300,7 +300,7 @@ export async function applyRefund(
export async function processPurchaseQueryRefund(
ws: InternalWalletState,
proposalId: string,
- forceNow: boolean = false,
+ forceNow = false,
): Promise<void> {
const onOpErr = (e: OperationError) =>
incrementPurchaseQueryRefundRetry(ws, proposalId, e);
@@ -366,7 +366,7 @@ async function processPurchaseQueryRefundImpl(
export async function processPurchaseApplyRefund(
ws: InternalWalletState,
proposalId: string,
- forceNow: boolean = false,
+ forceNow = false,
): Promise<void> {
const onOpErr = (e: OperationError) =>
incrementPurchaseApplyRefundRetry(ws, proposalId, e);
@@ -460,7 +460,7 @@ async function processPurchaseApplyRefundImpl(
}
// Groups that failed/succeeded
- let groups: { [refundGroupId: string]: boolean } = {};
+ const groups: { [refundGroupId: string]: boolean } = {};
// Avoid duplicates
const refreshCoinsMap: { [coinPub: string]: CoinPublicKey } = {};
diff --git a/src/operations/reserves.ts b/src/operations/reserves.ts
index 5c299d112..2ee1b358f 100644
--- a/src/operations/reserves.ts
+++ b/src/operations/reserves.ts
@@ -248,7 +248,7 @@ export async function forceQueryReserve(
export async function processReserve(
ws: InternalWalletState,
reservePub: string,
- forceNow: boolean = false,
+ forceNow = false,
): Promise<void> {
return ws.memoProcessReserve.memo(reservePub, async () => {
const onOpError = (err: OperationError) =>
@@ -264,7 +264,7 @@ async function registerReserveWithBank(
ws: InternalWalletState,
reservePub: string,
): Promise<void> {
- let reserve = await ws.db.get(Stores.reserves, reservePub);
+ const reserve = await ws.db.get(Stores.reserves, reservePub);
switch (reserve?.reserveStatus) {
case ReserveRecordStatus.WAIT_CONFIRM_BANK:
case ReserveRecordStatus.REGISTERING_BANK:
@@ -317,7 +317,7 @@ async function processReserveBankStatusImpl(
ws: InternalWalletState,
reservePub: string,
): Promise<void> {
- let reserve = await ws.db.get(Stores.reserves, reservePub);
+ const reserve = await ws.db.get(Stores.reserves, reservePub);
switch (reserve?.reserveStatus) {
case ReserveRecordStatus.WAIT_CONFIRM_BANK:
case ReserveRecordStatus.REGISTERING_BANK:
@@ -534,7 +534,7 @@ async function updateReserve(
async function processReserveImpl(
ws: InternalWalletState,
reservePub: string,
- forceNow: boolean = false,
+ forceNow = false,
): Promise<void> {
const reserve = await ws.db.get(Stores.reserves, reservePub);
if (!reserve) {
diff --git a/src/operations/tip.ts b/src/operations/tip.ts
index 7bfbddb6a..1a88dbca3 100644
--- a/src/operations/tip.ts
+++ b/src/operations/tip.ts
@@ -66,7 +66,7 @@ export async function getTipStatus(
console.log("status", tipPickupStatus);
- let amount = Amounts.parseOrThrow(tipPickupStatus.amount);
+ const amount = Amounts.parseOrThrow(tipPickupStatus.amount);
let tipRecord = await ws.db.get(Stores.tips, [
res.merchantTipId,
@@ -147,7 +147,7 @@ async function incrementTipRetry(
export async function processTip(
ws: InternalWalletState,
tipId: string,
- forceNow: boolean = false,
+ forceNow = false,
): Promise<void> {
const onOpErr = (e: OperationError) => incrementTipRetry(ws, tipId, e);
await guardOperationException(
diff --git a/src/operations/withdraw.ts b/src/operations/withdraw.ts
index fcd9d70c9..70ecf9aed 100644
--- a/src/operations/withdraw.ts
+++ b/src/operations/withdraw.ts
@@ -394,7 +394,7 @@ async function incrementWithdrawalRetry(
export async function processWithdrawGroup(
ws: InternalWalletState,
withdrawalGroupId: string,
- forceNow: boolean = false,
+ forceNow = false,
): Promise<void> {
const onOpErr = (e: OperationError) =>
incrementWithdrawalRetry(ws, withdrawalGroupId, e);
@@ -470,7 +470,7 @@ export async function getExchangeWithdrawalInfo(
.reduce((a, b) => Amounts.add(a, b).amount);
const exchangeWireAccounts: string[] = [];
- for (let account of exchangeWireInfo.accounts) {
+ for (const account of exchangeWireInfo.accounts) {
exchangeWireAccounts.push(account.payto_uri);
}
diff --git a/src/types/dbTypes.ts b/src/types/dbTypes.ts
index f94fb6c6f..434993cb5 100644
--- a/src/types/dbTypes.ts
+++ b/src/types/dbTypes.ts
@@ -117,7 +117,7 @@ export function updateRetryInfoTimeout(
}
export function initRetryInfo(
- active: boolean = true,
+ active = true,
p: RetryPolicy = defaultRetryPolicy,
): RetryInfo {
if (!active) {
diff --git a/src/util/amounts.ts b/src/util/amounts.ts
index f9946393f..f0a4f1d72 100644
--- a/src/util/amounts.ts
+++ b/src/util/amounts.ts
@@ -260,7 +260,7 @@ export function parse(s: string): AmountJson | undefined {
if (tail.length > fractionalLength + 1) {
return undefined;
}
- let value = Number.parseInt(res[2]);
+ const value = Number.parseInt(res[2]);
if (value > maxAmountValue) {
return undefined;
}
diff --git a/src/util/query.ts b/src/util/query.ts
index ce704b4fc..44f668658 100644
--- a/src/util/query.ts
+++ b/src/util/query.ts
@@ -123,8 +123,8 @@ interface CursorValueResult<T> {
class ResultStream<T> {
private currentPromise: Promise<void>;
- private gotCursorEnd: boolean = false;
- private awaitingResult: boolean = false;
+ private gotCursorEnd = false;
+ private awaitingResult = false;
constructor(private req: IDBRequest) {
this.awaitingResult = true;
@@ -304,7 +304,7 @@ function runWithTransaction<T>(
const storeName = stores.map((x) => x.name);
const tx = db.transaction(storeName, mode);
let funResult: any = undefined;
- let gotFunResult: boolean = false;
+ let gotFunResult = false;
tx.oncomplete = () => {
// This is a fatal error: The transaction completed *before*
// the transaction function returned. Likely, the transaction
diff --git a/src/util/time.ts b/src/util/time.ts
index 138ecb876..05188b6d2 100644
--- a/src/util/time.ts
+++ b/src/util/time.ts
@@ -34,7 +34,7 @@ export interface Duration {
readonly d_ms: number | "forever";
}
-let timeshift: number = 0;
+let timeshift = 0;
export function setDangerousTimetravel(dt: number) {
timeshift = dt;
diff --git a/src/util/timer.ts b/src/util/timer.ts
index 8706c939e..a1712b03f 100644
--- a/src/util/timer.ts
+++ b/src/util/timer.ts
@@ -87,7 +87,7 @@ const nullTimerHandle = {
* Group of timers that can be destroyed at once.
*/
export class TimerGroup {
- private stopped: boolean = false;
+ private stopped = false;
private timerMap: { [index: number]: TimerHandle } = {};
diff --git a/src/wallet.ts b/src/wallet.ts
index 3171d0cea..063a259d6 100644
--- a/src/wallet.ts
+++ b/src/wallet.ts
@@ -140,7 +140,7 @@ export class Wallet {
private ws: InternalWalletState;
private timerGroup: TimerGroup = new TimerGroup();
private latch = new AsyncCondition();
- private stopped: boolean = false;
+ private stopped = false;
private memoRunRetryLoop = new AsyncOpMemoSingle<void>();
get db(): Database {
@@ -175,7 +175,7 @@ export class Wallet {
*/
async processOnePendingOperation(
pending: PendingOperationInfo,
- forceNow: boolean = false,
+ forceNow = false,
): Promise<void> {
console.log("running pending", pending);
switch (pending.type) {
@@ -230,7 +230,7 @@ export class Wallet {
/**
* Process pending operations.
*/
- public async runPending(forceNow: boolean = false): Promise<void> {
+ public async runPending(forceNow = false): Promise<void> {
const onlyDue = !forceNow;
const pendingOpsResponse = await this.getPendingOperations({ onlyDue });
for (const p of pendingOpsResponse.pendingOperations) {
@@ -318,7 +318,7 @@ export class Wallet {
private async runRetryLoopImpl(): Promise<void> {
while (!this.stopped) {
console.log("running wallet retry loop iteration");
- let pending = await this.getPendingOperations({ onlyDue: true });
+ const pending = await this.getPendingOperations({ onlyDue: true });
console.log("pending ops", JSON.stringify(pending, undefined, 2));
if (pending.pendingOperations.length === 0) {
const allPending = await this.getPendingOperations({ onlyDue: false });
@@ -382,7 +382,7 @@ export class Wallet {
}
});
if (!applied) {
- for (let c of builtinCurrencies) {
+ for (const c of builtinCurrencies) {
await tx.put(Stores.currencies, c);
}
}
@@ -489,7 +489,7 @@ export class Wallet {
*/
async updateExchangeFromUrl(
baseUrl: string,
- force: boolean = false,
+ force = false,
): Promise<ExchangeRecord> {
try {
return updateExchangeFromUrl(this.ws, baseUrl, force);
diff --git a/src/webex/chromeBadge.ts b/src/webex/chromeBadge.ts
index cdd99f8c1..330388ca0 100644
--- a/src/webex/chromeBadge.ts
+++ b/src/webex/chromeBadge.ts
@@ -38,25 +38,25 @@ export class ChromeBadge {
* might still be running even if we're not busy anymore,
* just to transition to the "normal" state in a animated way.
*/
- private animationRunning: boolean = false;
+ private animationRunning = false;
/**
* Is the wallet still busy? Note that we do not stop the
* animation immediately when the wallet goes idle, but
* instead slowly close the gap.
*/
- private isBusy: boolean = false;
+ private isBusy = false;
/**
* Current rotation angle, ranges from 0 to rotationAngleMax.
*/
- private rotationAngle: number = 0;
+ private rotationAngle = 0;
/**
* While animating, how wide is the current gap in the circle?
* Ranges from 0 to openMax.
*/
- private gapWidth: number = 0;
+ private gapWidth = 0;
/**
* Should we show the notification dot?
diff --git a/src/webex/i18n.tsx b/src/webex/i18n.tsx
index a156cf834..ed6fe868f 100644
--- a/src/webex/i18n.tsx
+++ b/src/webex/i18n.tsx
@@ -30,7 +30,7 @@ import * as React from "react";
const jed = setupJed();
-let enableTracing = false;
+const enableTracing = false;
/**
* Set up jed library for internationalization,
diff --git a/src/webex/notify.ts b/src/webex/notify.ts
index d76d121a0..887658ef9 100644
--- a/src/webex/notify.ts
+++ b/src/webex/notify.ts
@@ -26,9 +26,9 @@
*/
import * as wxApi from "./wxApi";
-declare var cloneInto: any;
+declare let cloneInto: any;
-let logVerbose: boolean = false;
+let logVerbose = false;
try {
logVerbose = !!localStorage.getItem("taler-log-verbose");
} catch (e) {
diff --git a/src/webex/pages/benchmark.tsx b/src/webex/pages/benchmark.tsx
index 1efe7898d..bf4c4b04d 100644
--- a/src/webex/pages/benchmark.tsx
+++ b/src/webex/pages/benchmark.tsx
@@ -77,7 +77,7 @@ class BenchmarkRunner extends React.Component<any, BenchmarkRunnerState> {
async run() {
this.setState({ result: undefined, running: true });
- let result = await wxApi.benchmarkCrypto(this.state.repetitions);
+ const result = await wxApi.benchmarkCrypto(this.state.repetitions);
this.setState({ result, running: false });
}
diff --git a/src/webex/pages/popup.tsx b/src/webex/pages/popup.tsx
index f4a2bf568..6cd7242ff 100644
--- a/src/webex/pages/popup.tsx
+++ b/src/webex/pages/popup.tsx
@@ -427,8 +427,8 @@ function amountDiff(
total: string | Amounts.AmountJson,
partial: string | Amounts.AmountJson,
): Amounts.AmountJson | string {
- let a = typeof total === "string" ? Amounts.parse(total) : total;
- let b = typeof partial === "string" ? Amounts.parse(partial) : partial;
+ const a = typeof total === "string" ? Amounts.parse(total) : total;
+ const b = typeof partial === "string" ? Amounts.parse(partial) : partial;
if (a && b) {
return Amounts.sub(a, b).amount;
} else {
@@ -437,7 +437,7 @@ function amountDiff(
}
function parseSummary(summary: string) {
- let parsed = summary.split(/: (.+)/);
+ const parsed = summary.split(/: (.+)/);
return {
merchant: parsed[0],
item: parsed[1],
diff --git a/src/webex/renderHtml.tsx b/src/webex/renderHtml.tsx
index 082dd84dd..b6ff1248c 100644
--- a/src/webex/renderHtml.tsx
+++ b/src/webex/renderHtml.tsx
@@ -61,7 +61,7 @@ export const AmountView = ({ amount }: { amount: AmountJson | string }) =>
* Abbreviate a string to a given length, and show the full
* string on hover as a tooltip.
*/
-export function abbrev(s: string, n: number = 5) {
+export function abbrev(s: string, n = 5) {
let sAbbrev = s;
if (s.length > n) {
sAbbrev = s.slice(0, n) + "..";
diff --git a/src/webex/wxBackend.ts b/src/webex/wxBackend.ts
index 4c9a76556..ef4715dce 100644
--- a/src/webex/wxBackend.ts
+++ b/src/webex/wxBackend.ts
@@ -384,7 +384,7 @@ let currentDatabase: IDBDatabase | undefined;
*/
let outdatedDbVersion: number | undefined;
-let walletInit: OpenedPromise<void> = openPromise<void>();
+const walletInit: OpenedPromise<void> = openPromise<void>();
async function reinitWallet() {
if (currentWallet) {
@@ -571,7 +571,7 @@ export async function wxMain() {
}
if (details.statusCode === 402 || details.statusCode === 202) {
console.log(`got 402/202 from ${details.url}`);
- for (let header of details.responseHeaders || []) {
+ for (const header of details.responseHeaders || []) {
if (header.name.toLowerCase() === "taler") {
const talerUri = header.value || "";
const uriType = classifyTalerUri(talerUri);