tls-client-node
Advanced tools
+4
-4
@@ -637,3 +637,3 @@ "use strict"; | ||
| if (this.runtime.mode === "native") { | ||
| this.runtime.native?.destroyAll(); | ||
| await this.runtime.native?.destroyAll(); | ||
| this.runtime = undefined; | ||
@@ -660,6 +660,6 @@ return; | ||
| if (runtime.mode === "native") { | ||
| return runtime.native.getCookiesFromSession({ | ||
| return (await runtime.native.getCookiesFromSession({ | ||
| sessionId, | ||
| url, | ||
| }).cookies; | ||
| })).cookies; | ||
| } | ||
@@ -821,3 +821,3 @@ const response = await this.requestJson("/api/cookies", { | ||
| response = runtime.mode === "native" | ||
| ? runtime.native.request(payload) | ||
| ? await runtime.native.request(payload) | ||
| : await this.requestJson("/api/forward", payload); | ||
@@ -824,0 +824,0 @@ } |
+4
-4
| import { TLSClientOptions } from "./types"; | ||
| export interface NativeClientBinding { | ||
| libraryPath: string; | ||
| request<T>(payload: unknown): T; | ||
| getCookiesFromSession<T>(payload: unknown): T; | ||
| destroySession<T>(payload: unknown): T; | ||
| destroyAll<T>(): T; | ||
| request<T>(payload: unknown): Promise<T>; | ||
| getCookiesFromSession<T>(payload: unknown): Promise<T>; | ||
| destroySession<T>(payload: unknown): Promise<T>; | ||
| destroyAll<T>(): Promise<T>; | ||
| } | ||
| export declare function ensureNativeBinding(options?: TLSClientOptions): Promise<NativeClientBinding>; |
+28
-8
@@ -28,2 +28,22 @@ "use strict"; | ||
| } | ||
| function invokeNativeAsync(operation, fn, ...args) { | ||
| return new Promise((resolve, reject) => { | ||
| fn.async(...args, (error, result) => { | ||
| if (error) { | ||
| reject(new errors_1.TLSClientError(`tls-client native ${operation} failed: ${error.message}`, { | ||
| code: "ERR_NATIVE_CALL_FAILED", | ||
| cause: error, | ||
| })); | ||
| return; | ||
| } | ||
| if (result === undefined) { | ||
| reject(new errors_1.TLSClientError(`tls-client native ${operation} returned no data.`, { | ||
| code: "ERR_NATIVE_EMPTY_RESPONSE", | ||
| })); | ||
| return; | ||
| } | ||
| resolve(result); | ||
| }); | ||
| }); | ||
| } | ||
| async function loadNativeBinding(libraryPath) { | ||
@@ -51,13 +71,13 @@ const existing = bindingCache.get(libraryPath); | ||
| libraryPath, | ||
| request(payload) { | ||
| return parseNativeResponse(rawBinding.request(JSON.stringify(payload)), "request", rawBinding); | ||
| async request(payload) { | ||
| return parseNativeResponse(await invokeNativeAsync("request", rawBinding.request, JSON.stringify(payload)), "request", rawBinding); | ||
| }, | ||
| getCookiesFromSession(payload) { | ||
| return parseNativeResponse(rawBinding.getCookiesFromSession(JSON.stringify(payload)), "getCookiesFromSession", rawBinding); | ||
| async getCookiesFromSession(payload) { | ||
| return parseNativeResponse(await invokeNativeAsync("getCookiesFromSession", rawBinding.getCookiesFromSession, JSON.stringify(payload)), "getCookiesFromSession", rawBinding); | ||
| }, | ||
| destroySession(payload) { | ||
| return parseNativeResponse(rawBinding.destroySession(JSON.stringify(payload)), "destroySession", rawBinding); | ||
| async destroySession(payload) { | ||
| return parseNativeResponse(await invokeNativeAsync("destroySession", rawBinding.destroySession, JSON.stringify(payload)), "destroySession", rawBinding); | ||
| }, | ||
| destroyAll() { | ||
| return parseNativeResponse(rawBinding.destroyAll(), "destroyAll", rawBinding); | ||
| async destroyAll() { | ||
| return parseNativeResponse(await invokeNativeAsync("destroyAll", rawBinding.destroyAll), "destroyAll", rawBinding); | ||
| }, | ||
@@ -64,0 +84,0 @@ }; |
+1
-1
| { | ||
| "name": "tls-client-node", | ||
| "version": "0.1.8", | ||
| "version": "0.1.9", | ||
| "description": "Node.js client for bogdanfinn/tls-client with native shared-library loading and optional managed runtime support.", | ||
@@ -5,0 +5,0 @@ "author": "Fatih Kabak", |
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
111425
0.89%2262
0.89%