diff --git a/packages/desktop/lib/electron/managers/transak.manager.ts b/packages/desktop/lib/electron/managers/transak.manager.ts index 121500f845..7ea3f87052 100644 --- a/packages/desktop/lib/electron/managers/transak.manager.ts +++ b/packages/desktop/lib/electron/managers/transak.manager.ts @@ -5,6 +5,9 @@ import { ITransakManager, ITransakWindowData } from '@core/app' import path from 'path' import { TRANSAK_WIDGET_URL } from '@auxiliary/transak/constants' import { buildQueryParametersFromObject } from '@core/utils/url' +import { Currency } from '@core/utils/enums' +import { validateBech32Address } from '@core/utils/crypto' +import { IOTA_BECH32_HRP } from '@core/network' export default class TransakManager implements ITransakManager { private rect: Electron.Rectangle @@ -165,6 +168,16 @@ export default class TransakManager implements ITransakManager { const { address, currency, service } = data const apiKey = process.env.TRANSAK_API_KEY + validateBech32Address(IOTA_BECH32_HRP, address) + + if (Object.values(Currency).includes(currency as Currency)) { + throw new Error('Invalid Transak currency') + } + + if (service !== 'BUY' && service !== 'SELL') { + throw new Error('Invalid Transak service') + } + const queryParams = buildQueryParametersFromObject({ apiKey, defaultFiatCurrency: currency,