Tarun Koyalwar 36985345a9
javascript bindings + docs generation enhancements ( generate typescript defination .d.ts files) (#4487)
* introduce typescript files generation using ast + tmpl

* feat valid ts with scraping

* feat remove old logic + tsdocs for all modules

* fix ikev and related bugs

* typescript docs for js modules

* lint,build + ldap realm fix

* go mod tidy

* fix named imports ast parsing

* fix ast code generation errors

* complete support for ts files generation

* support go global/const in ts docs

* updated template

* feat: typescript using go code generation

* nuke jsdoc generator

* update generated ts dir structure

* fix multifile ts gen issue

* fix panic in ts code gen

* fix test

* update docs of js libs

* feat: add doc+example for every js class,function,method

* fix missing quotes in ikev example

---------

Co-authored-by: Sandeep Singh <sandeep@projectdiscovery.io>
2024-02-07 21:45:40 +05:30

184 lines
4.3 KiB
TypeScript
Executable File

/**
* Open opens a new connection to the address with a timeout.
* supported protocols: tcp, udp
* @example
* ```javascript
* const net = require('nuclei/net');
* const conn = net.Open('tcp', 'acme.com:80');
* ```
*/
export function Open(protocol: string): NetConn | null {
return null;
}
/**
* Open opens a new connection to the address with a timeout.
* supported protocols: tcp, udp
* @example
* ```javascript
* const net = require('nuclei/net');
* const conn = net.OpenTLS('tcp', 'acme.com:443');
* ```
*/
export function OpenTLS(protocol: string): NetConn | null {
return null;
}
/**
* NetConn is a connection to a remote host.
* this is returned/create by Open and OpenTLS functions.
* @example
* ```javascript
* const net = require('nuclei/net');
* const conn = net.Open('tcp', 'acme.com:80');
* ```
*/
export class NetConn {
// Constructor of NetConn
constructor() {}
/**
* Close closes the connection.
* @example
* ```javascript
* const net = require('nuclei/net');
* const conn = net.Open('tcp', 'acme.com:80');
* conn.Close();
* ```
*/
public Close(): void {
return;
}
/**
* SetTimeout sets read/write timeout for the connection (in seconds).
* @example
* ```javascript
* const net = require('nuclei/net');
* const conn = net.Open('tcp', 'acme.com:80');
* conn.SetTimeout(10);
* ```
*/
public SetTimeout(value: number): void {
return;
}
/**
* SendArray sends array data to connection
* @example
* ```javascript
* const net = require('nuclei/net');
* const conn = net.Open('tcp', 'acme.com:80');
* conn.SendArray(['hello', 'world']);
* ```
*/
public SendArray(data: any): void {
return;
}
/**
* SendHex sends hex data to connection
* @example
* ```javascript
* const net = require('nuclei/net');
* const conn = net.Open('tcp', 'acme.com:80');
* conn.SendHex('68656c6c6f');
* ```
*/
public SendHex(data: string): void {
return;
}
/**
* Send sends data to the connection with a timeout.
* @example
* ```javascript
* const net = require('nuclei/net');
* const conn = net.Open('tcp', 'acme.com:80');
* conn.Send('hello');
* ```
*/
public Send(data: string): void {
return;
}
/**
* Recv receives data from the connection with a timeout.
* If N is 0, it will read all data sent by the server with 8MB limit.
* it tries to read until N bytes or timeout is reached.
* @example
* ```javascript
* const net = require('nuclei/net');
* const conn = net.Open('tcp', 'acme.com:80');
* const data = conn.Recv(1024);
* ```
*/
public Recv(N: number): Uint8Array | null {
return null;
}
/**
* RecvPartial is similar to Recv but it does not perform full read instead
* it creates a buffer of N bytes and returns whatever is returned by the connection
* this is usually used when fingerprinting services to get initial bytes from the server.
* @example
* ```javascript
* const net = require('nuclei/net');
* const conn = net.Open('tcp', 'acme.com:80');
* const data = conn.RecvPartial(1024);
* log(`Received ${data.length} bytes from the server`)
* ```
*/
public RecvPartial(N: number): Uint8Array | null {
return null;
}
/**
* RecvString receives data from the connection with a timeout
* output is returned as a string.
* If N is 0, it will read all data sent by the server with 8MB limit.
* @example
* ```javascript
* const net = require('nuclei/net');
* const conn = net.Open('tcp', 'acme.com:80');
* const data = conn.RecvString(1024);
* ```
*/
public RecvString(N: number): string | null {
return null;
}
/**
* RecvHex receives data from the connection with a timeout
* in hex format.
* If N is 0,it will read all data sent by the server with 8MB limit.
* @example
* ```javascript
* const net = require('nuclei/net');
* const conn = net.Open('tcp', 'acme.com:80');
* const data = conn.RecvHex(1024);
* ```
*/
public RecvHex(N: number): string | null {
return null;
}
}