From d42a74565ebc596b67a8e105b8eb271f85b3f4d0 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Mon, 21 Jun 2021 10:08:28 -0300 Subject: [PATCH] fix #6042 --- .../crypto/workers/cryptoImplementation.ts | 26 ++++++++++++++++--- .../taler-wallet-webextension/manifest.json | 2 +- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/packages/taler-wallet-core/src/crypto/workers/cryptoImplementation.ts b/packages/taler-wallet-core/src/crypto/workers/cryptoImplementation.ts index 9cffef035..f799fd6e7 100644 --- a/packages/taler-wallet-core/src/crypto/workers/cryptoImplementation.ts +++ b/packages/taler-wallet-core/src/crypto/workers/cryptoImplementation.ts @@ -76,6 +76,7 @@ import { DeriveTipRequest, SignTrackTransactionRequest, } from "../cryptoTypes.js"; +import bigint from "big-integer"; const logger = new Logger("cryptoImplementation.ts"); @@ -102,7 +103,15 @@ function amountToBuffer(amount: AmountJson): Uint8Array { const dvbuf = new DataView(buffer); const u8buf = new Uint8Array(buffer); const curr = stringToBytes(amount.currency); - dvbuf.setBigUint64(0, BigInt(amount.value)); + if (typeof dvbuf.setBigUint64 !== "undefined") { + dvbuf.setBigUint64(0, BigInt(amount.value)); + } else { + const arr = bigint(amount.value).toArray(2 ** 8).value + let offset = 8 - arr.length + for (let i = 0; i < arr.length; i++) { + dvbuf.setUint8(offset++, arr[i]); + } + } dvbuf.setUint32(8, amount.fraction); u8buf.set(curr, 8 + 4); @@ -113,15 +122,24 @@ function timestampRoundedToBuffer(ts: Timestamp): Uint8Array { const b = new ArrayBuffer(8); const v = new DataView(b); const tsRounded = timestampTruncateToSecond(ts); - const s = BigInt(tsRounded.t_ms) * BigInt(1000); - v.setBigUint64(0, s); + if (typeof v.setBigUint64 !== "undefined") { + const s = BigInt(tsRounded.t_ms) * BigInt(1000); + v.setBigUint64(0, s); + } else { + const s = (tsRounded.t_ms === "never" ? bigint.zero : bigint(tsRounded.t_ms).times(1000)); + const arr = s.toArray(2 ** 8).value + let offset = 8 - arr.length + for (let i = 0; i < arr.length; i++) { + v.setUint8(offset++, arr[i]); + } + } return new Uint8Array(b); } class SignaturePurposeBuilder { private chunks: Uint8Array[] = []; - constructor(private purposeNum: number) {} + constructor(private purposeNum: number) { } put(bytes: Uint8Array): SignaturePurposeBuilder { this.chunks.push(Uint8Array.from(bytes)); diff --git a/packages/taler-wallet-webextension/manifest.json b/packages/taler-wallet-webextension/manifest.json index 3ab5625a8..e864fe08a 100644 --- a/packages/taler-wallet-webextension/manifest.json +++ b/packages/taler-wallet-webextension/manifest.json @@ -13,7 +13,7 @@ "applications": { "gecko": { "id": "wallet@taler.net", - "strict_min_version": "68.0" + "strict_min_version": "57.0" } },