@sentry/react-native 5.19.0 → 5.19.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## 5.19.1
4
+
5
+ ### Fixes
6
+
7
+ - Don't add Expo Plugin option `authToken` to application bundle ([#3630](https://github.com/getsentry/sentry-react-native/pull/3630))
8
+ - Expo plugin configurations are generelly stored in plain text, and are also automatically added to built app bundles, and are therefore considered insecure.
9
+ - You should not set the auth token in the plugin config except for local testing. Instead, use the `SENTRY_AUTH_TOKEN` env variable, as pointed out in our [docs](https://docs.sentry.io/platforms/react-native/manual-setup/expo/).
10
+ - In addition to showing a warning, we are now actively removing an `authToken` from the plugin config if it was set.
11
+ - If you had set the auth token in the plugin config previously, **and** built and published an app with that config, you should [rotate your token](https://docs.sentry.io/product/accounts/auth-tokens/).
12
+ - Reduce waning messages spam when a property in Expo plugin configuration is missing ([#3631](https://github.com/getsentry/sentry-react-native/pull/3631))
13
+
3
14
  ## 5.19.0
4
15
 
5
16
  This release contains upgrade of `sentry-android` dependency to major version 7. There are no breaking changes in the JS API. If you are using the Android API please check [the migration guide](https://docs.sentry.io/platforms/android/migration/#migrating-from-iosentrysentry-android-6x-to-iosentrysentry-android-700).
@@ -1,4 +1,4 @@
1
1
  export declare const SDK_PACKAGE_NAME = "npm:@sentry/react-native";
2
2
  export declare const SDK_NAME = "sentry.javascript.react-native";
3
- export declare const SDK_VERSION = "5.19.0";
3
+ export declare const SDK_VERSION = "5.19.1";
4
4
  //# sourceMappingURL=version.d.ts.map
@@ -1,4 +1,4 @@
1
1
  export const SDK_PACKAGE_NAME = 'npm:@sentry/react-native';
2
2
  export const SDK_NAME = 'sentry.javascript.react-native';
3
- export const SDK_VERSION = '5.19.0';
3
+ export const SDK_VERSION = '5.19.1';
4
4
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/js/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,gBAAgB,GAAG,0BAA0B,CAAC;AAC3D,MAAM,CAAC,MAAM,QAAQ,GAAG,gCAAgC,CAAC;AACzD,MAAM,CAAC,MAAM,WAAW,GAAG,QAAQ,CAAC","sourcesContent":["export const SDK_PACKAGE_NAME = 'npm:@sentry/react-native';\nexport const SDK_NAME = 'sentry.javascript.react-native';\nexport const SDK_VERSION = '5.19.0';\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/js/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,gBAAgB,GAAG,0BAA0B,CAAC;AAC3D,MAAM,CAAC,MAAM,QAAQ,GAAG,gCAAgC,CAAC;AACzD,MAAM,CAAC,MAAM,WAAW,GAAG,QAAQ,CAAC","sourcesContent":["export const SDK_PACKAGE_NAME = 'npm:@sentry/react-native';\nexport const SDK_NAME = 'sentry.javascript.react-native';\nexport const SDK_VERSION = '5.19.1';\n"]}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@sentry/react-native",
3
3
  "homepage": "https://github.com/getsentry/sentry-react-native",
4
4
  "repository": "https://github.com/getsentry/sentry-react-native",
5
- "version": "5.19.0",
5
+ "version": "5.19.1",
6
6
  "description": "Official Sentry SDK for react-native",
7
7
  "typings": "dist/js/index.d.ts",
8
8
  "types": "dist/js/index.d.ts",
@@ -4,4 +4,16 @@ declare const sdkPackage: {
4
4
  version: string;
5
5
  };
6
6
  declare const SDK_PACKAGE_NAME: string;
7
+ export declare function warnOnce(message: string): void;
8
+ export declare function logPrefix(): string;
9
+ /**
10
+ * The same as `chalk.yellow`
11
+ * This code is part of the SDK, we don't want to introduce a dependency on `chalk` just for this.
12
+ */
13
+ export declare function yellow(message: string): string;
14
+ /**
15
+ * The same as `chalk.bold`
16
+ * This code is part of the SDK, we don't want to introduce a dependency on `chalk` just for this.
17
+ */
18
+ export declare function bold(message: string): string;
7
19
  export { sdkPackage, SDK_PACKAGE_NAME };
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.SDK_PACKAGE_NAME = exports.sdkPackage = exports.writeSentryPropertiesTo = void 0;
26
+ exports.SDK_PACKAGE_NAME = exports.sdkPackage = exports.bold = exports.yellow = exports.logPrefix = exports.warnOnce = exports.writeSentryPropertiesTo = void 0;
27
27
  const fs = __importStar(require("fs"));
28
28
  const path = __importStar(require("path"));
29
29
  function writeSentryPropertiesTo(filepath, sentryProperties) {
@@ -35,5 +35,34 @@ function writeSentryPropertiesTo(filepath, sentryProperties) {
35
35
  exports.writeSentryPropertiesTo = writeSentryPropertiesTo;
36
36
  const sdkPackage = require('../../package.json');
37
37
  exports.sdkPackage = sdkPackage;
38
- const SDK_PACKAGE_NAME = sdkPackage.name;
38
+ const SDK_PACKAGE_NAME = `${sdkPackage.name}/expo`;
39
39
  exports.SDK_PACKAGE_NAME = SDK_PACKAGE_NAME;
40
+ const warningMap = new Map();
41
+ function warnOnce(message) {
42
+ if (!warningMap.has(message)) {
43
+ warningMap.set(message, true);
44
+ // eslint-disable-next-line no-console
45
+ console.warn(yellow(`${logPrefix()} ${message}`));
46
+ }
47
+ }
48
+ exports.warnOnce = warnOnce;
49
+ function logPrefix() {
50
+ return `› ${bold('[@sentry/react-native/expo]')}`;
51
+ }
52
+ exports.logPrefix = logPrefix;
53
+ /**
54
+ * The same as `chalk.yellow`
55
+ * This code is part of the SDK, we don't want to introduce a dependency on `chalk` just for this.
56
+ */
57
+ function yellow(message) {
58
+ return `\x1b[33m${message}\x1b[0m`;
59
+ }
60
+ exports.yellow = yellow;
61
+ /**
62
+ * The same as `chalk.bold`
63
+ * This code is part of the SDK, we don't want to introduce a dependency on `chalk` just for this.
64
+ */
65
+ function bold(message) {
66
+ return `\x1b[1m${message}\x1b[22m`;
67
+ }
68
+ exports.bold = bold;
@@ -7,42 +7,47 @@ const withSentryAndroid_1 = require("./withSentryAndroid");
7
7
  const withSentryIOS_1 = require("./withSentryIOS");
8
8
  const withSentryPlugin = (config, props) => {
9
9
  const sentryProperties = getSentryProperties(props);
10
+ if (props && props.authToken) {
11
+ // If not removed, the plugin config with the authToken will be written to the application package
12
+ delete props.authToken;
13
+ }
10
14
  let cfg = config;
11
15
  if (sentryProperties !== null) {
12
16
  try {
13
17
  cfg = (0, withSentryAndroid_1.withSentryAndroid)(cfg, sentryProperties);
14
18
  }
15
19
  catch (e) {
16
- config_plugins_1.WarningAggregator.addWarningAndroid(utils_1.SDK_PACKAGE_NAME, `There was a problem configuring sentry-expo in your native Android project: ${e}`);
20
+ (0, utils_1.warnOnce)(`There was a problem with configuring your native Android project: ${e}`);
17
21
  }
18
22
  try {
19
23
  cfg = (0, withSentryIOS_1.withSentryIOS)(cfg, sentryProperties);
20
24
  }
21
25
  catch (e) {
22
- config_plugins_1.WarningAggregator.addWarningIOS(utils_1.SDK_PACKAGE_NAME, `There was a problem configuring sentry-expo in your native iOS project: ${e}`);
26
+ (0, utils_1.warnOnce)(`There was a problem with configuring your native iOS project: ${e}`);
23
27
  }
24
28
  }
25
29
  return cfg;
26
30
  };
27
- const missingAuthTokenMessage = '# auth.token is configured through SENTRY_AUTH_TOKEN environment variable';
28
31
  const missingProjectMessage = '# no project found, falling back to SENTRY_PROJECT environment variable';
29
32
  const missingOrgMessage = '# no org found, falling back to SENTRY_ORG environment variable';
33
+ const existingAuthTokenMessage = `# DO NOT COMMIT the auth token, use SENTRY_AUTH_TOKEN instead, see https://docs.sentry.io/platforms/react-native/manual-setup/`;
34
+ const missingAuthTokenMessage = `# Using SENTRY_AUTH_TOKEN environment variable`;
30
35
  function getSentryProperties(props) {
31
36
  const { organization, project, authToken, url = 'https://sentry.io/' } = props ?? {};
32
37
  // eslint-disable-next-line no-prototype-builtins
33
38
  const missingProperties = ['organization', 'project'].filter(each => !props?.hasOwnProperty(each));
34
39
  if (missingProperties.length) {
35
- const warningMessage = `Missing Sentry configuration properties: ${missingProperties.join(', ')} in config plugin. Builds will fall back to environment variables. See: https://docs.sentry.io/platforms/react-native/manual-setup/.`;
36
- config_plugins_1.WarningAggregator.addWarningAndroid(utils_1.SDK_PACKAGE_NAME, warningMessage);
37
- config_plugins_1.WarningAggregator.addWarningIOS(utils_1.SDK_PACKAGE_NAME, warningMessage);
40
+ const missingPropertiesString = (0, utils_1.bold)(missingProperties.join(', '));
41
+ const warningMessage = `Missing config for ${missingPropertiesString}. Environment variables will be used as a fallback during the build. https://docs.sentry.io/platforms/react-native/manual-setup/`;
42
+ (0, utils_1.warnOnce)(warningMessage);
43
+ }
44
+ if (authToken) {
45
+ (0, utils_1.warnOnce)(`Detected unsecure use of 'authToken' in Sentry plugin configuration. To avoid exposing the token use ${(0, utils_1.bold)('SENTRY_AUTH_TOKEN')} environment variable instead. https://docs.sentry.io/platforms/react-native/manual-setup/`);
38
46
  }
39
47
  return `defaults.url=${url}
40
48
  ${organization ? `defaults.org=${organization}` : missingOrgMessage}
41
49
  ${project ? `defaults.project=${project}` : missingProjectMessage}
42
- ${authToken
43
- ? `# Configure this value through \`SENTRY_AUTH_TOKEN\` environment variable instead. See: https://docs.sentry.io/platforms/react-native/manual-setup/\nauth.token=${authToken}`
44
- : missingAuthTokenMessage}
45
- `;
50
+ ${authToken ? `${existingAuthTokenMessage}\nauth.token=${authToken}` : missingAuthTokenMessage}`;
46
51
  }
47
52
  exports.getSentryProperties = getSentryProperties;
48
53
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
@@ -59,7 +59,7 @@ function modifyAppBuildGradle(buildGradle) {
59
59
  // See: https://github.com/getsentry/sentry-wizard/blob/e9b4522f27a852069c862bd458bdf9b07cab6e33/lib/Steps/Integrations/ReactNative.ts#L232
60
60
  const pattern = /^android {/m;
61
61
  if (!buildGradle.match(pattern)) {
62
- config_plugins_1.WarningAggregator.addWarningAndroid(utils_1.SDK_PACKAGE_NAME, 'Could not find `^android {` in `android/app/build.gradle`. Please open a bug report at https://github.com/getsentry/sentry-react-native.');
62
+ (0, utils_1.warnOnce)('Could not find `^android {` in `android/app/build.gradle`. Please open a bug report at https://github.com/getsentry/sentry-react-native.');
63
63
  return buildGradle;
64
64
  }
65
65
  const applyFrom = `apply from: new File(${resolveSentryReactNativePackageJsonPath}, "sentry.gradle")`;
@@ -53,10 +53,19 @@ const withSentryIOS = (config, sentryProperties) => {
53
53
  };
54
54
  exports.withSentryIOS = withSentryIOS;
55
55
  function modifyExistingXcodeBuildScript(script) {
56
- if (!script.shellScript.match(/(packager|scripts)\/react-native-xcode\.sh\b/) ||
57
- script.shellScript.includes('sentry-xcode.sh') ||
58
- script.shellScript.includes('@sentry')) {
59
- config_plugins_1.WarningAggregator.addWarningIOS(utils_1.SDK_PACKAGE_NAME, "Unable to modify build script 'Bundle React Native code and images'. Please open a bug report at https://github.com/expo/sentry-expo.");
56
+ if (!script.shellScript.match(/(packager|scripts)\/react-native-xcode\.sh\b/)) {
57
+ (0, utils_1.warnOnce)(`'react-native-xcode.sh' not found in 'Bundle React Native code and images'.
58
+ Please open a bug report at https://github.com/getsentry/sentry-react-native`);
59
+ return;
60
+ }
61
+ if (script.shellScript.includes('sentry-xcode.sh')) {
62
+ (0, utils_1.warnOnce)("The latest 'sentry-xcode.sh' script already exists in 'Bundle React Native code and images'.");
63
+ return;
64
+ }
65
+ if (script.shellScript.includes('@sentry')) {
66
+ (0, utils_1.warnOnce)(`Outdated or custom Sentry script found in 'Bundle React Native code and images'.
67
+ Regenerate the native project to use the latest script.
68
+ Run npx expo prebuild --clean`);
60
69
  return;
61
70
  }
62
71
  const code = JSON.parse(script.shellScript);
@@ -1,4 +1,4 @@
1
1
  export declare const SDK_PACKAGE_NAME = "npm:@sentry/react-native";
2
2
  export declare const SDK_NAME = "sentry.javascript.react-native";
3
- export declare const SDK_VERSION = "5.19.0";
3
+ export declare const SDK_VERSION = "5.19.1";
4
4
  //# sourceMappingURL=version.d.ts.map