Skip to content

Commit cbb7e8b

Browse files
committed
implement lavamoat
1 parent 1a50f5a commit cbb7e8b

12 files changed

Lines changed: 1356 additions & 80 deletions

File tree

Gemfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ GEM
8080
mutex_m
8181
i18n (1.14.7)
8282
concurrent-ruby (~> 1.0)
83-
json (2.15.2)
83+
json (2.16.0)
8484
logger (1.7.0)
85-
minitest (5.26.0)
85+
minitest (5.26.1)
8686
molinillo (0.8.0)
8787
mutex_m (0.3.0)
8888
nanaimo (0.3.0)

babel.config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,6 @@ module.exports = {
2424
plugins: ['transform-remove-console'],
2525
},
2626
},
27+
// Ignore SES files from transformation for LavaMoat compatibility
28+
ignore: [/\/ses\.cjs$/, /\/ses-hermes\.cjs$/],
2729
};

index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
/**
22
* @format
33
*/
4+
5+
// LavaMoat lockdown is automatically injected by the Metro serializer
6+
// configured in metro.config.js - no manual import needed
47
import './shim.js';
58
import 'react-native-get-random-values';
69
import { AppRegistry } from 'react-native';

metro.config.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');
2+
const { lockdownSerializer } = require('@lavamoat/react-native-lockdown');
23

34
const defaultConfig = getDefaultConfig(__dirname);
45
const { assetExts, sourceExts } = defaultConfig.resolver;
56

