Socket
Socket
Sign inDemoInstall

mysql2

Package Overview
Dependencies
Maintainers
3
Versions
184
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mysql2 - npm Package Compare versions

Comparing version 3.0.1 to 3.1.0

2

index.d.ts

@@ -183,2 +183,4 @@ import {

connectionLimit?: number;
maxIdle?: number;
idleTimeout?: number;
Promise?: any;

@@ -185,0 +187,0 @@ queueLimit?: number;

18

lib/auth_41.js

@@ -44,12 +44,3 @@ 'use strict';

function xor(a, b) {
if (!Buffer.isBuffer(a)) {
a = Buffer.from(a, 'binary');
}
if (!Buffer.isBuffer(b)) {
b = Buffer.from(b, 'binary');
}
const result = Buffer.allocUnsafe(a.length);
for (let i = 0; i < a.length; i++) {

@@ -64,3 +55,2 @@ result[i] = a[i] ^ b[i];

function token(password, scramble1, scramble2) {
// TODO: use buffers (not sure why strings here)
if (!password) {

@@ -99,10 +89,2 @@ return Buffer.alloc(0);

function xorRotating(a, seed) {
if (!Buffer.isBuffer(a)) {
a = Buffer.from(a, 'binary');
}
if (!Buffer.isBuffer(seed)) {
seed = Buffer.from(seed, 'binary');
}
const result = Buffer.allocUnsafe(a.length);

@@ -109,0 +91,0 @@ const seedLen = seed.length;

@@ -20,4 +20,4 @@ 'use strict';

const hash = crypto.createHash('sha256');
hash.update(msg, 'binary');
return hash.digest('binary');
hash.update(msg);
return hash.digest();
}

@@ -29,5 +29,5 @@

}
const stage1 = sha256(Buffer.from(password, 'utf8').toString('binary'));
const stage1 = sha256(Buffer.from(password));
const stage2 = sha256(stage1);
const stage3 = sha256(stage2 + scramble.toString('binary'));
const stage3 = sha256(Buffer.concat([stage2, scramble]));
return xor(stage1, stage3);

@@ -38,4 +38,4 @@ }

const stage1 = xorRotating(
Buffer.from(`${password}\0`, 'utf8').toString('binary'),
scramble.toString('binary')
Buffer.from(`${password}\0`, 'utf8'),
scramble
);

@@ -92,2 +92,3 @@ return crypto.publicEncrypt(key, stage1);

case STATE_WAIT_SERVER_KEY:
console.log('Server pub key:', data);
if (pluginOptions.onServerPublicKey) {

@@ -94,0 +95,0 @@ pluginOptions.onServerPublicKey(data);

@@ -15,4 +15,4 @@ 'use strict';

const stage1 = xorRotating(
Buffer.from(`${password}\0`, 'utf8').toString('binary'),
scramble.toString('binary')
Buffer.from(`${password}\0`, 'utf8'),
scramble
);

@@ -19,0 +19,0 @@ return crypto.publicEncrypt(key, stage1);

@@ -62,2 +62,4 @@ // This file was modified by Oracle on September 21, 2021.

connectionLimit: 1,
maxIdle: 1,
idleTimeout: 1,
Promise: 1,

@@ -93,3 +95,3 @@ queueLimit: 1,

this.host = options.host || 'localhost';
this.port = options.port || 3306;
this.port = (typeof options.port === 'string' ? parseInt(options.port, 10) : options.port)|| 3306;
this.localAddress = options.localAddress;

@@ -257,3 +259,3 @@ this.socketPath = options.socketPath;

host: parsedUrl.hostname,
port: parsedUrl.port,
port: parseInt(parsedUrl.port, 10),
database: parsedUrl.pathname.slice(1),

@@ -260,0 +262,0 @@ user: parsedUrl.username,

@@ -18,2 +18,8 @@ 'use strict';

: Number(options.connectionLimit);
this.maxIdle = isNaN(options.maxIdle)
? this.connectionLimit
: Number(options.maxIdle);
this.idleTimeout = isNaN(options.idleTimeout)
? 60000
: Number(options.idleTimeout);
this.queueLimit = isNaN(options.queueLimit)

@@ -20,0 +26,0 @@ ? 0

@@ -9,2 +9,4 @@ 'use strict';

this._pool = pool;
// The last active time of this connection
this.lastActiveTime = Date.now();
// When a fatal error occurs the connection's protocol ends, which will cause

@@ -26,2 +28,4 @@ // the connection to end as well, thus we only need to watch for the end event

}
// update last active time
this.lastActiveTime = Date.now();
this._pool.releaseConnection(this);

@@ -28,0 +32,0 @@ }

@@ -30,2 +30,6 @@ 'use strict';

this._closed = false;
if (this.config.maxIdle < this.config.connectionLimit) {
// create idle connection timeout automatically release job
this._removeIdleTimeoutConnections();
}
}

@@ -44,3 +48,3 @@

if (this._freeConnections.length > 0) {
connection = this._freeConnections.shift();
connection = this._freeConnections.pop();
this.emit('acquire', connection);

@@ -192,2 +196,22 @@ return process.nextTick(() => cb(null, connection));

_removeIdleTimeoutConnections() {
if (this._removeIdleTimeoutConnectionsTimer) {
clearTimeout(this._removeIdleTimeoutConnectionsTimer);
}
this._removeIdleTimeoutConnectionsTimer = setTimeout(() => {
try {
while (
this._freeConnections.length > this.config.maxIdle &&
Date.now() - this._freeConnections.get(0).lastActiveTime >
this.config.idleTimeout
) {
this._freeConnections.get(0).destroy();
}
} finally {
this._removeIdleTimeoutConnections();
}
}, 1000);
}
format(sql, values) {

@@ -194,0 +218,0 @@ return mysql.format(

{
"name": "mysql2",
"version": "3.0.1",
"version": "3.1.0",
"description": "fast mysql driver. Implements core protocol, prepared statements, ssl and compression in native JS",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -135,2 +135,4 @@ ## Node MySQL 2

connectionLimit: 10,
maxIdle: 10, // max idle connections, the default value is the same as `connectionLimit`
idleTimeout: 60000, // idle connections timeout, in milliseconds, the default value 60000
queueLimit: 0

@@ -137,0 +139,0 @@ });

@@ -30,2 +30,12 @@

/**
* The minimum number of idle connections. (Default: 10)
*/
maxIdle?: number;
/**
* The idle connections timeout, in milliseconds. (Default: 60000)
*/
idleTimeout?: number;
/**
* The maximum number of connection requests the pool will queue before returning an error from getConnection. If set to 0, there

@@ -32,0 +42,0 @@ * is no limit to the number of queued connection requests. (Default: 0)

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc