mcp-scraper 0.3.40 → 0.3.42

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.
@@ -5489,7 +5489,7 @@ async function fetchWithKernel(url) {
5489
5489
  });
5490
5490
  await client2.browsers.deleteByID(kb.session_id).catch(() => {
5491
5491
  });
5492
- void recordKernelSession({ kernelSessionId: kb.session_id, source: "kernel_fetch", stealth: typeof kb.stealth === "boolean" ? kb.stealth : null, headlessSent: useHeadless ? true : null, proxyUsed: typeof kb.proxy_id === "string" ? Boolean(kb.proxy_id) : null, fallback: true, openedAtMs, closedAtMs: Date.now() });
5492
+ void recordKernelSession({ kernelSessionId: kb.session_id, source: "kernel_fetch", stealth: typeof kb.stealth === "boolean" ? kb.stealth : null, headlessSent: useHeadless, proxyUsed: typeof kb.proxy_id === "string" ? Boolean(kb.proxy_id) : null, fallback: true, openedAtMs, closedAtMs: Date.now() });
5493
5493
  }
5494
5494
  }
5495
5495
  var import_sdk, import_playwright;
@@ -10265,7 +10265,7 @@ var init_rates = __esm({
10265
10265
  CONCURRENCY_SLOT_PRICE_LABEL = "$5/month";
10266
10266
  CONCURRENCY_SLOT_TERMINAL_COMMAND = "npx -y -p mcp-scraper@latest mcp-scraper-cli billing concurrency checkout";
10267
10267
  FREE_SIGNUP_MC = 1e5;
10268
- MEMORY_FREE_QUOTA_BYTES = 1e8 * 1;
10268
+ MEMORY_FREE_QUOTA_BYTES = 1e7 * 1;
10269
10269
  MEMORY_PLANS = {
10270
10270
  "price_1TnMSTS8aAcsk3TGBgiwuvqL": { plan: "pro", label: "Pro", price_id: "price_1TnMSTS8aAcsk3TGBgiwuvqL", interval: "month", monthly_usd: 19, quota_bytes: 5e9 },
10271
10271
  "price_1TnMSTS8aAcsk3TGWBVU2agY": { plan: "pro", label: "Pro", price_id: "price_1TnMSTS8aAcsk3TGWBVU2agY", interval: "year", monthly_usd: 19, quota_bytes: 5e9 }
@@ -25557,7 +25557,7 @@ var PACKAGE_VERSION;
25557
25557
  var init_version = __esm({
25558
25558
  "src/version.ts"() {
25559
25559
  "use strict";
25560
- PACKAGE_VERSION = "0.3.40";
25560
+ PACKAGE_VERSION = "0.3.42";
25561
25561
  }
25562
25562
  });
25563
25563
 
@@ -31600,8 +31600,9 @@ function isAllowedRedirect(uri) {
31600
31600
  } catch {
31601
31601
  return false;
31602
31602
  }
31603
- if (u.protocol !== "https:") return false;
31604
31603
  const h = u.hostname.toLowerCase();
31604
+ if (u.protocol === "http:" && (h === "localhost" || h === "127.0.0.1" || h === "::1")) return true;
31605
+ if (u.protocol !== "https:") return false;
31605
31606
  if (["claude.ai", "www.claude.ai", "claude.com", "www.claude.com"].includes(h)) return true;
31606
31607
  if (h.endsWith(".claude.ai") || h.endsWith(".claude.com")) return true;
31607
31608
  if (["chatgpt.com", "www.chatgpt.com", "chat.openai.com", "www.chat.openai.com"].includes(h)) return true;
@@ -31719,36 +31720,27 @@ function redirectWithError(redirectUri, state, error) {
31719
31720
  if (state) u.searchParams.set("state", state);
31720
31721
  return new Response(null, { status: 302, headers: { Location: u.toString() } });
31721
31722
  }
31722
- function authServerMetadata(scopes = SUPPORTED_SCOPES) {
31723
+ function authServerMetadata() {
31723
31724
  return {
31724
31725
  issuer: ISSUER,
31725
31726
  authorization_endpoint: `${ISSUER}/oauth/authorize`,
31726
31727
  token_endpoint: `${ISSUER}/oauth/token`,
31727
31728
  registration_endpoint: `${ISSUER}/oauth/register`,
31728
31729
  jwks_uri: `${ISSUER}/.well-known/jwks.json`,
31729
- scopes_supported: [...scopes],
31730
+ scopes_supported: [...SUPPORTED_SCOPES],
31730
31731
  response_types_supported: ["code"],
31731
31732
  grant_types_supported: ["authorization_code", "refresh_token"],
31732
31733
  code_challenge_methods_supported: ["S256"],
31733
31734
  token_endpoint_auth_methods_supported: ["none"]
31734
31735
  };
31735
31736
  }
31736
- function openidConfiguration(scopes = SUPPORTED_SCOPES) {
31737
+ function openidConfiguration() {
31737
31738
  return {
31738
- ...authServerMetadata(scopes),
31739
+ ...authServerMetadata(),
31739
31740
  subject_types_supported: ["public"],
31740
31741
  id_token_signing_alg_values_supported: ["RS256"]
31741
31742
  };
31742
31743
  }
31743
- function scopesForRequest(c) {
31744
- const host = (c.req.header("host") ?? "").toLowerCase();
31745
- if (!host) return SUPPORTED_SCOPES;
31746
- const suffix2 = c.req.path.replace(/^\/\.well-known\/(oauth-authorization-server|openid-configuration)/, "");
31747
- const candidate = `https://${host}${suffix2}`.replace(/\/$/, "");
31748
- if (candidate === SCRAPER_RESOURCE()) return SCRAPER_SCOPES;
31749
- if (candidate === RESOURCE().replace(/\/$/, "")) return MEMORY_SCOPES;
31750
- return SUPPORTED_SCOPES;
31751
- }
31752
31744
  function parseAuthParams(get) {
31753
31745
  return {
31754
31746
  response_type: get("response_type") ?? "",
@@ -31823,19 +31815,19 @@ var init_oauth_routes = __esm({
31823
31815
  });
31824
31816
  oauthApp.get("/.well-known/oauth-authorization-server", (c) => {
31825
31817
  console.log("[oauth-dcr] GET /.well-known/oauth-authorization-server ua=%s", c.req.header("user-agent") ?? "");
31826
- return c.json(authServerMetadata(scopesForRequest(c)));
31818
+ return c.json(authServerMetadata());
31827
31819
  });
31828
31820
  oauthApp.get("/.well-known/oauth-authorization-server/*", (c) => {
31829
31821
  console.log("[oauth-dcr] GET %s (path-aware AS) ua=%s", c.req.path, c.req.header("user-agent") ?? "");
31830
- return c.json(authServerMetadata(scopesForRequest(c)));
31822
+ return c.json(authServerMetadata());
31831
31823
  });
31832
31824
  oauthApp.get("/.well-known/openid-configuration", (c) => {
31833
31825
  console.log("[oauth-dcr] GET /.well-known/openid-configuration ua=%s", c.req.header("user-agent") ?? "");
31834
- return c.json(openidConfiguration(scopesForRequest(c)));
31826
+ return c.json(openidConfiguration());
31835
31827
  });
31836
31828
  oauthApp.get("/.well-known/openid-configuration/*", (c) => {
31837
31829
  console.log("[oauth-dcr] GET %s (path-aware OIDC) ua=%s", c.req.path, c.req.header("user-agent") ?? "");
31838
- return c.json(openidConfiguration(scopesForRequest(c)));
31830
+ return c.json(openidConfiguration());
31839
31831
  });
31840
31832
  oauthApp.get("/.well-known/jwks.json", async (c) => {
31841
31833
  const { publicJwk } = await getKeys();
@@ -33299,6 +33291,20 @@ async function entitledVaultRows(identity) {
33299
33291
  }
33300
33292
  return [...seen.values()];
33301
33293
  }
33294
+ async function embedBytesByPhysical(physicals) {
33295
+ const m = /* @__PURE__ */ new Map();
33296
+ try {
33297
+ const rows = await sql().query(
33298
+ `SELECT metadata->>'vault' AS vault, COUNT(*)::bigint AS chunks
33299
+ FROM "memory" WHERE metadata->>'vault' = ANY($1) GROUP BY 1`,
33300
+ [physicals]
33301
+ );
33302
+ for (const r of rows) if (r.vault) m.set(r.vault, Number(r.chunks) * EMBED_BYTES_PER_CHUNK);
33303
+ } catch {
33304
+ return m;
33305
+ }
33306
+ return m;
33307
+ }
33302
33308
  async function storageByPhysical(physicals) {
33303
33309
  if (physicals.length === 0) return /* @__PURE__ */ new Map();
33304
33310
  const rows = await sql().query(
@@ -33306,8 +33312,9 @@ async function storageByPhysical(physicals) {
33306
33312
  FROM mem_notes WHERE vault = ANY($1) GROUP BY vault`,
33307
33313
  [physicals]
33308
33314
  );
33315
+ const embed = await embedBytesByPhysical(physicals);
33309
33316
  const m = /* @__PURE__ */ new Map();
33310
- for (const r of rows) m.set(r.vault, { notes: Number(r.notes), bytes: Number(r.bytes) });
33317
+ for (const r of rows) m.set(r.vault, { notes: Number(r.notes), bytes: Number(r.bytes) + (embed.get(r.vault) ?? 0) });
33311
33318
  return m;
33312
33319
  }
33313
33320
  async function dbListVaults(identity) {
@@ -33420,13 +33427,14 @@ async function dbUsage(identity, plan) {
33420
33427
  unlimited: isUnlimited(plan)
33421
33428
  };
33422
33429
  }
33423
- var import_serverless, _sql, FREE_COST_CAP_USD;
33430
+ var import_serverless, _sql, EMBED_BYTES_PER_CHUNK, FREE_COST_CAP_USD;
33424
33431
  var init_memory_db = __esm({
33425
33432
  "src/api/memory-db.ts"() {
33426
33433
  "use strict";
33427
33434
  import_serverless = require("@neondatabase/serverless");
33428
33435
  init_rates();
33429
33436
  _sql = null;
33437
+ EMBED_BYTES_PER_CHUNK = Number(process.env.JINA_EMBED_DIM ?? 1024) * 4;
33430
33438
  FREE_COST_CAP_USD = 1;
33431
33439
  }
33432
33440
  });