@celljs/ta-offer 4.39.0 → 4.40.0

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.
@@ -1,5 +1,7 @@
1
- // ../ta-protocol/esm/common/ta-extension-host.js
1
+ // ../ta-protocol/esm/common/host-cloud-protocol.js
2
2
  var TA_CLOUD_OUTPUT_BYTES = 1024 * 1024;
3
+
4
+ // ../ta-protocol/esm/common/ta-extension-host.js
3
5
  var TA_HOST_EVENT = "ta:host";
4
6
  var TaHostUtil;
5
7
  (function(TaHostUtil2) {
package/host/index.mjs CHANGED
@@ -1873,6 +1873,8 @@ class OfferMcpTasks {
1873
1873
 
1874
1874
  // web-src/offer-oauth-util.ts
1875
1875
  import { createHash as createHash3, createHmac, timingSafeEqual } from "node:crypto";
1876
+ import { lookup } from "node:dns/promises";
1877
+ import { BlockList, isIP } from "node:net";
1876
1878
  var MCP_SCOPE = "ask";
1877
1879
  var CLIENT_PREFIX = "ta_ci_";
1878
1880
  var DOCUMENT_BYTES = 1e4;
@@ -1890,6 +1892,32 @@ var json = (status, value, headers = {}) => ({
1890
1892
  headers: { "content-type": "application/json; charset=utf-8", "cache-control": "no-store", ...CORS, ...headers },
1891
1893
  body: JSON.stringify(value)
1892
1894
  });
1895
+ var NOT_PUBLIC = new BlockList;
1896
+ for (const [network, prefix] of [
1897
+ ["0.0.0.0", 8],
1898
+ ["10.0.0.0", 8],
1899
+ ["100.64.0.0", 10],
1900
+ ["127.0.0.0", 8],
1901
+ ["169.254.0.0", 16],
1902
+ ["172.16.0.0", 12],
1903
+ ["192.0.0.0", 24],
1904
+ ["192.168.0.0", 16],
1905
+ ["198.18.0.0", 15],
1906
+ ["224.0.0.0", 4],
1907
+ ["240.0.0.0", 4]
1908
+ ]) {
1909
+ NOT_PUBLIC.addSubnet(network, prefix, "ipv4");
1910
+ }
1911
+ for (const [network, prefix] of [
1912
+ ["::", 127],
1913
+ ["64:ff9b::", 96],
1914
+ ["fc00::", 7],
1915
+ ["fe80::", 10],
1916
+ ["ff00::", 8]
1917
+ ]) {
1918
+ NOT_PUBLIC.addSubnet(network, prefix, "ipv6");
1919
+ }
1920
+ var resolveAll = async (host) => (await lookup(host, { all: true, verbatim: true })).map((one) => one.address);
1893
1921
  var LOOPBACK = new Set(["127.0.0.1", "localhost", "[::1]"]);
1894
1922
  var NOT_APPS = new Set(["javascript:", "data:", "vbscript:", "file:", "blob:", "about:", "ws:", "wss:", "ftp:"]);
1895
1923
  var OfferOAuthUtil;
@@ -1990,7 +2018,7 @@ var OfferOAuthUtil;
1990
2018
  return `${CLIENT_PREFIX}${said}.${sign(secret, said)}`;
1991
2019
  }
1992
2020
  OfferOAuthUtil.register = register;
1993
- async function client(secret, id, read = fetch) {
2021
+ async function client(secret, id, read = fetch, resolve = resolveAll) {
1994
2022
  if (typeof id !== "string" || id.length > 4000) {
1995
2023
  return;
1996
2024
  }
@@ -2006,9 +2034,14 @@ var OfferOAuthUtil;
2006
2034
  return;
2007
2035
  }
2008
2036
  }
2009
- return document(id, read);
2037
+ return document(id, read, resolve);
2010
2038
  }
2011
2039
  OfferOAuthUtil.client = client;
2040
+ function publicAddress(address) {
2041
+ const family = isIP(address);
2042
+ return family !== 0 && !NOT_PUBLIC.check(address, family === 4 ? "ipv4" : "ipv6");
2043
+ }
2044
+ OfferOAuthUtil.publicAddress = publicAddress;
2012
2045
  function verifies(verifier, challenge2) {
2013
2046
  if (typeof verifier !== "string" || !/^[A-Za-z0-9._~-]{43,128}$/.test(verifier)) {
2014
2047
  return false;
@@ -2022,7 +2055,7 @@ var OfferOAuthUtil;
2022
2055
  }
2023
2056
  OfferOAuthUtil.nameOf = nameOf;
2024
2057
  const documents = new Map;
2025
- async function document(id, read) {
2058
+ async function document(id, read, resolve) {
2026
2059
  let url;
2027
2060
  try {
2028
2061
  url = new URL(id);
@@ -2040,6 +2073,10 @@ var OfferOAuthUtil;
2040
2073
  }
2041
2074
  let client2;
2042
2075
  try {
2076
+ const addresses = await resolve(host);
2077
+ if (!addresses.length || !addresses.every(publicAddress)) {
2078
+ throw new Error("Not of the internet.");
2079
+ }
2043
2080
  const answer2 = await read(id, { redirect: "error", signal: AbortSignal.timeout(DOCUMENT_MS), headers: { accept: "application/json" } });
2044
2081
  const text = answer2.ok ? await answer2.text() : "";
2045
2082
  const value = text && text.length <= DOCUMENT_BYTES ? JSON.parse(text) : undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celljs/ta-offer",
3
- "version": "4.39.0",
3
+ "version": "4.40.0",
4
4
  "description": "A pi package for Ta: an agent of yours opened to others by a link, used from a browser, each in a conversation of their own on your models, within plans you set and paid offline or by a code to scan",
5
5
  "keywords": [
6
6
  "pi-package"
@@ -27,8 +27,8 @@
27
27
  "watch": "tsc -b -w --preserveWatchOutput"
28
28
  },
29
29
  "devDependencies": {
30
- "@celljs/ta-protocol": "4.39.0",
31
- "@celljs/ta-web": "4.39.0",
30
+ "@celljs/ta-protocol": "4.40.0",
31
+ "@celljs/ta-web": "4.40.0",
32
32
  "@types/react": "^19.3.0"
33
33
  },
34
34
  "publishConfig": {