Socket
Socket
Sign inDemoInstall

@lakam99/socks

Package Overview
Dependencies
104
Maintainers
1
Versions
80
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.3.8 to 0.3.9

16

index.d.ts

@@ -86,3 +86,4 @@ import { JaxonSSLConfig } from '../jax.on/src/jax.on';

export type SockErrorMessage = {type: SockMessageType.ERROR, data: {message: string}};
export type SockSesh = {ip: string, pages: InstantiatedSockPageReference[], currentPage: InstantiatedSockPageReference};
export type SockSesh = {ip: string, pages: InstantiatedSockPageReference[], currentPage: InstantiatedSockPageReference, accessToken?: string};
export const $SESSIONS: SockSesh[];

@@ -95,2 +96,9 @@ /**

/**
*
* @param req
* @returns the ip of the request object
*/
export function getRequesterIp(req: Request): string;
export declare class SocksServer {

@@ -110,2 +118,8 @@ /**

protected get_current_page(req: any): SockCurrentPage;
/**
*
* @param ip the ip address assosciated with the sock session
*/
protected get_sesh(ip: string): SockSesh;
}

@@ -112,0 +126,0 @@

4

package.json

@@ -6,3 +6,3 @@ {

"main": "socks.js",
"version": "0.3.8",
"version": "0.3.9",
"devDependencies": {

@@ -23,5 +23,5 @@ "@types/cookie-parser": "^1.4.3",

"dependencies": {
"@lakam99/jax.on": "^0.3.4",
"@lakam99/jax.on": "^0.3.5",
"ts-node": "^10.9.1"
}
}

@@ -31,3 +31,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.SocksServer = exports.SockPage = exports.monitor_prop = exports.SockMessageType = void 0;
exports.SocksServer = exports.SockPage = exports.monitor_prop = exports.$SESSIONS = exports.SockMessageType = void 0;
const fs_1 = require("fs");

@@ -47,2 +47,3 @@ const ws_1 = require("ws");

;
exports.$SESSIONS = [];
function monitor_prop(writable = true) {

@@ -169,3 +170,2 @@ return function (target, prop) {

constructor(port = 8080, source_code_path, ssl = undefined) {
this.sessions = [];
if (ssl) {

@@ -181,6 +181,6 @@ this.constructor.init_ssl_jax(ssl);

socket.on('close', () => {
const sesh = this.get_sesh(getSocketIp(socket));
if (sesh) {
//this.sessions.splice(this.sessions.indexOf(sesh), 1);
}
// const sesh = this.get_sesh(getSocketIp(socket));
// if (sesh) {
// $SESSIONS.splice($SESSIONS.indexOf(sesh), 1);
// }
});

@@ -223,3 +223,3 @@ });

const sesh = { ip, currentPage: page, pages: [page] };
this.sessions.push(sesh);
exports.$SESSIONS.push(sesh);
currentPage.setSesh(sesh);

@@ -230,4 +230,4 @@ return sesh;

const page = new pageClass(undefined, this.getTheServer.bind(this));
const pageReference = { page, name: pageName };
const sesh = this.get_sesh(ip);
const pageReference = { page, name: pageName, sesh };
if (sesh) {

@@ -245,3 +245,3 @@ sesh.pages.push(pageReference);

get_sesh(ip = "") {
return this.sessions.find((sesh) => sesh.ip === ip);
return exports.$SESSIONS.find((sesh) => sesh.ip === ip);
}

@@ -248,0 +248,0 @@ get_current_page(req) {

@@ -10,3 +10,3 @@ import {Application, static as _static} from 'express';

export type InstantiatedSockPageReference = {name: string, page: SockPage};
export type SockSesh = {ip: string, pages: InstantiatedSockPageReference[], currentPage: InstantiatedSockPageReference};
export type SockSesh = {ip: string, pages: InstantiatedSockPageReference[], currentPage: InstantiatedSockPageReference, accessToken?: string};
export type SockPageConstructor<T = {}> = new (socket: WebSocket | undefined, socks: (() => Application)) => T;

@@ -37,2 +37,4 @@ type InstantiatedSockPage = SockPageConstructor<SockPage> & { prototype: SockPage };

export const $SESSIONS:SockSesh[] = [];
export function monitor_prop(writable: boolean = true) {

@@ -55,2 +57,15 @@ return function(target: any, prop: string) {

export function get_session_from_ip(ip: string): SockSesh | undefined {
return $SESSIONS.find(sesh => sesh.ip === ip);
}
export function require_auth() {
return function(target: SockPage) {
const sesh = get_session_from_ip(target.getConnectionIP());
if (!sesh?.accessToken?.length) {
target.
}
}
}
function parseHtml(html: string, context: any): string {

@@ -70,3 +85,3 @@ let result:string = '';

function getRequesterIp(req: any): string {
export function getRequesterIp(req: any): string {
return req?.client?.remoteAddress;

@@ -183,3 +198,2 @@ }

private wss: Server;
private sessions: SockSesh[] = [];
private pageNames: string[];

@@ -226,3 +240,3 @@ private source_code_path: string;

const sesh = {ip, currentPage: page, pages: [page]};
this.sessions.push(sesh);
$SESSIONS.push(sesh);
currentPage.setSesh(sesh);

@@ -234,4 +248,4 @@ return sesh;

const page = new pageClass(undefined, this.getTheServer.bind(this));
const pageReference = {page, name: pageName};
const sesh = this.get_sesh(ip);
const pageReference = {page, name: pageName, sesh};
if (sesh) {

@@ -262,6 +276,6 @@ sesh.pages.push(pageReference);

socket.on('close', () => {
const sesh = this.get_sesh(getSocketIp(socket));
if (sesh) {
this.sessions.splice(this.sessions.indexOf(sesh), 1);
}
// const sesh = this.get_sesh(getSocketIp(socket));
// if (sesh) {
// $SESSIONS.splice($SESSIONS.indexOf(sesh), 1);
// }
});

@@ -274,4 +288,4 @@ }

private get_sesh(ip: string = ""): SockSesh | undefined {
return this.sessions.find((sesh: SockSesh) => sesh.ip === ip);
protected get_sesh(ip: string = ""): SockSesh | undefined {
return $SESSIONS.find((sesh: SockSesh) => sesh.ip === ip);
}

@@ -278,0 +292,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc