@todesktop/cli 1.12.0-1 → 1.12.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/README.md CHANGED
@@ -1195,6 +1195,10 @@ Now, when we build your app on ToDesktop servers, it will also run your custom `
1195
1195
 
1196
1196
  ## Changelog
1197
1197
 
1198
+ ### v1.12.1
1199
+
1200
+ - Remove sensitive data when logging to `main.log`
1201
+
1198
1202
  ### v1.12.0
1199
1203
 
1200
1204
  - Add support for custom `updateUrlBase` in config to specify a custom auto-update URL
package/dist/cli.js CHANGED
@@ -50,6 +50,40 @@ var os = __toESM(require("os"));
50
50
  var path = __toESM(require("path"));
51
51
  var Sentry = __toESM(require("@sentry/node"));
52
52
  var logger;
53
+ var SENSITIVE_FIELD_KEY_SUBSTRINGS = [
54
+ "token",
55
+ "password",
56
+ "secret",
57
+ "credentials",
58
+ "environmentVariable"
59
+ ];
60
+ function isJWT(str) {
61
+ const jwtPattern = /^[A-Za-z0-9_-]{2,}(?:\.[A-Za-z0-9_-]{2,}){2}$/;
62
+ return typeof str === "string" && str.length > 20 && jwtPattern.test(str);
63
+ }
64
+ function sanitizeFields(obj) {
65
+ if (!obj || typeof obj !== "object") {
66
+ if (typeof obj === "string" && isJWT(obj)) {
67
+ return "[REDACTED JWT]";
68
+ }
69
+ return obj;
70
+ }
71
+ const copy = Array.isArray(obj) ? [...obj] : { ...obj };
72
+ for (const key of Object.keys(copy)) {
73
+ const lowerKey = key.toLowerCase();
74
+ const value = copy[key];
75
+ if (SENSITIVE_FIELD_KEY_SUBSTRINGS.some(
76
+ (substring) => lowerKey.includes(substring) && !lowerKey.startsWith("$")
77
+ )) {
78
+ copy[key] = "[REDACTED]";
79
+ } else if (typeof value === "string" && isJWT(value)) {
80
+ copy[key] = "[REDACTED JWT]";
81
+ } else if (typeof value === "object") {
82
+ copy[key] = sanitizeFields(value);
83
+ }
84
+ }
85
+ return copy;
86
+ }
53
87
  try {
54
88
  const name = "todesktop-cli";
55
89
  let parentDirectory;
@@ -72,7 +106,9 @@ try {
72
106
  fs.mkdirSync(parentDirectory, { recursive: true });
73
107
  logger = import_bunyan.default.createLogger({
74
108
  name,
75
- src: true,
109
+ serializers: {
110
+ scrub: (data) => sanitizeFields(data)
111
+ },
76
112
  streams: [
77
113
  {
78
114
  level: "debug",
@@ -462,7 +498,6 @@ var isPlatformBuildRunning = (platformBuild) => {
462
498
  var import_jsx_runtime3 = require("react/jsx-runtime");
463
499
  var logForCIThrottled = (0, import_lodash.default)(logForCI_default, 60 * 1e3, { trailing: true });
464
500
  var BuildProgress = ({ build, onBuildFailure }) => {
465
- logger_default.debug("BuildProgress component: render");
466
501
  const exit = useExit_default();
467
502
  const [{ hasKickedOff }, setState] = (0, import_react2.useState)({
468
503
  hasKickedOff: false
@@ -814,7 +849,6 @@ var MainLayout = ({
814
849
  commandUsed,
815
850
  hasBuildEverFailed
816
851
  }) => {
817
- logger_default.debug("MainLayout component: render");
818
852
  const onInput = useInput_default();
819
853
  const { isRawModeSupported } = (0, import_ink10.useStdin)();
820
854
  const [
@@ -953,7 +987,10 @@ var import_pretty_bytes = __toESM(require("pretty-bytes"));
953
987
  var import_axios = __toESM(require("axios"));
954
988
  var { TODESKTOP_CLI_FIREBASE_FUNCTIONS_BASE } = getEnvironmentVariables_default();
955
989
  async function postToFirebaseFunction_default(functionName, body = {}, config2 = {}) {
956
- logger_default.debug({ functionName, body, config: config2 }, "postToFirebaseFunction");
990
+ logger_default.debug(
991
+ { scrub: { functionName, body, config: config2 } },
992
+ "postToFirebaseFunction"
993
+ );
957
994
  try {
958
995
  const response = await import_axios.default.post(
959
996
  `${TODESKTOP_CLI_FIREBASE_FUNCTIONS_BASE}${functionName}`,
@@ -961,7 +998,7 @@ async function postToFirebaseFunction_default(functionName, body = {}, config2 =
961
998
  config2
962
999
  );
963
1000
  logger_default.debug(
964
- { responseData: response.data },
1001
+ { scrub: { responseData: response.data } },
965
1002
  "postToFirebaseFunction: success"
966
1003
  );
967
1004
  return response.data;
@@ -2483,11 +2520,13 @@ async function uploadApplicationSource({
2483
2520
  var _a;
2484
2521
  logger_default.debug(
2485
2522
  {
2486
- appId,
2487
- appPkgJson,
2488
- buildId,
2489
- config: config2,
2490
- onProgress
2523
+ scrub: {
2524
+ appId,
2525
+ appPkgJson,
2526
+ buildId,
2527
+ config: config2,
2528
+ onProgress
2529
+ }
2491
2530
  },
2492
2531
  "uploadApplicationSource"
2493
2532
  );
@@ -5466,7 +5505,7 @@ var package_default = {
5466
5505
  access: "public"
5467
5506
  },
5468
5507
  name: "@todesktop/cli",
5469
- version: "1.12.0-0",
5508
+ version: "1.12.0",
5470
5509
  license: "MIT",
5471
5510
  author: "Dave Jeffery <dave@todesktop.com> (http://www.todesktop.com/)",
5472
5511
  homepage: "https://todesktop.com/cli",