mysql2 3.9.7 → 3.9.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -36,7 +36,10 @@ function encrypt(password, scramble, key) {
|
|
|
36
36
|
Buffer.from(`${password}\0`, 'utf8'),
|
|
37
37
|
scramble
|
|
38
38
|
);
|
|
39
|
-
return crypto.publicEncrypt(
|
|
39
|
+
return crypto.publicEncrypt({
|
|
40
|
+
key,
|
|
41
|
+
padding: crypto.constants.RSA_PKCS1_OAEP_PADDING
|
|
42
|
+
}, stage1);
|
|
40
43
|
}
|
|
41
44
|
|
|
42
45
|
module.exports = (pluginOptions = {}) => ({ connection }) => {
|
package/lib/helpers.js
CHANGED
|
@@ -73,3 +73,15 @@ const privateObjectProps = new Set([
|
|
|
73
73
|
]);
|
|
74
74
|
|
|
75
75
|
exports.privateObjectProps = privateObjectProps;
|
|
76
|
+
|
|
77
|
+
const fieldEscape = (field) => {
|
|
78
|
+
if (privateObjectProps.has(field)) {
|
|
79
|
+
throw new Error(
|
|
80
|
+
`The field name (${field}) can't be the same as an object's private property.`,
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return srcEscape(field);
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
exports.fieldEscape = fieldEscape;
|
|
@@ -145,22 +145,14 @@ function compile(fields, options, config) {
|
|
|
145
145
|
let tableName = '';
|
|
146
146
|
|
|
147
147
|
for (let i = 0; i < fields.length; i++) {
|
|
148
|
-
fieldName = helpers.
|
|
149
|
-
|
|
150
|
-
if (helpers.privateObjectProps.has(fields[i].name)) {
|
|
151
|
-
throw new Error(
|
|
152
|
-
`The field name (${fieldName}) can't be the same as an object's private property.`,
|
|
153
|
-
);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
parserFn(`// ${fieldName}: ${typeNames[fields[i].columnType]}`);
|
|
148
|
+
fieldName = helpers.fieldEscape(fields[i].name);
|
|
149
|
+
// parserFn(`// ${fieldName}: ${typeNames[fields[i].columnType]}`);
|
|
157
150
|
|
|
158
151
|
if (typeof options.nestTables === 'string') {
|
|
159
|
-
lvalue = `result[${helpers.
|
|
160
|
-
fields[i].table + options.nestTables + fields[i].name,
|
|
161
|
-
)}]`;
|
|
152
|
+
lvalue = `result[${helpers.fieldEscape(fields[i].table + options.nestTables + fields[i].name)}]`;
|
|
162
153
|
} else if (options.nestTables === true) {
|
|
163
|
-
tableName = helpers.
|
|
154
|
+
tableName = helpers.fieldEscape(fields[i].table);
|
|
155
|
+
|
|
164
156
|
parserFn(`if (!result[${tableName}]) result[${tableName}] = {};`);
|
|
165
157
|
lvalue = `result[${tableName}][${fieldName}]`;
|
|
166
158
|
} else if (options.rowsAsArray) {
|
|
@@ -190,7 +182,6 @@ function compile(fields, options, config) {
|
|
|
190
182
|
}
|
|
191
183
|
parserFn('}');
|
|
192
184
|
|
|
193
|
-
|
|
194
185
|
currentFieldNullBit *= 2;
|
|
195
186
|
if (currentFieldNullBit === 0x100) {
|
|
196
187
|
currentFieldNullBit = 1;
|
|
@@ -143,28 +143,24 @@ function compile(fields, options, config) {
|
|
|
143
143
|
}
|
|
144
144
|
resultTablesArray = Object.keys(resultTables);
|
|
145
145
|
for (let i = 0; i < resultTablesArray.length; i++) {
|
|
146
|
-
parserFn(`result[${helpers.
|
|
146
|
+
parserFn(`result[${helpers.fieldEscape(resultTablesArray[i])}] = {};`);
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
let lvalue = '';
|
|
151
151
|
let fieldName = '';
|
|
152
|
+
let tableName = '';
|
|
152
153
|
for (let i = 0; i < fields.length; i++) {
|
|
153
|
-
fieldName = helpers.
|
|
154
|
+
fieldName = helpers.fieldEscape(fields[i].name);
|
|
155
|
+
// parserFn(`// ${fieldName}: ${typeNames[fields[i].columnType]}`);
|
|
154
156
|
|
|
155
|
-
if (helpers.privateObjectProps.has(fields[i].name)) {
|
|
156
|
-
throw new Error(
|
|
157
|
-
`The field name (${fieldName}) can't be the same as an object's private property.`,
|
|
158
|
-
);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
parserFn(`// ${fieldName}: ${typeNames[fields[i].columnType]}`);
|
|
162
157
|
if (typeof options.nestTables === 'string') {
|
|
163
|
-
lvalue = `result[${helpers.
|
|
164
|
-
fields[i].table + options.nestTables + fields[i].name,
|
|
165
|
-
)}]`;
|
|
158
|
+
lvalue = `result[${helpers.fieldEscape(fields[i].table + options.nestTables + fields[i].name)}]`;
|
|
166
159
|
} else if (options.nestTables === true) {
|
|
167
|
-
|
|
160
|
+
tableName = helpers.fieldEscape(fields[i].table);
|
|
161
|
+
|
|
162
|
+
parserFn(`if (!result[${tableName}]) result[${tableName}] = {};`);
|
|
163
|
+
lvalue = `result[${tableName}][${fieldName}]`;
|
|
168
164
|
} else if (options.rowsAsArray) {
|
|
169
165
|
lvalue = `result[${i.toString(10)}]`;
|
|
170
166
|
} else {
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mysql2",
|
|
3
|
-
"version": "3.9.
|
|
3
|
+
"version": "3.9.8",
|
|
4
4
|
"description": "fast mysql driver. Implements core protocol, prepared statements, ssl and compression in native JS",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"typings": "typings/mysql/index",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"lint": "npm run lint:docs && npm run lint:code",
|
|
9
|
-
"lint:code": "eslint index.js promise.js index.d.ts promise.d.ts \"typings/**/*.ts\" \"lib/**/*.js\" \"test/**/*.{js,ts}\" \"benchmarks/**/*.js\"",
|
|
9
|
+
"lint:code": "eslint index.js promise.js index.d.ts promise.d.ts \"typings/**/*.ts\" \"lib/**/*.js\" \"test/**/*.{js,cjs,mjs,ts}\" \"benchmarks/**/*.js\"",
|
|
10
10
|
"lint:docs": "eslint Contributing.md README.md",
|
|
11
11
|
"lint:typings": "npx prettier --check ./typings",
|
|
12
12
|
"lint:tests": "npx prettier --check ./test",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"eslint": "^8.27.0",
|
|
78
78
|
"eslint-config-prettier": "^9.0.0",
|
|
79
79
|
"eslint-plugin-async-await": "0.0.0",
|
|
80
|
-
"eslint-plugin-markdown": "^
|
|
80
|
+
"eslint-plugin-markdown": "^5.0.0",
|
|
81
81
|
"husky": "^9.0.2",
|
|
82
82
|
"lint-staged": "^15.0.1",
|
|
83
83
|
"poku": "^1.8.1",
|
|
@@ -14,7 +14,7 @@ export const authPlugins: {
|
|
|
14
14
|
caching_sha2_password: AuthPluginDefinition<{
|
|
15
15
|
overrideIsSecure?: boolean;
|
|
16
16
|
serverPublicKey?: RsaPublicKey | RsaPrivateKey | KeyLike;
|
|
17
|
-
|
|
17
|
+
onServerPublicKey?: (data: Buffer) => void;
|
|
18
18
|
}>;
|
|
19
19
|
mysql_clear_password: AuthPluginDefinition<{
|
|
20
20
|
password?: string;
|
|
@@ -25,6 +25,6 @@ export const authPlugins: {
|
|
|
25
25
|
}>;
|
|
26
26
|
sha256_password: AuthPluginDefinition<{
|
|
27
27
|
serverPublicKey?: RsaPublicKey | RsaPrivateKey | KeyLike;
|
|
28
|
-
|
|
28
|
+
onServerPublicKey?: (data: Buffer) => void;
|
|
29
29
|
}>;
|
|
30
30
|
};
|