Socket
Socket
Sign inDemoInstall

@mtcute/socks-proxy

Package Overview
Dependencies
57
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.7.0 to 0.8.0

3

cjs/index.d.ts

@@ -1,3 +0,2 @@

import { IntermediatePacketCodec, tl } from '@mtcute/core';
import { BaseTcpTransport } from '@mtcute/core/network/transports/tcp.js';
import { BaseTcpTransport, IntermediatePacketCodec, tl } from '@mtcute/node';
/**

@@ -4,0 +3,0 @@ * An error has occurred while connecting to an SOCKS proxy

"use strict";
// ^^ because of this._socket. we know it's not null, almost everywhere, but TS doesn't
Object.defineProperty(exports, "__esModule", { value: true });

@@ -9,5 +8,5 @@ exports.SocksTcpTransport = exports.BaseSocksTcpTransport = exports.SocksProxyConnectionError = void 0;

const net_1 = require("net");
const core_1 = require("@mtcute/core");
const tcp_js_1 = require("@mtcute/core/network/transports/tcp.js");
const utils_js_1 = require("@mtcute/core/utils.js");
const node_1 = require("@mtcute/node");
const utils_js_1 = require("@mtcute/node/utils.js");
const p = new node_1.NodePlatform();
/**

@@ -26,3 +25,3 @@ * An error has occurred while connecting to an SOCKS proxy

if (parts.length !== 4) {
throw new core_1.MtArgumentError('Invalid IPv4 address');
throw new node_1.MtArgumentError('Invalid IPv4 address');
}

@@ -32,3 +31,3 @@ for (let i = 0; i < 4; i++) {

if (isNaN(n) || n < 0 || n > 255) {
throw new core_1.MtArgumentError('Invalid IPv4 address');
throw new node_1.MtArgumentError('Invalid IPv4 address');
}

@@ -39,3 +38,3 @@ buf[offset + i] = n;

function buildSocks4ConnectRequest(ip, port, username = '') {
const userId = (0, utils_js_1.utf8EncodeToBuffer)(username);
const userId = p.utf8Encode(username);
const buf = new Uint8Array(9 + userId.length);

@@ -65,9 +64,9 @@ buf[0] = 0x04; // VER

function buildSocks5Auth(username, password) {
const usernameBuf = (0, utils_js_1.utf8EncodeToBuffer)(username);
const passwordBuf = (0, utils_js_1.utf8EncodeToBuffer)(password);
const usernameBuf = p.utf8Encode(username);
const passwordBuf = p.utf8Encode(password);
if (usernameBuf.length > 255) {
throw new core_1.MtArgumentError(`Too long username (${usernameBuf.length} > 255)`);
throw new node_1.MtArgumentError(`Too long username (${usernameBuf.length} > 255)`);
}
if (passwordBuf.length > 255) {
throw new core_1.MtArgumentError(`Too long password (${passwordBuf.length} > 255)`);
throw new node_1.MtArgumentError(`Too long password (${passwordBuf.length} > 255)`);
}

@@ -87,3 +86,3 @@ const buf = new Uint8Array(3 + usernameBuf.length + passwordBuf.length);

if (parts.length !== 8) {
throw new core_1.MtArgumentError('Invalid IPv6 address');
throw new node_1.MtArgumentError('Invalid IPv6 address');
}

@@ -94,3 +93,3 @@ const dv = (0, utils_js_1.dataViewFromBuffer)(buf);

if (isNaN(n) || n < 0 || n > 0xffff) {
throw new core_1.MtArgumentError('Invalid IPv6 address');
throw new node_1.MtArgumentError('Invalid IPv6 address');
}

@@ -136,3 +135,3 @@ dv.setUint16(j, n, false);

*/
class BaseSocksTcpTransport extends tcp_js_1.BaseTcpTransport {
class BaseSocksTcpTransport extends node_1.BaseTcpTransport {
constructor(proxy) {

@@ -146,4 +145,4 @@ super();

connect(dc) {
if (this._state !== core_1.TransportState.Idle) {
throw new core_1.MtArgumentError('Transport is not IDLE');
if (this._state !== node_1.TransportState.Idle) {
throw new node_1.MtArgumentError('Transport is not IDLE');
}

@@ -155,3 +154,3 @@ if (!this.packetCodecInitialized) {

}
this._state = core_1.TransportState.Connecting;
this._state = node_1.TransportState.Connecting;
this._currentDc = dc;

@@ -279,3 +278,3 @@ this._socket = (0, net_1.connect)(this._proxy.port, this._proxy.host, this._onProxyConnected.bind(this));

default:
(0, core_1.assertNever)(state);
(0, node_1.assertNever)(state);
}

@@ -304,3 +303,3 @@ };

super(...arguments);
this._packetCodec = new core_1.IntermediatePacketCodec();
this._packetCodec = new node_1.IntermediatePacketCodec();
}

@@ -307,0 +306,0 @@ }

@@ -1,3 +0,2 @@

import { IntermediatePacketCodec, tl } from '@mtcute/core';
import { BaseTcpTransport } from '@mtcute/core/network/transports/tcp.js';
import { BaseTcpTransport, IntermediatePacketCodec, tl } from '@mtcute/node';
/**

@@ -4,0 +3,0 @@ * An error has occurred while connecting to an SOCKS proxy

@@ -1,2 +0,1 @@

// ^^ because of this._socket. we know it's not null, almost everywhere, but TS doesn't
// eslint-disable-next-line @typescript-eslint/ban-ts-comment

@@ -6,5 +5,5 @@ // @ts-expect-error

import { connect } from 'net';
import { assertNever, IntermediatePacketCodec, MtArgumentError, TransportState } from '@mtcute/core';
import { BaseTcpTransport } from '@mtcute/core/network/transports/tcp.js';
import { dataViewFromBuffer, utf8EncodeToBuffer } from '@mtcute/core/utils.js';
import { assertNever, BaseTcpTransport, IntermediatePacketCodec, MtArgumentError, NodePlatform, TransportState } from '@mtcute/node';
import { dataViewFromBuffer } from '@mtcute/node/utils.js';
const p = new NodePlatform();
/**

@@ -33,3 +32,3 @@ * An error has occurred while connecting to an SOCKS proxy

function buildSocks4ConnectRequest(ip, port, username = '') {
const userId = utf8EncodeToBuffer(username);
const userId = p.utf8Encode(username);
const buf = new Uint8Array(9 + userId.length);

@@ -59,4 +58,4 @@ buf[0] = 0x04; // VER

function buildSocks5Auth(username, password) {
const usernameBuf = utf8EncodeToBuffer(username);
const passwordBuf = utf8EncodeToBuffer(password);
const usernameBuf = p.utf8Encode(username);
const passwordBuf = p.utf8Encode(password);
if (usernameBuf.length > 255) {

@@ -63,0 +62,0 @@ throw new MtArgumentError(`Too long username (${usernameBuf.length} > 255)`);

{
"name": "@mtcute/socks-proxy",
"version": "0.7.0",
"version": "0.8.0",
"description": "SOCKS4/5 proxy support for mtcute",

@@ -9,5 +9,6 @@ "author": "Alina Sireneva <alina@tei.su>",

"type": "module",
"sideEffects": false,
"scripts": {},
"dependencies": {
"@mtcute/core": "^0.7.0",
"@mtcute/node": "^0.8.0",
"ip6": "0.2.7"

@@ -14,0 +15,0 @@ },

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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