apple-notes-mcp 2.7.4 → 2.7.5

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.
Files changed (2) hide show
  1. package/build/index.js +110 -39
  2. package/package.json +1 -1
package/build/index.js CHANGED
@@ -3660,49 +3660,49 @@ var require_fast_uri = __commonJS({
3660
3660
  schemelessOptions.skipEscape = true;
3661
3661
  return serialize(resolved, schemelessOptions);
3662
3662
  }
3663
- function resolveComponent(base, relative, options, skipNormalization) {
3663
+ function resolveComponent(base, relative2, options, skipNormalization) {
3664
3664
  const target = {};
3665
3665
  if (!skipNormalization) {
3666
3666
  base = parse3(serialize(base, options), options);
3667
- relative = parse3(serialize(relative, options), options);
3667
+ relative2 = parse3(serialize(relative2, options), options);
3668
3668
  }
3669
3669
  options = options || {};
3670
- if (!options.tolerant && relative.scheme) {
3671
- target.scheme = relative.scheme;
3672
- target.userinfo = relative.userinfo;
3673
- target.host = relative.host;
3674
- target.port = relative.port;
3675
- target.path = removeDotSegments(relative.path || "");
3676
- target.query = relative.query;
3670
+ if (!options.tolerant && relative2.scheme) {
3671
+ target.scheme = relative2.scheme;
3672
+ target.userinfo = relative2.userinfo;
3673
+ target.host = relative2.host;
3674
+ target.port = relative2.port;
3675
+ target.path = removeDotSegments(relative2.path || "");
3676
+ target.query = relative2.query;
3677
3677
  } else {
3678
- if (relative.userinfo !== void 0 || relative.host !== void 0 || relative.port !== void 0) {
3679
- target.userinfo = relative.userinfo;
3680
- target.host = relative.host;
3681
- target.port = relative.port;
3682
- target.path = removeDotSegments(relative.path || "");
3683
- target.query = relative.query;
3678
+ if (relative2.userinfo !== void 0 || relative2.host !== void 0 || relative2.port !== void 0) {
3679
+ target.userinfo = relative2.userinfo;
3680
+ target.host = relative2.host;
3681
+ target.port = relative2.port;
3682
+ target.path = removeDotSegments(relative2.path || "");
3683
+ target.query = relative2.query;
3684
3684
  } else {
3685
- if (!relative.path) {
3685
+ if (!relative2.path) {
3686
3686
  target.path = base.path;
3687
- if (relative.query !== void 0) {
3688
- target.query = relative.query;
3687
+ if (relative2.query !== void 0) {
3688
+ target.query = relative2.query;
3689
3689
  } else {
3690
3690
  target.query = base.query;
3691
3691
  }
3692
3692
  } else {
3693
- if (relative.path[0] === "/") {
3694
- target.path = removeDotSegments(relative.path);
3693
+ if (relative2.path[0] === "/") {
3694
+ target.path = removeDotSegments(relative2.path);
3695
3695
  } else {
3696
3696
  if ((base.userinfo !== void 0 || base.host !== void 0 || base.port !== void 0) && !base.path) {
3697
- target.path = "/" + relative.path;
3697
+ target.path = "/" + relative2.path;
3698
3698
  } else if (!base.path) {
3699
- target.path = relative.path;
3699
+ target.path = relative2.path;
3700
3700
  } else {
3701
- target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative.path;
3701
+ target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative2.path;
3702
3702
  }
3703
3703
  target.path = removeDotSegments(target.path);
3704
3704
  }
3705
- target.query = relative.query;
3705
+ target.query = relative2.query;
3706
3706
  }
3707
3707
  target.userinfo = base.userinfo;
3708
3708
  target.host = base.host;
@@ -3710,7 +3710,7 @@ var require_fast_uri = __commonJS({
3710
3710
  }
3711
3711
  target.scheme = base.scheme;
3712
3712
  }
3713
- target.fragment = relative.fragment;
3713
+ target.fragment = relative2.fragment;
3714
3714
  return target;
3715
3715
  }
3716
3716
  function equal(uriA, uriB, options) {
@@ -11912,9 +11912,9 @@ var require_URL = __commonJS({
11912
11912
  },
11913
11913
  // See: http://tools.ietf.org/html/rfc3986#section-5.2
11914
11914
  // and https://url.spec.whatwg.org/#constructors
11915
- resolve: function(relative) {
11915
+ resolve: function(relative2) {
11916
11916
  var base = this;
11917
- var r = new URL2(relative);
11917
+ var r = new URL2(relative2);
11918
11918
  var t = new URL2();
11919
11919
  if (r.scheme !== void 0) {
11920
11920
  t.scheme = r.scheme;
@@ -24193,14 +24193,14 @@ var require_turndown_cjs = __commonJS({
24193
24193
  } else if (node.nodeType === 1) {
24194
24194
  replacement = replacementForNode.call(self, node);
24195
24195
  }
24196
- return join6(output, replacement);
24196
+ return join7(output, replacement);
24197
24197
  }, "");
24198
24198
  }
24199
24199
  function postProcess(output) {
24200
24200
  var self = this;
24201
24201
  this.rules.forEach(function(rule) {
24202
24202
  if (typeof rule.append === "function") {
24203
- output = join6(output, rule.append(self.options));
24203
+ output = join7(output, rule.append(self.options));
24204
24204
  }
24205
24205
  });
24206
24206
  return output.replace(/^[\t\r\n]+/, "").replace(/[\t\r\n\s]+$/, "");
@@ -24212,7 +24212,7 @@ var require_turndown_cjs = __commonJS({
24212
24212
  if (whitespace.leading || whitespace.trailing) content = content.trim();
24213
24213
  return whitespace.leading + rule.replacement(content, node, this.options) + whitespace.trailing;
24214
24214
  }
24215
- function join6(output, replacement) {
24215
+ function join7(output, replacement) {
24216
24216
  var s1 = trimTrailingNewlines(output);
24217
24217
  var s2 = trimLeadingNewlines(replacement);
24218
24218
  var nls = Math.max(output.length - s1.length, replacement.length - s2.length);
@@ -39204,8 +39204,17 @@ function getChecklistItems(noteId) {
39204
39204
  }
39205
39205
 
39206
39206
  // src/utils/attachmentFs.ts
39207
- import { existsSync as existsSync2, mkdirSync, mkdtempSync, readFileSync, rmSync, statSync } from "fs";
39208
- import { dirname, isAbsolute, resolve, sep } from "path";
39207
+ import {
39208
+ existsSync as existsSync2,
39209
+ lstatSync,
39210
+ mkdirSync,
39211
+ mkdtempSync,
39212
+ readFileSync,
39213
+ realpathSync,
39214
+ rmSync,
39215
+ statSync
39216
+ } from "fs";
39217
+ import { dirname, isAbsolute, join as join2, relative, resolve, sep } from "path";
39209
39218
  import { homedir as homedir2, tmpdir } from "os";
39210
39219
  function allowedSaveRoots() {
39211
39220
  return [
@@ -39217,17 +39226,79 @@ function allowedSaveRoots() {
39217
39226
  "/private/tmp"
39218
39227
  ];
39219
39228
  }
39220
- function ensureParentDir(abs) {
39229
+ function canonicalize(path4) {
39230
+ return realpathSync.native(path4);
39231
+ }
39232
+ function isWithinRoots(candidate, roots) {
39233
+ return roots.some((root) => {
39234
+ const base = root.endsWith(sep) ? root.slice(0, -1) : root;
39235
+ return candidate === base || candidate.startsWith(base + sep);
39236
+ });
39237
+ }
39238
+ function canonicalRoots(roots) {
39239
+ const canonical = [];
39240
+ for (const root of roots) {
39241
+ const abs = resolve(root);
39242
+ let resolved;
39243
+ try {
39244
+ resolved = canonicalize(abs);
39245
+ } catch {
39246
+ resolved = abs;
39247
+ }
39248
+ if (!canonical.includes(resolved)) canonical.push(resolved);
39249
+ }
39250
+ return canonical;
39251
+ }
39252
+ function entryExists(path4) {
39253
+ try {
39254
+ lstatSync(path4);
39255
+ return true;
39256
+ } catch (e) {
39257
+ const code = e.code;
39258
+ return !(code === "ENOENT" || code === "ENOTDIR");
39259
+ }
39260
+ }
39261
+ function deepestExistingAncestor(abs) {
39262
+ let current = abs;
39263
+ for (; ; ) {
39264
+ if (entryExists(current)) return current;
39265
+ const parent = dirname(current);
39266
+ if (parent === current) return current;
39267
+ current = parent;
39268
+ }
39269
+ }
39270
+ function ensureParentDir(abs, roots = allowedSaveRoots()) {
39271
+ assertSafeSavePath(abs, roots);
39221
39272
  mkdirSync(dirname(abs), { recursive: true });
39222
39273
  }
39223
39274
  function assertSafeSavePath(p, roots = allowedSaveRoots()) {
39224
39275
  if (!p || !p.trim()) throw new Error("A destination path is required.");
39225
39276
  if (!isAbsolute(p)) throw new Error(`Destination path must be absolute: "${p}"`);
39226
39277
  const abs = resolve(p);
39227
- const ok = roots.some((r) => abs === r || abs.startsWith(r.endsWith(sep) ? r : r + sep));
39228
- if (!ok) {
39278
+ if (!isWithinRoots(abs, roots)) {
39279
+ throw new Error(`Refusing to write outside allowed locations (home, temp, /Volumes): "${abs}"`);
39280
+ }
39281
+ const ancestor = deepestExistingAncestor(abs);
39282
+ if (ancestor === abs && lstatSync(abs).isSymbolicLink()) {
39283
+ throw new Error(`Refusing to write to the symbolic link "${abs}".`);
39284
+ }
39285
+ let canonicalAncestor;
39286
+ try {
39287
+ canonicalAncestor = canonicalize(ancestor);
39288
+ } catch {
39289
+ throw new Error(`Destination path cannot be resolved: "${abs}"`);
39290
+ }
39291
+ const suffix = relative(ancestor, abs);
39292
+ if (suffix.split(sep).includes("..")) {
39229
39293
  throw new Error(`Refusing to write outside allowed locations (home, temp, /Volumes): "${abs}"`);
39230
39294
  }
39295
+ const canonicalDest = suffix ? join2(canonicalAncestor, suffix) : canonicalAncestor;
39296
+ const allowed = canonicalRoots(roots);
39297
+ if (!isWithinRoots(canonicalAncestor, allowed) || !isWithinRoots(canonicalDest, allowed)) {
39298
+ throw new Error(
39299
+ `Refusing to write outside allowed locations (home, temp, /Volumes): "${abs}" resolves to "${canonicalDest}" through a symbolic link.`
39300
+ );
39301
+ }
39231
39302
  return abs;
39232
39303
  }
39233
39304
  var DEFAULT_MAX_ATTACHMENT_BYTES = 25 * 1024 * 1024;
@@ -39272,7 +39343,7 @@ function cleanupTempDir(dir) {
39272
39343
  var import_turndown = __toESM(require_turndown_cjs(), 1);
39273
39344
  import { existsSync as existsSync3 } from "fs";
39274
39345
  import { homedir as homedir3 } from "os";
39275
- import { join as join2 } from "path";
39346
+ import { join as join3 } from "path";
39276
39347
  var FIELD_SEP = "";
39277
39348
  var RECORD_SEP = "";
39278
39349
  var AS_FIELD_SEP = "(ASCII character 31)";
@@ -39464,7 +39535,7 @@ function getNoteLinkFromDB(coreDataId) {
39464
39535
  const match = coreDataId.match(/\/p(\d+)$/);
39465
39536
  if (!match) return null;
39466
39537
  const pk = parseInt(match[1], 10);
39467
- const dbPath = join2(homedir3(), "Library/Group Containers/group.com.apple.notes/NoteStore.sqlite");
39538
+ const dbPath = join3(homedir3(), "Library/Group Containers/group.com.apple.notes/NoteStore.sqlite");
39468
39539
  if (!existsSync3(dbPath)) return null;
39469
39540
  try {
39470
39541
  const { DatabaseSync } = __require("node:sqlite");
@@ -42108,12 +42179,12 @@ function formatDoctorReport(r) {
42108
42179
 
42109
42180
  // src/services/fileConfig.ts
42110
42181
  import { existsSync as existsSync6, readFileSync as readFileSync2 } from "fs";
42111
- import { join as join5 } from "path";
42182
+ import { join as join6 } from "path";
42112
42183
  import { homedir as homedir6 } from "os";
42113
42184
  function fileConfigPath(env = process.env) {
42114
42185
  const override = env.APPLE_NOTES_MCP_CONFIG_FILE;
42115
42186
  if (override && override.trim()) return override.trim();
42116
- return join5(homedir6(), "Library", "Application Support", "apple-notes-mcp", "config.json");
42187
+ return join6(homedir6(), "Library", "Application Support", "apple-notes-mcp", "config.json");
42117
42188
  }
42118
42189
  function loadFileConfig(env = process.env, path4 = fileConfigPath(env)) {
42119
42190
  const applied = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apple-notes-mcp",
3
- "version": "2.7.4",
3
+ "version": "2.7.5",
4
4
  "description": "MCP server for Apple Notes - create, search, update, and manage notes via Claude and other AI assistants",
5
5
  "type": "module",
6
6
  "main": "build/index.js",