proxylang 0.16.0 → 0.17.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.
package/README.md CHANGED
@@ -62,7 +62,7 @@ const sharedCases = (exits: { ai: Exit }) => [
62
62
  ];
63
63
 
64
64
  const laptop = defineProfile({
65
- target: { engine: "surge", platform: "macos", version: "6.11.0" },
65
+ target: { engine: "surge", platform: "macos", version: "6.12.0" },
66
66
  proxies: [edge],
67
67
  groups: [ai],
68
68
  routes: sharedRoutes({ ai }),
@@ -1369,7 +1369,7 @@ function diagnosticView(profile, inspected) {
1369
1369
  }
1370
1370
  // src/model/protocols.ts
1371
1371
  function nodeIsTcpOnly(node, engine) {
1372
- return node.type === "http" || node.type === "anytls" && engine !== "surge" && engine !== "sing-box" || node.type === "vmess" || node.type === "vless" && !(engine === "sing-box" && node.packetEncoding) || engine === "surge" && node.type === "shadowsocks" && node.surge?.udpRelay === false;
1372
+ return node.type === "http" || node.type === "anytls" && engine !== "surge" && engine !== "sing-box" || node.type === "vmess" || node.type === "vless" && engine !== "surge" && !(engine === "sing-box" && node.packetEncoding) || engine === "surge" && node.type === "shadowsocks" && node.surge?.udpRelay === false;
1373
1373
  }
1374
1374
  // src/model/network.ts
1375
1375
  function truthPossibilities(condition, network) {
@@ -1855,7 +1855,25 @@ function surgeProxy(node, secret, name = (id) => id) {
1855
1855
  if (node.transport.host) params.push(`ws-headers=Host:${node.transport.host}`);
1856
1856
  }
1857
1857
  break;
1858
- case "vless": throw new RenderError("PROTOCOL_UNSUPPORTED");
1858
+ case "vless":
1859
+ params.push(`username=${uuid(node.uuid, secret)}`);
1860
+ if (node.flow) params.push(`flow=${node.flow}`);
1861
+ if (node.tls) {
1862
+ if (!node.reality) params.push("tls=true");
1863
+ params.push(`sni=${node.tls.serverName}`);
1864
+ if (!node.reality && node.tls.skipCertVerify !== void 0) params.push(`skip-cert-verify=${node.tls.skipCertVerify}`);
1865
+ const alpn = node.tls.alpn;
1866
+ if (alpn) params.push(`alpn=${alpn.length === 1 ? alpn[0] : `"${alpn.join(",")}"`}`);
1867
+ }
1868
+ if (node.reality) {
1869
+ params.push(`reality-public-key=${node.reality.publicKey}`);
1870
+ if (node.reality.shortId) params.push(`reality-short-id=${node.reality.shortId}`);
1871
+ if (node.utlsFingerprint === "chrome") params.push("client-fingerprint=chromium-155");
1872
+ }
1873
+ if (node.transport) {
1874
+ params.push("ws=true", `ws-path=${node.transport.path}`);
1875
+ if (node.transport.host) params.push(`ws-headers=Host:${node.transport.host}`);
1876
+ }
1859
1877
  }
1860
1878
  if (node.tcpFastOpen !== void 0) params.push(`tfo=${node.tcpFastOpen}`);
1861
1879
  if (node.type === "trojan" || node.type === "anytls" && node.surge?.udpRelay) params.push("udp-relay=true");
@@ -1878,7 +1896,7 @@ function validateProxyOptions(node, target, diagnostics) {
1878
1896
  }
1879
1897
  const tls = "tls" in node ? node.tls : void 0;
1880
1898
  const singBox = target.engine === "sing-box";
1881
- if (node.type === "vless" && !singBox && (node.flow !== void 0 || node.packetEncoding !== void 0 || node.reality !== void 0 || node.utlsFingerprint !== void 0)) diagnostics.push({
1899
+ if (node.type === "vless" && !singBox && target.engine !== "surge" && (node.flow !== void 0 || node.packetEncoding !== void 0 || node.reality !== void 0 || node.utlsFingerprint !== void 0)) diagnostics.push({
1882
1900
  severity: "error",
1883
1901
  code: "PROXY_OPTION_UNSUPPORTED",
1884
1902
  target: target.id,
@@ -1901,7 +1919,23 @@ function validateProxyOptions(node, target, diagnostics) {
1901
1919
  });
1902
1920
  return;
1903
1921
  }
1904
- if (("serverName" in node ? node.serverName : tls?.serverName) === "off" || tls?.alpn !== void 0) diagnostics.push({
1922
+ const name = "serverName" in node ? node.serverName : tls?.serverName;
1923
+ if (node.type === "vless") {
1924
+ const path = `proxies.${node.id}`;
1925
+ const unsupported = (field, message) => diagnostics.push({
1926
+ severity: "error",
1927
+ code: "PROXY_OPTION_UNSUPPORTED",
1928
+ target: target.id,
1929
+ path: `${path}.${field}`,
1930
+ message
1931
+ });
1932
+ if (node.packetEncoding === "packetaddr") unsupported("packetEncoding", "Surge VLESS 仅支持 XUDP");
1933
+ if (node.reality && node.transport) unsupported("transport", "Surge VLESS REALITY 不支持 WebSocket");
1934
+ if (node.reality && tls?.skipCertVerify === true) unsupported("tls.skipCertVerify", "Surge REALITY 由握手验证服务端");
1935
+ if (node.utlsFingerprint && !node.reality) unsupported("utlsFingerprint", "此 Surge 版本仅在 REALITY 使用 Chrome 指纹");
1936
+ if (tls?.alpn && (node.reality || tls.alpn.some((value) => !/^[A-Za-z0-9._/-]+$/.test(value)))) unsupported("tls.alpn", "Surge VLESS ALPN 必须能安全编码,且仅适用于普通 TLS");
1937
+ }
1938
+ if (name === "off" || node.type !== "vless" && tls?.alpn !== void 0) diagnostics.push({
1905
1939
  severity: "error",
1906
1940
  code: "PROXY_OPTION_UNSUPPORTED",
1907
1941
  target: target.id,
@@ -1972,7 +2006,6 @@ function compileSurgeProfile(input) {
1972
2006
  const edges = new Map(resources.map((r) => [r.id, []]));
1973
2007
  const proxyIds = new Set([...p.nodes, ...tunnels].map((n) => n.id));
1974
2008
  for (const node of p.nodes) {
1975
- if (node.type === "vless") error("PROTOCOL_UNSUPPORTED", `proxies.${node.id}`);
1976
2009
  validateProxyOptions(node, {
1977
2010
  id: "profile",
1978
2011
  engine: "surge"
@@ -3008,7 +3041,7 @@ const targetCatalog = deepFreeze([
3008
3041
  },
3009
3042
  {
3010
3043
  engine: "surge",
3011
- version: "5.23.0",
3044
+ version: "6.0.0",
3012
3045
  autoGroup: "surge-smart",
3013
3046
  platforms: ["ios"],
3014
3047
  protocols: [
@@ -3018,7 +3051,8 @@ const targetCatalog = deepFreeze([
3018
3051
  "socks5",
3019
3052
  "anytls",
3020
3053
  "shadowsocks",
3021
- "vmess"
3054
+ "vmess",
3055
+ "vless"
3022
3056
  ],
3023
3057
  endpoints: [],
3024
3058
  groups: [
@@ -3031,7 +3065,7 @@ const targetCatalog = deepFreeze([
3031
3065
  },
3032
3066
  {
3033
3067
  engine: "surge",
3034
- version: "6.11.0",
3068
+ version: "6.12.0",
3035
3069
  autoGroup: "surge-smart",
3036
3070
  platforms: ["macos"],
3037
3071
  protocols: [
@@ -3041,7 +3075,8 @@ const targetCatalog = deepFreeze([
3041
3075
  "socks5",
3042
3076
  "anytls",
3043
3077
  "shadowsocks",
3044
- "vmess"
3078
+ "vmess",
3079
+ "vless"
3045
3080
  ],
3046
3081
  endpoints: [],
3047
3082
  groups: [
package/dist/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { C as definitionDiagnostic, i as targetCatalog } from "./build-Dlv1JO0_.js";
2
+ import { C as definitionDiagnostic, i as targetCatalog } from "./build-WzQKLIE_.js";
3
3
  import { pathToFileURL } from "node:url";
4
4
  import { resolve } from "node:path";
5
5
  import { lstat, open, stat } from "node:fs/promises";
package/dist/index.d.ts CHANGED
@@ -445,11 +445,11 @@ type Fragments<T> = T | readonly Fragments<T>[];
445
445
  type Target = {
446
446
  readonly engine: "surge";
447
447
  readonly platform: "ios";
448
- readonly version: "5.23.0";
448
+ readonly version: "6.0.0";
449
449
  } | {
450
450
  readonly engine: "surge";
451
451
  readonly platform: "macos";
452
- readonly version: "6.11.0";
452
+ readonly version: "6.12.0";
453
453
  } | {
454
454
  readonly engine: "sing-box";
455
455
  readonly platform: "macos" | "linux";
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { S as ProfileDefinitionError, T as inspectDefinition, _ as endpointSchema, a as defineBuild, b as nativeRuleSetSchema, c as dnsRulesSchema, d as tunnelSchema, f as created, g as requireKind, h as parsed, l as conditionSchema, m as inspectRecord, n as runBuild, o as secretSources, p as flatten, r as explainProfile, s as defineProfile, t as checkBuild, u as groupTestSchema, v as idSchema, w as exactDefinition, x as nodeSchema, y as matchSchema } from "./build-Dlv1JO0_.js";
1
+ import { S as ProfileDefinitionError, T as inspectDefinition, _ as endpointSchema, a as defineBuild, b as nativeRuleSetSchema, c as dnsRulesSchema, d as tunnelSchema, f as created, g as requireKind, h as parsed, l as conditionSchema, m as inspectRecord, n as runBuild, o as secretSources, p as flatten, r as explainProfile, s as defineProfile, t as checkBuild, u as groupTestSchema, v as idSchema, w as exactDefinition, x as nodeSchema, y as matchSchema } from "./build-WzQKLIE_.js";
2
2
  import { createHash } from "node:crypto";
3
3
  // src/authoring/resources.ts
4
4
  const builtin = (builtin) => created({ builtin }, "builtin");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "proxylang",
3
- "version": "0.16.0",
3
+ "version": "0.17.0",
4
4
  "description": "Composable routing policies in TypeScript with explicit platform targets",
5
5
  "homepage": "https://github.com/CorrectRoadH/proxylang#readme",
6
6
  "bugs": {