@trops/dash-core 0.1.805 → 0.1.806

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.
@@ -16097,6 +16097,24 @@ var schedulerController_1 = schedulerController$2;
16097
16097
  return base;
16098
16098
  }
16099
16099
 
16100
+ // True only for a path strictly inside the widgets folder, links resolved,
16101
+ // so a widget loaded from the user's folder (or a link to it) is never
16102
+ // deleted with it.
16103
+ function isInsideWidgetsDir(target) {
16104
+ try {
16105
+ const root = fs.realpathSync(WIDGETS_CACHE_DIR);
16106
+ const rel = path.relative(root, fs.realpathSync(target));
16107
+ return (
16108
+ rel !== "" &&
16109
+ rel !== ".." &&
16110
+ !rel.startsWith(`..${path.sep}`) &&
16111
+ !path.isAbsolute(rel)
16112
+ );
16113
+ } catch {
16114
+ return false;
16115
+ }
16116
+ }
16117
+
16100
16118
  class WidgetRegistry {
16101
16119
  constructor(componentManager = null, customPath = null) {
16102
16120
  if (!WIDGETS_CACHE_DIR) {
@@ -17241,7 +17259,9 @@ var schedulerController_1 = schedulerController$2;
17241
17259
  }
17242
17260
 
17243
17261
  try {
17244
- if (fs.existsSync(widget.path)) {
17262
+ // A folder of widgets loads in place, so its path is the user's own
17263
+ // folder: forget the widget, never delete files outside Dash's own.
17264
+ if (fs.existsSync(widget.path) && isInsideWidgetsDir(widget.path)) {
17245
17265
  fs.rmSync(widget.path, { recursive: true });
17246
17266
  }
17247
17267
 
@@ -17843,7 +17863,8 @@ var schedulerController_1 = schedulerController$2;
17843
17863
  module.exports.setupWidgetRegistryHandlers = setupWidgetRegistryHandlers;
17844
17864
  module.exports.validateZipEntries = validateZipEntries;
17845
17865
  module.exports.setInstallGate = setInstallGate;
17846
- module.exports.checkPackage = checkPackage;
17866
+ module.exports.checkPackage = checkPackage;
17867
+ module.exports.isInsideWidgetsDir = isInsideWidgetsDir;
17847
17868
  } (widgetRegistry$1));
17848
17869
 
17849
17870
  var widgetRegistryExports = widgetRegistry$1.exports;