@cerefox/memory 1.19.5 → 1.19.6

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.
@@ -5318,7 +5318,7 @@ var init_cli_core = __esm(() => {
5318
5318
  });
5319
5319
 
5320
5320
  // src/meta.ts
5321
- var PKG_VERSION = "1.19.5";
5321
+ var PKG_VERSION = "1.19.6";
5322
5322
  var init_meta = () => {};
5323
5323
 
5324
5324
  // ../../_shared/config/paths.ts
@@ -26589,12 +26589,19 @@ function decideAuth(input) {
26589
26589
  message: "The API key presented is not valid for this server."
26590
26590
  };
26591
26591
  }
26592
- function apiAuth() {
26592
+ function restGatewayKeys(env = process.env) {
26593
+ const keys = env.CEREFOX_API_KEY ?? "";
26594
+ if (!keys.trim() || !(env.CEREFOX_POSTGREST_UPSTREAM ?? "").trim())
26595
+ return keys;
26596
+ const internal = (env.CEREFOX_SUPABASE_KEY ?? "").trim();
26597
+ return internal ? `${keys},${internal}` : keys;
26598
+ }
26599
+ function apiAuth(keys = () => process.env.CEREFOX_API_KEY ?? "") {
26593
26600
  return async (c, next) => {
26594
26601
  const decision = decideAuth({
26595
26602
  remoteAddress: remoteAddressOf(c),
26596
26603
  authorization: c.req.header("Authorization") ?? null,
26597
- configuredKeys: process.env.CEREFOX_API_KEY ?? "",
26604
+ configuredKeys: keys(),
26598
26605
  requireKeyEverywhere: (process.env.CEREFOX_API_REQUIRE_KEY ?? "") === "1"
26599
26606
  });
26600
26607
  if (decision.allow)
@@ -26895,7 +26902,7 @@ var init_update_check = __esm(() => {
26895
26902
  });
26896
26903
 
26897
26904
  // ../../_shared/ef-meta/index.ts
26898
- var EF_VERSION = "1.19.5", CEREFOX_VERSION = "1.19.5", EF_LAST_CHANGED = "1.19.0";
26905
+ var EF_VERSION = "1.19.6", CEREFOX_VERSION = "1.19.6", EF_LAST_CHANGED = "1.19.0";
26899
26906
  var init_ef_meta = () => {};
26900
26907
 
26901
26908
  // ../../_shared/embeddings/onnx-embedder.ts
@@ -59292,7 +59299,7 @@ var require_data = __commonJS(function(exports, module) {
59292
59299
  };
59293
59300
  });
59294
59301
 
59295
- // ../../node_modules/.bun/fast-uri@3.1.8/node_modules/fast-uri/lib/utils.js
59302
+ // ../../node_modules/.bun/fast-uri@3.1.9/node_modules/fast-uri/lib/utils.js
59296
59303
  var require_utils2 = __commonJS(function(exports, module) {
59297
59304
  var isUUID = RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu);
59298
59305
  var isIPv4 = RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);
@@ -59542,6 +59549,37 @@ var require_utils2 = __commonJS(function(exports, module) {
59542
59549
  }
59543
59550
  return output.join("");
59544
59551
  }
59552
+ function removeDotSegmentsRelative(path) {
59553
+ if (path === "" || path[0] === "/") {
59554
+ return removeDotSegments(path);
59555
+ }
59556
+ const segments = path.split("/");
59557
+ const last = segments.length - 1;
59558
+ const output = [];
59559
+ let trailingDirectory = false;
59560
+ for (let i = 0;i <= last; i++) {
59561
+ const segment = segments[i];
59562
+ if (segment === "." || segment === "..") {
59563
+ if (segment === "..") {
59564
+ if (output.length !== 0 && output[output.length - 1] !== "..") {
59565
+ output.pop();
59566
+ } else {
59567
+ output.push("..");
59568
+ }
59569
+ }
59570
+ trailingDirectory = i === last;
59571
+ } else {
59572
+ output.push(segment);
59573
+ }
59574
+ }
59575
+ if (trailingDirectory && output[output.length - 1] !== "..") {
59576
+ output.push("");
59577
+ }
59578
+ if (output.length === 0 || output[0] === "" || output[0].includes(":")) {
59579
+ output.unshift(".");
59580
+ }
59581
+ return output.join("/");
59582
+ }
59545
59583
  var HOST_DELIMS = { "@": "%40", "/": "%2F", "?": "%3F", "#": "%23", ":": "%3A" };
59546
59584
  var HOST_DELIM_RE = /[@/?#:]/g;
59547
59585
  var HOST_DELIM_NO_COLON_RE = /[@/?#]/g;
@@ -59802,6 +59840,7 @@ var require_utils2 = __commonJS(function(exports, module) {
59802
59840
  encodeFragment,
59803
59841
  escapePreservingEscapes,
59804
59842
  removeDotSegments,
59843
+ removeDotSegmentsRelative,
59805
59844
  isIPv4,
59806
59845
  isUUID,
59807
59846
  normalizeIPv6,
@@ -59809,7 +59848,7 @@ var require_utils2 = __commonJS(function(exports, module) {
59809
59848
  };
59810
59849
  });
59811
59850
 
59812
- // ../../node_modules/.bun/fast-uri@3.1.8/node_modules/fast-uri/lib/schemes.js
59851
+ // ../../node_modules/.bun/fast-uri@3.1.9/node_modules/fast-uri/lib/schemes.js
59813
59852
  var require_schemes = __commonJS(function(exports, module) {
59814
59853
  var { isUUID } = require_utils2();
59815
59854
  var URN_REG = /^([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-./:;=@]|%[\da-f]{2})+)$/iu;
@@ -59984,18 +60023,20 @@ var require_schemes = __commonJS(function(exports, module) {
59984
60023
  };
59985
60024
  });
59986
60025
 
59987
- // ../../node_modules/.bun/fast-uri@3.1.8/node_modules/fast-uri/index.js
60026
+ // ../../node_modules/.bun/fast-uri@3.1.9/node_modules/fast-uri/index.js
59988
60027
  var require_fast_uri = __commonJS(function(exports, module) {
59989
- var { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, serializePathEncoding, normalizeQueryFragmentEncoding, encodeQuery, encodeFragment, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = require_utils2();
60028
+ var { normalizeIPv6, removeDotSegments, removeDotSegmentsRelative, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, serializePathEncoding, normalizeQueryFragmentEncoding, encodeQuery, encodeFragment, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = require_utils2();
59990
60029
  var { SCHEMES, getSchemeHandler } = require_schemes();
59991
60030
  var VALID_SCHEME = /^[A-Za-z][A-Za-z0-9+.-]*$/u;
59992
60031
  var MALFORMED_SCHEME_ERROR = "URI scheme is malformed.";
59993
- function decodeValidScheme(scheme) {
59994
- const decodedScheme = unescape(String(scheme));
59995
- if (!VALID_SCHEME.test(decodedScheme)) {
60032
+ var MALFORMED_HOST_ERROR = "URI host is malformed.";
60033
+ var FORBIDDEN_DOMAIN_HOST_CHARACTER = /[\0-\x20"#/:<>?@[\\\]^`{|}\x7F]/u;
60034
+ function validateScheme(scheme) {
60035
+ const stringScheme = String(scheme);
60036
+ if (!VALID_SCHEME.test(stringScheme)) {
59996
60037
  throw new TypeError(MALFORMED_SCHEME_ERROR);
59997
60038
  }
59998
- return decodedScheme;
60039
+ return stringScheme;
59999
60040
  }
60000
60041
  function normalize(uri, options) {
60001
60042
  if (typeof uri === "string") {
@@ -60030,6 +60071,9 @@ var require_fast_uri = __commonJS(function(exports, module) {
60030
60071
  const resolvedSchemeHandler = getSchemeHandler(options && options.scheme || resolved.scheme);
60031
60072
  const resolvedHost = resolved.host;
60032
60073
  const resolvedHostIsIP = resolvedHost !== undefined && resolvedHost !== "" && (isIPv4(resolvedHost) || normalizeIPv6(resolvedHost).isIPV6);
60074
+ if (hasForbiddenDomainHost(resolved, options || {}, resolvedSchemeHandler, resolvedHostIsIP)) {
60075
+ throw new Error(MALFORMED_HOST_ERROR);
60076
+ }
60033
60077
  canonicalizeHost(resolved, options || {}, resolvedSchemeHandler, resolvedHostIsIP);
60034
60078
  const encodedASCIIHost = resolvedHost && resolvedHost.indexOf("%") !== -1 && !/\P{ASCII}/u.test(resolvedHost);
60035
60079
  if (resolved.error && !encodedASCIIHost) {
@@ -60071,14 +60115,15 @@ var require_fast_uri = __commonJS(function(exports, module) {
60071
60115
  if (relative.path[0] === "/") {
60072
60116
  target.path = removeDotSegments(relative.path);
60073
60117
  } else {
60074
- if ((base.userinfo !== undefined || base.host !== undefined || base.port !== undefined) && !base.path) {
60118
+ const baseHasAuthority = base.userinfo !== undefined || base.host !== undefined || base.port !== undefined;
60119
+ if (baseHasAuthority && !base.path) {
60075
60120
  target.path = "/" + relative.path;
60076
60121
  } else if (!base.path) {
60077
60122
  target.path = relative.path;
60078
60123
  } else {
60079
60124
  target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative.path;
60080
60125
  }
60081
- target.path = removeDotSegments(target.path);
60126
+ target.path = base.scheme === undefined && !baseHasAuthority && target.path[0] !== "/" ? removeDotSegmentsRelative(target.path) : removeDotSegments(target.path);
60082
60127
  }
60083
60128
  target.query = relative.query;
60084
60129
  }
@@ -60116,13 +60161,14 @@ var require_fast_uri = __commonJS(function(exports, module) {
60116
60161
  const options = Object.assign({}, opts);
60117
60162
  const uriTokens = [];
60118
60163
  if (component.scheme) {
60119
- component.scheme = decodeValidScheme(component.scheme);
60164
+ component.scheme = validateScheme(component.scheme);
60120
60165
  }
60121
60166
  const schemeHandler = getSchemeHandler(options.scheme || component.scheme);
60122
60167
  if (schemeHandler && schemeHandler.serialize)
60123
60168
  schemeHandler.serialize(component, options);
60124
60169
  const hasAuthority = component.userinfo !== undefined || component.host !== undefined || component.port !== undefined;
60125
- const pathNoScheme = !options.skipEscape && component.scheme === undefined && !hasAuthority;
60170
+ const schemelessReference = (component.scheme === undefined || options.reference === "suffix") && !hasAuthority;
60171
+ const pathNoScheme = !options.skipEscape && schemelessReference;
60126
60172
  if (component.path !== undefined) {
60127
60173
  if (!options.skipEscape) {
60128
60174
  component.path = serializePathEncoding(component.path, pathNoScheme);
@@ -60131,7 +60177,7 @@ var require_fast_uri = __commonJS(function(exports, module) {
60131
60177
  }
60132
60178
  }
60133
60179
  if (options.reference !== "suffix" && component.scheme) {
60134
- component.scheme = decodeValidScheme(component.scheme);
60180
+ component.scheme = validateScheme(component.scheme);
60135
60181
  uriTokens.push(component.scheme, ":");
60136
60182
  }
60137
60183
  const authority = recomposeAuthority(component);
@@ -60147,9 +60193,9 @@ var require_fast_uri = __commonJS(function(exports, module) {
60147
60193
  if (component.path !== undefined) {
60148
60194
  let s = component.path;
60149
60195
  if (!options.absolutePath && (!schemeHandler || !schemeHandler.absolutePath)) {
60150
- s = removeDotSegments(s);
60196
+ s = schemelessReference && s[0] !== "/" ? removeDotSegmentsRelative(s) : removeDotSegments(s);
60151
60197
  }
60152
- if (pathNoScheme) {
60198
+ if (schemelessReference) {
60153
60199
  s = serializePathEncoding(s, true);
60154
60200
  }
60155
60201
  if (authority === undefined && s[0] === "/" && s[1] === "/") {
@@ -60197,16 +60243,32 @@ var require_fast_uri = __commonJS(function(exports, module) {
60197
60243
  return hasMalformedPercentEncoding(matches[3]) || host !== undefined && !isIPLiteral(host) && hasMalformedPercentEncoding(host) || hasMalformedPercentEncoding(matches[6]) || hasMalformedPercentEncoding(matches[7]) || hasMalformedPercentEncoding(matches[8]);
60198
60244
  }
60199
60245
  function canonicalizeHost(parsed, options, schemeHandler, isIP) {
60246
+ if (hasForbiddenDomainHost(parsed, options, schemeHandler, isIP)) {
60247
+ parsed.error = parsed.error || MALFORMED_HOST_ERROR;
60248
+ return true;
60249
+ }
60200
60250
  if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport) && parsed.host && !isIPLiteral(parsed.host) && (options.domainHost || schemeHandler && schemeHandler.domainHost) && isIP === false && nonSimpleDomain(parsed.host)) {
60251
+ let url;
60201
60252
  try {
60202
- parsed.host = new URL("http://" + parsed.host).hostname;
60253
+ url = new URL("http://" + parsed.host);
60203
60254
  } catch (e) {
60204
60255
  parsed.error = parsed.error || "Host's domain name can not be converted to ASCII: " + e;
60205
60256
  return true;
60206
60257
  }
60258
+ if (!isHostOnlyURL(url)) {
60259
+ parsed.error = parsed.error || MALFORMED_HOST_ERROR;
60260
+ return true;
60261
+ }
60262
+ parsed.host = url.hostname;
60207
60263
  }
60208
60264
  return false;
60209
60265
  }
60266
+ function hasForbiddenDomainHost(parsed, options, schemeHandler, isIP) {
60267
+ return Boolean(parsed.host && isIP === false && !isIPLiteral(parsed.host) && (options.domainHost || schemeHandler && schemeHandler.domainHost) && FORBIDDEN_DOMAIN_HOST_CHARACTER.test(parsed.host));
60268
+ }
60269
+ function isHostOnlyURL(url) {
60270
+ return url.username === "" && url.password === "" && url.port === "" && url.pathname === "/" && url.search === "" && url.hash === "" && url.hostname !== "";
60271
+ }
60210
60272
  function parseWithStatus(uri, opts) {
60211
60273
  const options = Object.assign({}, opts);
60212
60274
  const parsed = {
@@ -60261,9 +60323,8 @@ var require_fast_uri = __commonJS(function(exports, module) {
60261
60323
  parsed.query = matches[7];
60262
60324
  parsed.fragment = matches[8];
60263
60325
  if (parsed.scheme !== undefined) {
60264
- const decodedScheme = unescape(parsed.scheme);
60265
- if (VALID_SCHEME.test(decodedScheme)) {
60266
- parsed.scheme = decodedScheme.toLowerCase();
60326
+ if (VALID_SCHEME.test(parsed.scheme)) {
60327
+ parsed.scheme = parsed.scheme.toLowerCase();
60267
60328
  } else {
60268
60329
  parsed.error = parsed.error || MALFORMED_SCHEME_ERROR;
60269
60330
  malformedScheme = true;
@@ -60291,7 +60352,7 @@ var require_fast_uri = __commonJS(function(exports, module) {
60291
60352
  malformedIPLiteral = hasIPLiteralBracket && (!bracketedIPLiteral || ipv6result.error === true);
60292
60353
  parsed.host = isIP ? ipv6result.host : ipv6result.host.toLowerCase();
60293
60354
  if (malformedIPLiteral) {
60294
- parsed.error = parsed.error || "URI host is malformed.";
60355
+ parsed.error = parsed.error || MALFORMED_HOST_ERROR;
60295
60356
  malformedAuthorityOrPort = true;
60296
60357
  }
60297
60358
  } else {
@@ -60319,7 +60380,7 @@ var require_fast_uri = __commonJS(function(exports, module) {
60319
60380
  if (!isIP) {
60320
60381
  host = normalizePercentEncoding(host.toLowerCase());
60321
60382
  }
60322
- parsed.host = reescapeHostDelimiters(host, isIP);
60383
+ parsed.host = isIP || options.scheme !== "null" ? reescapeHostDelimiters(host, isIP) : host;
60323
60384
  }
60324
60385
  if (!schemeHandler || schemeHandler && !schemeHandler.skipNormalize) {
60325
60386
  if (parsed.path) {
@@ -82125,7 +82186,7 @@ function buildApp(ctx = buildWebContext()) {
82125
82186
  c.res.headers.set("Link", `<${OPENAPI_PATH}>; rel="service-desc"`);
82126
82187
  });
82127
82188
  app.use("/api/v1/*", apiAuth());
82128
- app.use("/rest/v1/*", apiAuth());
82189
+ app.use("/rest/v1/*", apiAuth(() => restGatewayKeys()));
82129
82190
  registerMetaRoutes(app, ctx);
82130
82191
  registerPreferencesRoutes(app);
82131
82192
  if (ctx) {
@@ -18,7 +18,7 @@
18
18
  * doesn't touch `supabase/functions/` leaves it alone).
19
19
  */
20
20
 
21
- export const EF_VERSION = "1.19.5";
21
+ export const EF_VERSION = "1.19.6";
22
22
 
23
23
  /**
24
24
  * The Cerefox RELEASE version — what `cerefox --version` reports and what npm
@@ -36,7 +36,7 @@ export const EF_VERSION = "1.19.5";
36
36
  * is imported by the Deno Edge Functions, which cannot reach into the npm
37
37
  * package.
38
38
  */
39
- export const CEREFOX_VERSION = "1.19.5";
39
+ export const CEREFOX_VERSION = "1.19.6";
40
40
 
41
41
  /**
42
42
  * The most recent version whose EF-side SOURCE actually changed (#127).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cerefox/memory",
3
- "version": "1.19.5",
3
+ "version": "1.19.6",
4
4
  "description": "Cerefox \u2014 user-owned shared memory for AI agents. CLI + stdio MCP server + web UI + ingestion for a knowledge base on your own Supabase project (or fully self-hosted with Cerefox Local).",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/fstamatelopoulos/cerefox",