Skip to content

Commit

Permalink
feat(mobile): prevent 3rd party access our packages
Browse files Browse the repository at this point in the history
  • Loading branch information
Nodonisko committed Feb 19, 2025
1 parent 8586a18 commit c851f55
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions suite-native/app/metro.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ const defaultSourceExts = jsonExpoConfig.resolver.sourceExts;
const additionalSOurceExts = process.env.RN_SRC_EXT ? process.env.RN_SRC_EXT.split(',') : [];
const sourceExts = [...additionalSOurceExts, ...defaultSourceExts];

const TREZOR_PACKAGES_SCOPES = ['@trezor', '@suite-common', '@suite-native'];

/**
* Metro configuration
* https://facebook.github.io/metro/docs/configuration
Expand Down Expand Up @@ -36,6 +38,14 @@ const config = {
},
sourceExts,
resolveRequest: (context, moduleName, platform) => {
if (
TREZOR_PACKAGES_SCOPES.some(scope => moduleName.includes(scope)) &&
context.originModulePath.includes('node_modules/')
) {
throw new Error(
`SECURITY ALERT: Some 3rd party package is using our interal packages or Connect! Please check this file: ${context.originModulePath}`,
);
}
// index 0 refers to suite-native/app node_modules directory
const rootNodeModulesPath = context.nodeModulesPaths[1];

Expand Down

0 comments on commit c851f55

Please sign in to comment.