@fastls/fastls 0.12.0 → 0.13.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
@@ -21,7 +21,7 @@ const h3 = new Session({ httpVersion: 'h3' });
21
21
  try { await h3.get('https://example.com'); } finally { await h3.closeAsync(); }
22
22
  ```
23
23
 
24
- Node.js 22+ 的 Fastls C ABI v1 绑定,提供 Promise API、TypeScript 声明、ESM 和 CommonJS 入口。本文对应 **0.12.0**。
24
+ Node.js 22+ 的 Fastls C ABI v1 绑定,提供 Promise API、TypeScript 声明、ESM 和 CommonJS 入口。本文对应 **0.13.0**。
25
25
 
26
26
  支持 HTTP/1.1、HTTP/2、流式上传下载、双工、SSE、WebSocket、会话 Cookie 和 HTTP/HTTPS/SOCKS 代理。网络请求由 Go 执行,通过 Koffi 在当前 Node 进程中调用;使用者无需 Python 或 RPC 服务。
27
27
 
@@ -37,7 +37,7 @@ Node.js 22+ 的 Fastls C ABI v1 绑定,提供 Promise API、TypeScript 声明
37
37
  安装指定版本:
38
38
 
39
39
  ```sh
40
- npm install @fastls/fastls@0.12.0
40
+ npm install @fastls/fastls@0.13.0
41
41
  ```
42
42
 
43
43
  主包通过同版本的可选依赖自动安装当前平台的 Fastls 原生库。保留 optional dependencies;支持 Windows x64、Linux glibc x64/arm64、macOS x64/arm64。Linux musl 和其它架构没有内置包。具体系统最低版本见原生包的 `native/manifest.json`。
@@ -404,3 +404,5 @@ JavaScript无法强行中断任意Promise:取消会立即释放原生请求,
404
404
  ## 动态库选择与安装排错
405
405
 
406
406
  加载优先级:显式 SessionOptions.library → FASTLS_LIBRARY → 包内 manifest → 同版本平台可选依赖;源码目录可回退仓库 dist,已安装 thin 包不回退仓库。普通 npm 用户应保留 optionalDependencies,不必设置外部库路径。外部旧库可能覆盖新包,ABI 号相同也不保证扩展能力相同。Linux glibc 与 macOS 最低版本、摘要及动态依赖以 native/manifest.json 为准。更多排错见 [在线帮助](https://fasttls.github.io/help/)。
407
+
408
+ `ProfileSpec.fromFingerprints(base, { ja3, h2 })` 使用 Go 共用的离线转换器,返回经校验的完整 Spec;支持现有 Session/fetch 和 ProfileStore。详细[中文说明](https://github.com/FastTLS/fastls-ffi/blob/main/FINGERPRINTS.zh-CN.md) · [English contract](https://github.com/FastTLS/fastls-ffi/blob/main/FINGERPRINTS.md)。
package/dist/native.d.ts CHANGED
@@ -38,6 +38,7 @@ export declare class Native {
38
38
  static load(library?: string): Native;
39
39
  private constructor();
40
40
  call<T = unknown>(name: string, ...args: unknown[]): T;
41
+ adaptProfile(input: unknown): Record<string, unknown>;
41
42
  start(input: unknown): bigint;
42
43
  requireCapabilities(required: readonly string[]): void;
43
44
  wsStart(input: unknown): bigint;
package/dist/native.js CHANGED
@@ -104,6 +104,12 @@ class Native {
104
104
  this.functions.read = lib.func("int fastls_read(uint64_t handle, _Out_ void *buffer, size_t capacity, _Out_ size_t *length)");
105
105
  this.functions.write = lib.func("int fastls_write(uint64_t handle, const void *buffer, size_t length, int end)");
106
106
  const features = new Set(this.call("features"));
107
+ if (features.has("fingerprint_adapter_v1")) {
108
+ try {
109
+ this.functions.profile_adapt = lib.func("void *fastls_profile_adapt(void *json, size_t length)");
110
+ }
111
+ catch { /* Reject use below; old HTTP operations remain available. */ }
112
+ }
107
113
  if (features.has("transport_options_v1")) {
108
114
  try {
109
115
  this.functions.transport_create_with_options = lib.func("void *fastls_transport_create_with_options(void *json, size_t length)");
@@ -169,6 +175,16 @@ class Native {
169
175
  }
170
176
  return envelope.result;
171
177
  }
178
+ adaptProfile(input) {
179
+ this.requireCapabilities(["fingerprint_adapter_v1", "profile_spec_v1"]);
180
+ if (!this.functions.profile_adapt) {
181
+ const error = new errors_js_1.FastlsError("native fingerprint adapter symbol is unavailable");
182
+ error.code = "unsupported_capability";
183
+ throw error;
184
+ }
185
+ const raw = encodeNativeJSON(input);
186
+ return this.call("profile_adapt", raw, raw.length);
187
+ }
172
188
  start(input) {
173
189
  const raw = encodeNativeJSON(input);
174
190
  return asHandle(this.call("start", raw, raw.length));
@@ -10,5 +10,10 @@ export interface AddressPolicy {
10
10
  export declare class ProfileSpec {
11
11
  private readonly snapshot;
12
12
  constructor(value: Readonly<Record<string, unknown>>);
13
+ static fromFingerprints(base: ProfileSpec, options: {
14
+ ja3?: string;
15
+ h2?: string;
16
+ library?: string;
17
+ }): ProfileSpec;
13
18
  toJSON(): Record<string, unknown>;
14
19
  }
package/dist/profiles.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ProfileSpec = void 0;
4
+ const native_js_1 = require("./native.js");
4
5
  /** Explicit snapshot of a complete schema-v1 profile, validated by the core. */
5
6
  class ProfileSpec {
6
7
  snapshot;
@@ -11,6 +12,16 @@ class ProfileSpec {
11
12
  if (Buffer.byteLength(this.snapshot) > 256 * 1024)
12
13
  throw new RangeError("profileSpec exceeds 256KiB");
13
14
  }
15
+ static fromFingerprints(base, options) {
16
+ if (!(base instanceof ProfileSpec))
17
+ throw new TypeError("base must be ProfileSpec");
18
+ const { ja3 = "", h2 = "", library } = options;
19
+ if (typeof ja3 !== "string" || typeof h2 !== "string")
20
+ throw new TypeError("ja3 and h2 must be strings");
21
+ if (Object.keys(options).some(key => !["ja3", "h2", "library"].includes(key)))
22
+ throw new TypeError("unknown fingerprint option");
23
+ return new ProfileSpec(native_js_1.Native.load(library).adaptProfile({ schema_version: 1, base: base.toJSON(), ja3, h2 }));
24
+ }
14
25
  toJSON() { return JSON.parse(this.snapshot); }
15
26
  }
16
27
  exports.ProfileSpec = ProfileSpec;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fastls/fastls",
3
- "version": "0.12.0",
3
+ "version": "0.13.0",
4
4
  "description": "Node.js bindings for the Fastls C ABI",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -35,10 +35,10 @@
35
35
  "registry": "https://registry.npmjs.org/"
36
36
  },
37
37
  "optionalDependencies": {
38
- "@fastls/fastls-win32-x64": "0.12.0",
39
- "@fastls/fastls-linux-x64-glibc": "0.12.0",
40
- "@fastls/fastls-linux-arm64-glibc": "0.12.0",
41
- "@fastls/fastls-darwin-x64": "0.12.0",
42
- "@fastls/fastls-darwin-arm64": "0.12.0"
38
+ "@fastls/fastls-win32-x64": "0.13.0",
39
+ "@fastls/fastls-linux-x64-glibc": "0.13.0",
40
+ "@fastls/fastls-linux-arm64-glibc": "0.13.0",
41
+ "@fastls/fastls-darwin-x64": "0.13.0",
42
+ "@fastls/fastls-darwin-arm64": "0.13.0"
43
43
  }
44
44
  }