7+
// Polyfills needed for React Native
8+
const getPolyfills = () => [
9+
// eslint-disable-next-line import/no-extraneous-dependencies
10+
...require('@react-native/js-polyfills')(),
11+
];
12+
613
/**
7-
* Metro configuration
14+
* Metro configuration with LavaMoat lockdown protection
815
* https://reactnative.dev/docs/metro
916
*
1017
* @type {import('@react-native/metro-config').MetroConfig}
@@ -15,8 +22,12 @@ const config = {
1522
},
1623
resolver: {
1724
assetExts: assetExts.filter((ext) => ext !== 'svg'),
18-
sourceExts: [...sourceExts, 'svg'],
25+
sourceExts: [...sourceExts, 'svg', 'cjs'],
1926
},
27+
serializer: lockdownSerializer(
28+
{ hermesRuntime: true },
29+
{ getPolyfills }
30+
),
2031
};
2132

2233
module.exports = mergeConfig(getDefaultConfig(__dirname), config);

package.json

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,14 @@
2222
},
2323
"dependencies": {
2424
"@alchemy/aa-core": "3.19.0",
25+
"@lavamoat/react-native-lockdown": "0.0.2",
2526
"@notifee/react-native": "9.1.8",
2627
"@react-native-clipboard/clipboard": "1.16.3",
2728
"@react-native-community/blur": "4.4.1",
2829
"@react-native-firebase/app": "23.5.0",
2930
"@react-native-firebase/messaging": "23.5.0",
3031
"@react-native-picker/picker": "2.11.4",
32+
"@react-native/js-polyfills": "0.82.1",
3133
"@react-navigation/native": "7.1.19",
3234
"@react-navigation/stack": "7.6.2",
3335
"@reduxjs/toolkit": "2.10.1",
@@ -90,6 +92,7 @@
9092
"@babel/preset-env": "7.28.5",
9193
"@babel/runtime": "7.28.4",
9294
"@eslint/js": "9.39.1",
95+
"@lavamoat/allow-scripts": "^3.0.4",
9396
"@react-native-community/cli": "20.0.2",
9497
"@react-native-community/cli-platform-android": "20.0.2",
9598
"@react-native-community/cli-platform-ios": "20.0.2",
@@ -159,5 +162,36 @@
159162
"tls": false,
160163
"net": "react-native-tcp-socket",
161164
"zlib": "browserify-zlib"
165+
},
166+
"lavamoat": {
167+
"allowScripts": {
168+
"@notifee/react-native": false,
169+
"@react-native-firebase/app": false,
170+
"@react-native-firebase/messaging": false,
171+
"@react-native/js-polyfills": false,
172+
"jail-monkey": false,
173+
"react-native": false,
174+
"react-native-camera-kit": false,
175+
"react-native-encrypted-storage": false,
176+
"react-native-gesture-handler": false,
177+
"react-native-keychain": false,
178+
"react-native-mmkv": false,
179+
"react-native-nitro-modules": false,
180+
"react-native-permissions": false,
181+
"react-native-quick-crypto": false,
182+
"react-native-reanimated": false,
183+
"react-native-screens": false,
184+
"react-native-svg": false,
185+
"react-native-tcp-socket": false,
186+
"react-native-vector-icons": false,
187+
"react-native-worklets": false,
188+
"$root$": true,
189+
"@react-native-firebase/app>firebase>@firebase/firestore>@grpc/proto-loader>protobufjs": false,
190+
"@react-native-firebase/app>firebase>@firebase/util": false,
191+
"@runonflux/aa-schnorr-multisig-sdk>secp256k1": true,
192+
"@runonflux/utxo-lib>secp256k1": true,
193+
"jest>@jest/core>jest-resolve>unrs-resolver": false,
194+
"postinstall-postinstall": true
195+
}
162196
}
163197
}

src/components/HelpSection/HelpSection.tsx

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import React, { useState } from 'react';
22
import {
33
View,
44
Text,
@@ -17,10 +17,12 @@ import packageJson from '../../../package.json';
1717
const HelpSection = (props: {
1818
actionStatus: (status: boolean) => void;
1919
visible: boolean;
20+
navigation?: any;
2021
}) => {
2122
const { t } = useTranslation(['home', 'common']);
2223
const { Fonts, Gutters, Layout, Common, Colors, darkMode, Images } =
2324
useTheme();
25+
const [versionTapCount, setVersionTapCount] = useState(0);
2426

2527
const close = () => {
2628
console.log('Close');
@@ -46,6 +48,20 @@ const HelpSection = (props: {
4648
Linking.openURL('https://runonflux.io');
4749
};
4850

51+
const handleVersionTap = () => {
52+
const newCount = versionTapCount + 1;
53+
setVersionTapCount(newCount);
54+
if (newCount >= 5) {
55+
setVersionTapCount(0);
56+
close();
57+
if (props.navigation) {
58+
setTimeout(() => {
59+
props.navigation.navigate('LavaMoatTest');
60+
}, 100);
61+
}
62+
}
63+
};
64+
4965
return (
5066
<Modal
5167
animationType="fade"
@@ -127,14 +143,16 @@ const HelpSection = (props: {
127143
}
128144
/>
129145
</TouchableOpacity>
130-
<Text
131-
style={[
132-
Fonts.textTiny,
133-
Fonts.textCenter
134-
]}
135-
>
136-
v{packageJson.version}
137-
</Text>
146+
<TouchableOpacity onPress={handleVersionTap}>
147+
<Text
148+
style={[
149+
Fonts.textTiny,
150+
Fonts.textCenter
151+
]}
152+
>
153+
v{packageJson.version}
154+
</Text>
155+
</TouchableOpacity>
138156
</View>
139157
<View style={[Layout.justifyContentEnd]}>
140158
<TouchableOpacity

src/components/Navbar/Navbar.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { useTheme } from '../../hooks';
55

66
import HelpSection from '../../components/HelpSection/HelpSection';
77

8-
function Navbar(props: { openSettingsTrigger: () => void }) {
8+
function Navbar(props: { openSettingsTrigger: () => void; navigation?: any }) {
99
const { darkMode, Gutters, Layout, Images, Colors } = useTheme();
1010
const [helpSectionModalOpen, setHelpSectionModalOpen] = useState(false);
1111
const openHelp = () => {
@@ -48,6 +48,7 @@ function Navbar(props: { openSettingsTrigger: () => void }) {
4848
<HelpSection
4949
actionStatus={handleHelpModalAction}
5050
visible={helpSectionModalOpen}
51+
navigation={props.navigation}
5152
/>
5253
</View>
5354
</>

src/navigators/Main.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { Home, Welcome, Create, Restore } from '../screens';
2+
import { Home, Welcome, Create, Restore, LavaMoatTest } from '../screens';
33
import { createStackNavigator } from '@react-navigation/stack';
44
import { useAppSelector } from '../hooks';
55

@@ -17,6 +17,7 @@ const MainNavigator = () => {
1717
)}
1818
<Stack.Screen name="Create" component={Create} />
1919
<Stack.Screen name="Restore" component={Restore} />
20+
<Stack.Screen name="LavaMoatTest" component={LavaMoatTest} />
2021
</Stack.Navigator>
2122
);
2223
};

src/screens/Home/Home.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1323,7 +1323,7 @@ function Home({ navigation }: Props) {
13231323

13241324
return (
13251325
<View style={[Layout.fill, Layout.colCenter, Layout.scrollSpaceBetween]}>
1326-
<Navbar openSettingsTrigger={openSettings} />
1326+
<Navbar openSettingsTrigger={openSettings} navigation={navigation} />
13271327
<Divider color={Colors.textGray200} />
13281328
<KeyboardAwareScrollView
13291329
keyboardShouldPersistTaps="always"

0 commit comments

Comments
 (0)