Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions .github/workflows/build.yml

This file was deleted.

5 changes: 5 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,10 @@ jobs:
- name: Install dependencies
run: yarn install

- name: Check USDT pause and retired build inputs
run: |
node --test tests/services/usdtPause.test.cjs tests/recovery/usdtBackup.test.cjs \
scripts/verify-channel-config.test.cjs ios/scripts/verify-retired-env.test.cjs

- name: Run tests
run: npm run test
9 changes: 8 additions & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ apply plugin: "com.android.application"
apply plugin: "com.facebook.react"
apply plugin: 'com.google.gms.google-services'
apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"
// react-native-config embeds every selected env key, even when JavaScript does not use it.
// Check the resolved env map so direct Gradle builds cannot package retired credentials.
def retiredCredentialKeys = ['GASFREE_API_KEY', 'GASFREE_API_SECRET',
'LETS_EXCHANGE_API_KEY'].collectMany { [it, "RN_${it}"] }
if (retiredCredentialKeys.any { project.ext.env.containsKey(it) }) {
throw new GradleException('Retired API credentials must not be included in an Android build')
}
apply plugin: 'kotlin-android'

/**
Expand Down Expand Up @@ -205,4 +212,4 @@ dependencies {
implementation 'com.itextpdf:itextg:5.5.10'


}
}
15 changes: 13 additions & 2 deletions appcenter-pre-build.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
#!/usr/bin/env bash
# Creates an .env from ENV variables for use with react-native-config
set -eu

if [ -n "${RN_GASFREE_API_KEY+x}" ] || [ -n "${RN_GASFREE_API_SECRET+x}" ] || [ -n "${RN_LETS_EXCHANGE_API_KEY+x}" ]; then
printf "Retired API credentials must not be included in a mobile build\n" >&2
exit 1
fi

ENV_WHITELIST=${ENV_WHITELIST:-"^RN_"}
printf "Creating an .env file with the following whitelist:\n"
printf "%s\n" $ENV_WHITELIST
set | egrep -e $ENV_WHITELIST | sed 's/^RN_//g' > .env
printf "\n.env created with contents:\n\n"
cat .env
if grep -Eq '^(RN_)?(GASFREE_API_(KEY|SECRET)|LETS_EXCHANGE_API_KEY)=' .env; then
rm .env
printf "Retired API credentials must not be included in a mobile build\n" >&2
exit 1
fi
printf ".env created\n"
11 changes: 11 additions & 0 deletions ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,17 @@ post_install do |installer|
# :ccache_enabled => true
)

# react-native-config logs and embeds every key from its selected .env file.
# Run the guard in that pod's own phase before its code generator starts.
config_target = installer.pods_project.targets.find { |target| target.name == 'react-native-config' }
config_codegen = config_target&.shell_script_build_phases&.find { |phase| phase.name == '[CP-User] Config codegen' }
raise 'react-native-config codegen phase not found; release credential guard cannot be installed' unless config_codegen

config_codegen.shell_script = <<~SCRIPT + config_codegen.shell_script
set -e
ruby "${PODS_ROOT}/../scripts/verify-retired-env.rb" "${PODS_TARGET_SRCROOT}/ios/ReactNativeConfig" "${SRCROOT}/../.."
SCRIPT

# fixes release issue with xCode 16, bitcode is stripped by default.
bitcode_strip_path = `xcrun --find bitcode_strip`.chop!
def strip_bitcode_from_framework(bitcode_strip_path, framework_relative_path)
Expand Down
17 changes: 17 additions & 0 deletions ios/scripts/verify-retired-env.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

# Use react-native-config's own reader so this checks the same ENVFILE,
# /tmp/envfile override, and .env fallback that its code generator will use.
reader_directory, environment_root = ARGV
abort('Missing react-native-config environment inputs') unless reader_directory && environment_root

retired_names = %w[GASFREE_API_KEY GASFREE_API_SECRET LETS_EXCHANGE_API_KEY]
retired_names += retired_names.map { |name| "RN_#{name}" }
failure = 'Retired API credentials must not be included in an iOS build'

abort(failure) if retired_names.any? { |name| ENV.key?(name) }

require File.join(reader_directory, 'ReadDotEnv')
dotenv, = read_dot_env(environment_root)
abort(failure) if retired_names.any? { |name| dotenv.key?(name) }
58 changes: 58 additions & 0 deletions ios/scripts/verify-retired-env.test.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
const { test } = require('node:test');
const assert = require('node:assert/strict');
const fs = require('node:fs');
const os = require('node:os');
const path = require('node:path');
const { spawnSync } = require('node:child_process');

const verifier = path.join(__dirname, 'verify-retired-env.rb');
const reader = process.env.KEEPER_TEST_RN_CONFIG_READER ||
path.join(__dirname, '..', '..', 'node_modules', 'react-native-config', 'ios', 'ReactNativeConfig');
const secret = 'synthetic-secret-not-for-output';
const retiredNames = ['GASFREE_API_KEY', 'GASFREE_API_SECRET', 'LETS_EXCHANGE_API_KEY'];
retiredNames.push(...retiredNames.map(name => `RN_${name}`));

function verify(contents, additionalEnv = {}) {
const directory = fs.mkdtempSync(path.join(os.tmpdir(), 'keeper-ios-env-'));
try {
const envFile = path.join(directory, '.env.test');
fs.writeFileSync(envFile, contents);
return spawnSync('ruby', [verifier, reader, directory], {
cwd: directory,
env: { PATH: process.env.PATH, ENVFILE: envFile, ...additionalEnv },
encoding: 'utf8',
});
} finally {
fs.rmSync(directory, { recursive: true, force: true });
}
}

test('iOS pod guard accepts config without retired credentials', () => {
assert.ok(fs.existsSync(reader), 'Install react-native-config before running this test');
const result = verify('CHANNEL_URL=https://channel.bitcoinkeeper.app/\n');
assert.equal(result.status, 0, result.stderr);
});

for (const name of retiredNames) {
test(`iOS pod guard rejects ${name} in selected ENVFILE before logging its value`,
() => {
const result = verify(`CHANNEL_URL=https://channel.bitcoinkeeper.app/\n${name}=${secret}\n`);
assert.notEqual(result.status, 0);
assert.doesNotMatch(result.stdout + result.stderr, /synthetic-secret-not-for-output/);
});
}

test('iOS pod guard rejects exported retired credentials', () => {
const result = verify(`export GASFREE_API_KEY=${secret}\n`);
assert.notEqual(result.status, 0);
assert.doesNotMatch(result.stdout + result.stderr, /synthetic-secret-not-for-output/);
});

test('iOS pod guard rejects a retired process variable before logging its value',
() => {
const result = verify('CHANNEL_URL=https://channel.bitcoinkeeper.app/\n', {
RN_GASFREE_API_SECRET: secret,
});
assert.notEqual(result.status, 0);
assert.doesNotMatch(result.stdout + result.stderr, /synthetic-secret-not-for-output/);
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"iosProd": "npx react-native run-ios --scheme=hexa_keeper --simulator 'iPhone 16' ",
"start": "react-native start",
"test": "jest",
"test:release": "node --test scripts/release-version.test.cjs && python3 -B -m unittest discover -s scripts -p 'test_release_artifact.py'",
"test:release": "node --test scripts/release-version.test.cjs scripts/verify-channel-config.test.cjs && python3 -B -m unittest discover -s scripts -p 'test_release_artifact.py'",
"version:inspect": "node scripts/release-version.cjs inspect",
"version:check": "node scripts/release-version.cjs check",
"version:apply": "node scripts/release-version.cjs apply",
Expand Down
7 changes: 6 additions & 1 deletion scripts/verify-channel-config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ if (!envFile || !fs.existsSync(envFile)) {
throw new Error('Production environment file is missing');
}

const matches = fs.readFileSync(envFile, 'utf8')
const envContents = fs.readFileSync(envFile, 'utf8');
if (/^\s*(?:export\s+)?(?:RN_)?(?:GASFREE_API_(?:KEY|SECRET)|LETS_EXCHANGE_API_KEY)\s*=/m.test(envContents)) {
throw new Error('Retired API credentials must not be included in a release environment');
}

const matches = envContents
.split(/\r?\n/)
.map(line => line.match(/^\s*(?:export\s+)?CHANNEL_URL\s*=\s*(.*?)\s*$/))
.filter(Boolean)
Expand Down
66 changes: 66 additions & 0 deletions scripts/verify-channel-config.test.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
const { test } = require('node:test');
const assert = require('node:assert/strict');
const fs = require('node:fs');
const os = require('node:os');
const path = require('node:path');
const { spawnSync } = require('node:child_process');

const verifier = path.join(__dirname, 'verify-channel-config.cjs');
const prebuild = path.join(__dirname, '..', 'appcenter-pre-build.sh');
const channel = 'CHANNEL_URL=https://channel.bitcoinkeeper.app/\n';

function withTempDirectory(run) {
const directory = fs.mkdtempSync(path.join(os.tmpdir(), 'keeper-usdt-env-'));
try {
return run(directory);
} finally {
fs.rmSync(directory, { recursive: true, force: true });
}
}

test('release env accepts reviewed channel without retired credentials', () =>
withTempDirectory((directory) => {
const envFile = path.join(directory, '.env.production');
fs.writeFileSync(envFile, channel);
const result = spawnSync(process.execPath, [verifier, envFile], { encoding: 'utf8' });
assert.equal(result.status, 0, result.stderr);
}));

for (const name of ['GASFREE_API_KEY', 'GASFREE_API_SECRET', 'RN_GASFREE_API_KEY',
'LETS_EXCHANGE_API_KEY', 'RN_LETS_EXCHANGE_API_KEY']) {
test(`release env rejects ${name} without logging its value`, () =>
withTempDirectory((directory) => {
const envFile = path.join(directory, '.env.production');
const secret = 'synthetic-secret-not-for-output';
fs.writeFileSync(envFile, `${channel}${name}=${secret}\n`);
const result = spawnSync(process.execPath, [verifier, envFile], { encoding: 'utf8' });
assert.notEqual(result.status, 0);
assert.doesNotMatch(result.stdout + result.stderr, /synthetic-secret-not-for-output/);
}));
}

test('AppCenter rejects retired credential input before writing .env', () =>
withTempDirectory((directory) => {
const secret = 'synthetic-secret-not-for-output';
const result = spawnSync('bash', [prebuild], {
cwd: directory,
env: { PATH: process.env.PATH, RN_GASFREE_API_SECRET: secret },
encoding: 'utf8',
});
assert.notEqual(result.status, 0);
assert.equal(fs.existsSync(path.join(directory, '.env')), false);
assert.doesNotMatch(result.stdout + result.stderr, /synthetic-secret-not-for-output/);
}));

test('AppCenter rejects retired swap credential input before writing .env', () =>
withTempDirectory((directory) => {
const secret = 'synthetic-secret-not-for-output';
const result = spawnSync('bash', [prebuild], {
cwd: directory,
env: { PATH: process.env.PATH, RN_LETS_EXCHANGE_API_KEY: secret },
encoding: 'utf8',
});
assert.notEqual(result.status, 0);
assert.equal(fs.existsSync(path.join(directory, '.env')), false);
assert.doesNotMatch(result.stdout + result.stderr, /synthetic-secret-not-for-output/);
}));
8 changes: 0 additions & 8 deletions sonar-project.properties

This file was deleted.

25 changes: 22 additions & 3 deletions src/components/TransactionElement.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useContext } from 'react';
import { Box, useColorMode } from '@gluestack-ui/themed-native-base';
import { StyleSheet, TouchableOpacity } from 'react-native';
import moment from 'moment';
Expand All @@ -21,10 +21,14 @@ import Colors from 'src/theme/Colors';
import useLabelsNew from 'src/hooks/useLabelsNew';
import { Wallet } from 'src/services/wallets/interfaces/wallet';
import { Vault } from 'src/services/wallets/interfaces/vault';
import { USDTTransaction } from 'src/services/wallets/operations/dollars/USDT';
import {
isHistoricalUnverifiedUSDTRequest,
USDTTransaction,
} from 'src/services/wallets/operations/dollars/USDT';
import { EntityKind } from 'src/services/wallets/enums';
import { USDTWallet } from 'src/services/wallets/factories/USDTWalletFactory';
import ThemedColor from './ThemedColor/ThemedColor';
import { LocalizationContext } from 'src/context/Localization/LocContext';

function TransactionElement({
transaction,
Expand All @@ -44,6 +48,9 @@ function TransactionElement({
let amount: number;
let confirmations: number;
let transactionType: string;
const legacyUSDTRequest =
wallet.entityKind === EntityKind.USDT_WALLET &&
isHistoricalUnverifiedUSDTRequest(transaction as USDTTransaction);
if (wallet.entityKind === EntityKind.USDT_WALLET) {
transactionId =
(transaction as USDTTransaction).txId || (transaction as USDTTransaction).traceId;
Expand All @@ -65,6 +72,7 @@ function TransactionElement({

const { labels } = useLabelsNew({ txid: transactionId });
const { colorMode } = useColorMode();
const { translations } = useContext(LocalizationContext);
const formattedDate = moment(date)?.format('DD MMM YY . HH:mm A');
const viewAll_color = ThemedColor({ name: 'viewAll_color' });

Expand All @@ -82,7 +90,7 @@ function TransactionElement({
>
<Box style={styles.rowCenter}>
<Box style={styles.circle}>
{confirmations === 0 && !isCached && (
{confirmations === 0 && !isCached && !legacyUSDTRequest && (
<Box style={styles.transaction}>
<TransactionPendingIcon />
</Box>
Expand Down Expand Up @@ -113,6 +121,11 @@ function TransactionElement({
<Text color={viewAll_color} style={styles.transactionDate} numberOfLines={1}>
{formattedDate}
</Text>
{legacyUSDTRequest && (
<Text color={viewAll_color} style={styles.legacyStatus} numberOfLines={1}>
{translations.usdtWalletText.statusUnavailable}
</Text>
)}
{(transaction as Transaction).tags?.includes('potential-dust-spend') && (
<Box style={styles.dustLabelChip}>
<Text style={styles.dustLabelText} color="rgba(217, 44, 44, 1)">
Expand Down Expand Up @@ -167,6 +180,12 @@ const styles = StyleSheet.create({
marginHorizontal: 3,
lineHeight: 17,
},
legacyStatus: {
fontSize: 10,
width: wp(125),
marginHorizontal: 3,
lineHeight: 13,
},
transactionIdText: {
marginHorizontal: 4,
fontSize: 14,
Expand Down
9 changes: 9 additions & 0 deletions src/context/Localization/language/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2153,6 +2153,15 @@
"psbtMissingSignature": "This PSBT does not include a signature for the selected signer"
},
"usdtWalletText": {
"pausedTitle": "USDT activity is limited",
"pausedBody": "New USDT wallets, sending, buying, selling and swapping are paused. This wallet, its balance and history remain available.",
"sendingPausedTitle": "USDT sending is paused",
"sendingPausedBody": "Keeper cannot send USDT from this wallet right now. Your wallet details, balance and transaction history remain available.",
"receivePausedWarning": "This is your wallet's saved receive address. Keeper cannot send USDT from this wallet while sending is paused. Funds received here cannot be sent through Keeper during the pause. Do not deposit new USDT unless you understand this limitation.",
"statusUnavailable": "Status unavailable",
"legacyRequestTitle": "Earlier USDT request",
"legacyRequestNotice": "Keeper can no longer verify this earlier USDT request. If it completed, it may also appear as a separate on-chain transaction.",
"requestedAmount": "Requested Amount",
"pickWalletType": "Pick Your Wallet Type",
"selectCurrency": "Select the currency you would like to use",
"bitcoinWallet": "Bitcoin Wallet",
Expand Down
9 changes: 9 additions & 0 deletions src/context/Localization/language/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -2134,6 +2134,15 @@
"psbtMissingSignature": "This PSBT does not include a signature for the selected signer"
},
"usdtWalletText": {
"pausedTitle": "La actividad de USDT está limitada",
"pausedBody": "La creación de carteras de USDT, el envío, la compra, la venta y el intercambio están pausados. Esta cartera, su saldo e historial siguen disponibles.",
"sendingPausedTitle": "El envío de USDT está pausado",
"sendingPausedBody": "Keeper no puede enviar USDT desde esta cartera ahora mismo. Los detalles, el saldo y el historial de transacciones de la cartera siguen disponibles.",
"receivePausedWarning": "Esta es la dirección de recepción guardada de tu cartera. Keeper no puede enviar USDT desde esta cartera mientras el envío esté pausado. Los fondos recibidos aquí no se pueden enviar mediante Keeper durante la pausa. No deposites nuevos USDT a menos que comprendas esta limitación.",
"statusUnavailable": "Estado no disponible",
"legacyRequestTitle": "Solicitud anterior de USDT",
"legacyRequestNotice": "Keeper ya no puede verificar esta solicitud de USDT anterior. Si se completó, también puede aparecer como una transacción separada en la cadena.",
"requestedAmount": "Importe solicitado",
"pickWalletType": "Pick Your Wallet Type",
"selectCurrency": "Select the currency you would like to use",
"bitcoinWallet": "Bitcoin Wallet",
Expand Down
7 changes: 7 additions & 0 deletions src/hooks/useUSDTWallets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ export interface UseUSDTWalletsOptions {
includeHidden?: boolean;
}

// Existing USDT wallets remain readable, but new wallet creation and import are paused.
export const USDT_WALLET_CREATION_PAUSED = true;

export interface UseUSDTWalletsReturn {
usdtWallets: USDTWallet[];
error: string | null;
Expand Down Expand Up @@ -101,6 +104,10 @@ export const useUSDTWallets = (options: UseUSDTWalletsOptions = {}): UseUSDTWall
primaryMnemonic?: string;
importDetails?: USDTWalletImportDetails;
}): Promise<{ newWallet?: USDTWallet; error?: string }> => {
if (USDT_WALLET_CREATION_PAUSED) {
return { error: 'USDT wallet setup is paused' };
}

try {
setError(null);
const walletNetworkType = USDTWalletSupportedNetwork;
Expand Down
Loading
Loading