Closed levi-nz closed 2 months ago
I'm working on a project using this library right now and have made my own file with these functions using ffi-rs, anyone is welcome to use this instead. The example should be replaced with something similar IMO.
import {DataType, load, open} from "ffi-rs";
const LIBRARY_NAME = "tls-client";
open({
library: LIBRARY_NAME,
path: "./tls-client.so"
});
export function request(requestData) {
return JSON.parse(load({
library: LIBRARY_NAME,
funcName: "request",
retType: DataType.String,
paramsType: [DataType.String],
paramsValue: [JSON.stringify(requestData)]
}));
}
export function freeMemory(id) {
load({
library: LIBRARY_NAME,
funcName: "freeMemory",
retType: DataType.Void,
paramsType: [DataType.String],
paramsValue: [id]
});
}
export function getCookiesFromSession(requestData) {
return JSON.parse(load({
library: LIBRARY_NAME,
funcName: "getCookiesFromSession",
retType: DataType.String,
paramsType: [DataType.String],
paramsValue: [JSON.stringify(requestData)]
}));
}
export function addCookiesToSession(cookieData) {
return JSON.parse(load({
library: LIBRARY_NAME,
funcName: "addCookiesToSession",
retType: DataType.String,
paramsType: [DataType.String],
paramsValue: [JSON.stringify(cookieData)]
}));
}
export function destroySession(sessionId) {
return JSON.parse(load({
library: LIBRARY_NAME,
funcName: "destroySession",
retType: DataType.String,
paramsType: [DataType.String],
paramsValue: [JSON.stringify({sessionId})]
}));
}
Thank you very much for the contribution. https://github.com/bogdanfinn/tls-client/blob/master/cffi_dist/example_node/index_ffi_rs.js
TLS client version
v1.7.2
System information
Ubuntu 22.04 LTS
Issue description
The current node example found here: https://github.com/bogdanfinn/tls-client/blob/f53719acd0e9ff02c2965d9c8b6f21bc049efb12/cffi_dist/example_node/index.js
Uses the outdated
ffi-napi
package, which has not been maintained in 2 years and is broken on newer Node versions on Linux and Mac, and requires Visual Studio installation on Windows. ffi-rs or another modern library should be used instead.Related issue: https://github.com/node-ffi-napi/node-ffi-napi/issues/269
Steps to reproduce / Code Sample
Run node example on Mac or Linux using a modern Node version, will result in a C error