From 1c7423dbad6c7a7d8efffadb3c854d961da17336 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Thu, 17 Jun 2021 12:40:42 -0300 Subject: fix support with webpack{4,5} in browser environment added missing .js extension to the imports split index use browser field in package json --- packages/taler-wallet-core/src/index.node.ts | 43 ++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 packages/taler-wallet-core/src/index.node.ts (limited to 'packages/taler-wallet-core/src/index.node.ts') diff --git a/packages/taler-wallet-core/src/index.node.ts b/packages/taler-wallet-core/src/index.node.ts new file mode 100644 index 000000000..a3be6b5f6 --- /dev/null +++ b/packages/taler-wallet-core/src/index.node.ts @@ -0,0 +1,43 @@ +/* + This file is part of TALER + (C) 2019 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 + */ + +export * from "./index.js"; + +// Utils for using the wallet under node +export { NodeHttpLib } from "./headless/NodeHttpLib.js"; +export { + getDefaultNodeWallet, + DefaultNodeWalletArgs, +} from "./headless/helpers.js"; + +import { setPRNG } from './crypto/primitives/nacl-fast.js'; +import cr from 'crypto'; + +function cleanup(arr: Uint8Array): void { + for (let i = 0; i < arr.length; i++) arr[i] = 0; +} + +// Initialize PRNG if environment provides CSPRNG. +// If not, methods calling randombytes will throw. +if (cr && cr.randomBytes) { + setPRNG(function (x: Uint8Array, n: number) { + const v = cr.randomBytes(n); + for (let i = 0; i < n; i++) x[i] = v[i]; + cleanup(v); + }); +} + +export * from "./crypto/workers/nodeThreadWorker.js"; -- cgit v1.2.3