@nocobase/plugin-multi-app-manager 2.0.0-beta.9 → 2.0.1
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.
- package/dist/client/{db3a142b120d6553.js → 00b71fff3c8c7167.js} +1 -1
- package/dist/client/Migrate.d.ts +10 -0
- package/dist/client/index.js +1 -1
- package/dist/externalVersion.js +7 -7
- package/dist/locale/en-US.json +3 -2
- package/dist/locale/zh-CN.json +3 -2
- package/dist/node_modules/p-queue/dist/index.d.ts +101 -0
- package/dist/node_modules/p-queue/dist/index.js +1 -0
- package/dist/node_modules/p-queue/dist/lower-bound.d.ts +1 -0
- package/dist/node_modules/p-queue/dist/lower-bound.js +21 -0
- package/dist/node_modules/p-queue/dist/options.d.ts +64 -0
- package/dist/node_modules/p-queue/dist/options.js +2 -0
- package/dist/node_modules/p-queue/dist/priority-queue.d.ts +12 -0
- package/dist/node_modules/p-queue/dist/priority-queue.js +32 -0
- package/dist/node_modules/p-queue/dist/queue.d.ts +7 -0
- package/dist/node_modules/p-queue/dist/queue.js +2 -0
- package/dist/node_modules/p-queue/license +9 -0
- package/dist/node_modules/p-queue/node_modules/eventemitter3/index.d.ts +134 -0
- package/dist/node_modules/p-queue/node_modules/eventemitter3/index.js +336 -0
- package/dist/node_modules/p-queue/node_modules/eventemitter3/package.json +56 -0
- package/dist/node_modules/p-queue/node_modules/eventemitter3/umd/eventemitter3.js +340 -0
- package/dist/node_modules/p-queue/node_modules/eventemitter3/umd/eventemitter3.min.js +1 -0
- package/dist/node_modules/p-queue/package.json +1 -0
- package/dist/server/adapters/legacy-adapter.d.ts +43 -0
- package/dist/server/adapters/legacy-adapter.js +207 -0
- package/dist/server/server.d.ts +4 -6
- package/dist/server/server.js +38 -191
- package/package.json +2 -2
- package/dist/node_modules/mariadb/LICENSE +0 -502
- package/dist/node_modules/mariadb/callback.js +0 -41
- package/dist/node_modules/mariadb/lib/cmd/batch-bulk.js +0 -278
- package/dist/node_modules/mariadb/lib/cmd/batch-rewrite.js +0 -372
- package/dist/node_modules/mariadb/lib/cmd/change-user.js +0 -149
- package/dist/node_modules/mariadb/lib/cmd/class/ok-packet.js +0 -17
- package/dist/node_modules/mariadb/lib/cmd/column-definition.js +0 -102
- package/dist/node_modules/mariadb/lib/cmd/command.js +0 -168
- package/dist/node_modules/mariadb/lib/cmd/common-binary-cmd.js +0 -327
- package/dist/node_modules/mariadb/lib/cmd/common-text-cmd.js +0 -427
- package/dist/node_modules/mariadb/lib/cmd/handshake/auth/caching-sha2-password-auth.js +0 -168
- package/dist/node_modules/mariadb/lib/cmd/handshake/auth/clear-password-auth.js +0 -23
- package/dist/node_modules/mariadb/lib/cmd/handshake/auth/ed25519-password-auth.js +0 -761
- package/dist/node_modules/mariadb/lib/cmd/handshake/auth/native-password-auth.js +0 -55
- package/dist/node_modules/mariadb/lib/cmd/handshake/auth/pam-password-auth.js +0 -58
- package/dist/node_modules/mariadb/lib/cmd/handshake/auth/plugin-auth.js +0 -19
- package/dist/node_modules/mariadb/lib/cmd/handshake/auth/sha256-password-auth.js +0 -142
- package/dist/node_modules/mariadb/lib/cmd/handshake/client-capabilities.js +0 -74
- package/dist/node_modules/mariadb/lib/cmd/handshake/client-handshake-response.js +0 -126
- package/dist/node_modules/mariadb/lib/cmd/handshake/handshake.js +0 -292
- package/dist/node_modules/mariadb/lib/cmd/handshake/initial-handshake.js +0 -74
- package/dist/node_modules/mariadb/lib/cmd/handshake/ssl-request.js +0 -29
- package/dist/node_modules/mariadb/lib/cmd/ping.js +0 -52
- package/dist/node_modules/mariadb/lib/cmd/query.js +0 -255
- package/dist/node_modules/mariadb/lib/cmd/quit.js +0 -28
- package/dist/node_modules/mariadb/lib/cmd/reset.js +0 -54
- package/dist/node_modules/mariadb/lib/cmd/resultset.js +0 -607
- package/dist/node_modules/mariadb/lib/cmd/stream.js +0 -45
- package/dist/node_modules/mariadb/lib/config/connection-options.js +0 -258
- package/dist/node_modules/mariadb/lib/config/pool-cluster-options.js +0 -19
- package/dist/node_modules/mariadb/lib/config/pool-options.js +0 -47
- package/dist/node_modules/mariadb/lib/connection-callback.js +0 -160
- package/dist/node_modules/mariadb/lib/connection.js +0 -1460
- package/dist/node_modules/mariadb/lib/const/capabilities.js +0 -64
- package/dist/node_modules/mariadb/lib/const/collations.js +0 -473
- package/dist/node_modules/mariadb/lib/const/connection_status.js +0 -13
- package/dist/node_modules/mariadb/lib/const/error-code.js +0 -1282
- package/dist/node_modules/mariadb/lib/const/field-detail.js +0 -35
- package/dist/node_modules/mariadb/lib/const/field-type.js +0 -71
- package/dist/node_modules/mariadb/lib/const/server-status.js +0 -30
- package/dist/node_modules/mariadb/lib/const/state-change.js +0 -12
- package/dist/node_modules/mariadb/lib/filtered-pool-cluster.js +0 -81
- package/dist/node_modules/mariadb/lib/io/bulk-packet.js +0 -590
- package/dist/node_modules/mariadb/lib/io/compression-input-stream.js +0 -141
- package/dist/node_modules/mariadb/lib/io/compression-output-stream.js +0 -171
- package/dist/node_modules/mariadb/lib/io/packet-input-stream.js +0 -193
- package/dist/node_modules/mariadb/lib/io/packet-node-encoded.js +0 -36
- package/dist/node_modules/mariadb/lib/io/packet-node-iconv.js +0 -37
- package/dist/node_modules/mariadb/lib/io/packet-output-stream.js +0 -502
- package/dist/node_modules/mariadb/lib/io/packet.js +0 -515
- package/dist/node_modules/mariadb/lib/io/rewrite-packet.js +0 -481
- package/dist/node_modules/mariadb/lib/misc/connection-information.js +0 -96
- package/dist/node_modules/mariadb/lib/misc/errors.js +0 -123
- package/dist/node_modules/mariadb/lib/misc/parse.js +0 -1033
- package/dist/node_modules/mariadb/lib/misc/utils.js +0 -298
- package/dist/node_modules/mariadb/lib/pool-base.js +0 -611
- package/dist/node_modules/mariadb/lib/pool-callback.js +0 -202
- package/dist/node_modules/mariadb/lib/pool-cluster-callback.js +0 -66
- package/dist/node_modules/mariadb/lib/pool-cluster.js +0 -407
- package/dist/node_modules/mariadb/lib/pool-promise.js +0 -108
- package/dist/node_modules/mariadb/node_modules/@types/node/assert/strict.d.ts +0 -8
- package/dist/node_modules/mariadb/node_modules/@types/node/assert.d.ts +0 -912
- package/dist/node_modules/mariadb/node_modules/@types/node/async_hooks.d.ts +0 -501
- package/dist/node_modules/mariadb/node_modules/@types/node/buffer.d.ts +0 -2232
- package/dist/node_modules/mariadb/node_modules/@types/node/child_process.d.ts +0 -1366
- package/dist/node_modules/mariadb/node_modules/@types/node/cluster.d.ts +0 -414
- package/dist/node_modules/mariadb/node_modules/@types/node/console.d.ts +0 -412
- package/dist/node_modules/mariadb/node_modules/@types/node/constants.d.ts +0 -18
- package/dist/node_modules/mariadb/node_modules/@types/node/crypto.d.ts +0 -3338
- package/dist/node_modules/mariadb/node_modules/@types/node/dgram.d.ts +0 -545
- package/dist/node_modules/mariadb/node_modules/@types/node/diagnostics_channel.d.ts +0 -152
- package/dist/node_modules/mariadb/node_modules/@types/node/dns/promises.d.ts +0 -370
- package/dist/node_modules/mariadb/node_modules/@types/node/dns.d.ts +0 -659
- package/dist/node_modules/mariadb/node_modules/@types/node/domain.d.ts +0 -169
- package/dist/node_modules/mariadb/node_modules/@types/node/events.d.ts +0 -651
- package/dist/node_modules/mariadb/node_modules/@types/node/fs/promises.d.ts +0 -1091
- package/dist/node_modules/mariadb/node_modules/@types/node/fs.d.ts +0 -3869
- package/dist/node_modules/mariadb/node_modules/@types/node/globals.d.ts +0 -294
- package/dist/node_modules/mariadb/node_modules/@types/node/globals.global.d.ts +0 -1
- package/dist/node_modules/mariadb/node_modules/@types/node/http.d.ts +0 -1396
- package/dist/node_modules/mariadb/node_modules/@types/node/http2.d.ts +0 -2101
- package/dist/node_modules/mariadb/node_modules/@types/node/https.d.ts +0 -391
- package/dist/node_modules/mariadb/node_modules/@types/node/index.d.ts +0 -129
- package/dist/node_modules/mariadb/node_modules/@types/node/inspector.d.ts +0 -2744
- package/dist/node_modules/mariadb/node_modules/@types/node/module.d.ts +0 -114
- package/dist/node_modules/mariadb/node_modules/@types/node/net.d.ts +0 -791
- package/dist/node_modules/mariadb/node_modules/@types/node/os.d.ts +0 -455
- package/dist/node_modules/mariadb/node_modules/@types/node/package.json +0 -220
- package/dist/node_modules/mariadb/node_modules/@types/node/path.d.ts +0 -180
- package/dist/node_modules/mariadb/node_modules/@types/node/perf_hooks.d.ts +0 -557
- package/dist/node_modules/mariadb/node_modules/@types/node/process.d.ts +0 -1481
- package/dist/node_modules/mariadb/node_modules/@types/node/punycode.d.ts +0 -117
- package/dist/node_modules/mariadb/node_modules/@types/node/querystring.d.ts +0 -131
- package/dist/node_modules/mariadb/node_modules/@types/node/readline.d.ts +0 -650
- package/dist/node_modules/mariadb/node_modules/@types/node/repl.d.ts +0 -424
- package/dist/node_modules/mariadb/node_modules/@types/node/stream/consumers.d.ts +0 -24
- package/dist/node_modules/mariadb/node_modules/@types/node/stream/promises.d.ts +0 -42
- package/dist/node_modules/mariadb/node_modules/@types/node/stream/web.d.ts +0 -330
- package/dist/node_modules/mariadb/node_modules/@types/node/stream.d.ts +0 -1249
- package/dist/node_modules/mariadb/node_modules/@types/node/string_decoder.d.ts +0 -67
- package/dist/node_modules/mariadb/node_modules/@types/node/timers/promises.d.ts +0 -68
- package/dist/node_modules/mariadb/node_modules/@types/node/timers.d.ts +0 -94
- package/dist/node_modules/mariadb/node_modules/@types/node/tls.d.ts +0 -1020
- package/dist/node_modules/mariadb/node_modules/@types/node/trace_events.d.ts +0 -161
- package/dist/node_modules/mariadb/node_modules/@types/node/tty.d.ts +0 -204
- package/dist/node_modules/mariadb/node_modules/@types/node/url.d.ts +0 -891
- package/dist/node_modules/mariadb/node_modules/@types/node/util.d.ts +0 -1594
- package/dist/node_modules/mariadb/node_modules/@types/node/v8.d.ts +0 -378
- package/dist/node_modules/mariadb/node_modules/@types/node/vm.d.ts +0 -507
- package/dist/node_modules/mariadb/node_modules/@types/node/wasi.d.ts +0 -158
- package/dist/node_modules/mariadb/node_modules/@types/node/worker_threads.d.ts +0 -649
- package/dist/node_modules/mariadb/node_modules/@types/node/zlib.d.ts +0 -517
- package/dist/node_modules/mariadb/package.json +0 -1
- package/dist/node_modules/mariadb/promise.js +0 -34
- package/dist/node_modules/mariadb/types/index.d.ts +0 -870
|
@@ -1,427 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const ResultSet = require('./resultset');
|
|
4
|
-
const FieldDetail = require('../const/field-detail');
|
|
5
|
-
const FieldType = require('../const/field-type');
|
|
6
|
-
const Long = require('long');
|
|
7
|
-
const moment = require('moment-timezone');
|
|
8
|
-
const QUOTE = 0x27;
|
|
9
|
-
|
|
10
|
-
class CommonText extends ResultSet {
|
|
11
|
-
constructor(resolve, reject, cmdOpts, connOpts, sql, values) {
|
|
12
|
-
super(resolve, reject);
|
|
13
|
-
this.configAssign(connOpts, cmdOpts);
|
|
14
|
-
this.sql = sql;
|
|
15
|
-
this.initialValues = values;
|
|
16
|
-
this.getDateQuote = this.opts.tz
|
|
17
|
-
? this.opts.tz === 'Etc/UTC'
|
|
18
|
-
? CommonText.getUtcDate
|
|
19
|
-
: CommonText.getTimezoneDate
|
|
20
|
-
: CommonText.getLocalDate;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Write (and escape) current parameter value to output writer
|
|
25
|
-
*
|
|
26
|
-
* @param out output writer
|
|
27
|
-
* @param value current parameter
|
|
28
|
-
* @param opts connection options
|
|
29
|
-
* @param info connection information
|
|
30
|
-
*/
|
|
31
|
-
writeParam(out, value, opts, info) {
|
|
32
|
-
switch (typeof value) {
|
|
33
|
-
case 'boolean':
|
|
34
|
-
out.writeStringAscii(value ? 'true' : 'false');
|
|
35
|
-
break;
|
|
36
|
-
case 'bigint':
|
|
37
|
-
case 'number':
|
|
38
|
-
out.writeStringAscii('' + value);
|
|
39
|
-
break;
|
|
40
|
-
case 'object':
|
|
41
|
-
if (value === null) {
|
|
42
|
-
out.writeStringAscii('NULL');
|
|
43
|
-
} else if (Object.prototype.toString.call(value) === '[object Date]') {
|
|
44
|
-
out.writeStringAscii(this.getDateQuote(value, opts));
|
|
45
|
-
} else if (Buffer.isBuffer(value)) {
|
|
46
|
-
out.writeStringAscii("_BINARY '");
|
|
47
|
-
out.writeBufferEscape(value);
|
|
48
|
-
out.writeInt8(QUOTE);
|
|
49
|
-
} else if (typeof value.toSqlString === 'function') {
|
|
50
|
-
out.writeStringEscapeQuote(String(value.toSqlString()));
|
|
51
|
-
} else if (Long.isLong(value)) {
|
|
52
|
-
out.writeStringAscii(value.toString());
|
|
53
|
-
} else if (Array.isArray(value)) {
|
|
54
|
-
if (opts.arrayParenthesis) {
|
|
55
|
-
out.writeStringAscii('(');
|
|
56
|
-
}
|
|
57
|
-
for (let i = 0; i < value.length; i++) {
|
|
58
|
-
if (i !== 0) out.writeStringAscii(',');
|
|
59
|
-
this.writeParam(out, value[i], opts, info);
|
|
60
|
-
}
|
|
61
|
-
if (opts.arrayParenthesis) {
|
|
62
|
-
out.writeStringAscii(')');
|
|
63
|
-
}
|
|
64
|
-
} else {
|
|
65
|
-
if (
|
|
66
|
-
value.type != null &&
|
|
67
|
-
[
|
|
68
|
-
'Point',
|
|
69
|
-
'LineString',
|
|
70
|
-
'Polygon',
|
|
71
|
-
'MultiPoint',
|
|
72
|
-
'MultiLineString',
|
|
73
|
-
'MultiPolygon',
|
|
74
|
-
'GeometryCollection'
|
|
75
|
-
].includes(value.type)
|
|
76
|
-
) {
|
|
77
|
-
//GeoJSON format.
|
|
78
|
-
let prefix =
|
|
79
|
-
(info.isMariaDB() && info.hasMinVersion(10, 1, 4)) ||
|
|
80
|
-
(!info.isMariaDB() && info.hasMinVersion(5, 7, 6))
|
|
81
|
-
? 'ST_'
|
|
82
|
-
: '';
|
|
83
|
-
switch (value.type) {
|
|
84
|
-
case 'Point':
|
|
85
|
-
out.writeStringAscii(
|
|
86
|
-
prefix +
|
|
87
|
-
"PointFromText('POINT(" +
|
|
88
|
-
CommonText.geoPointToString(value.coordinates) +
|
|
89
|
-
")')"
|
|
90
|
-
);
|
|
91
|
-
break;
|
|
92
|
-
|
|
93
|
-
case 'LineString':
|
|
94
|
-
out.writeStringAscii(
|
|
95
|
-
prefix +
|
|
96
|
-
"LineFromText('LINESTRING(" +
|
|
97
|
-
CommonText.geoArrayPointToString(value.coordinates) +
|
|
98
|
-
")')"
|
|
99
|
-
);
|
|
100
|
-
break;
|
|
101
|
-
|
|
102
|
-
case 'Polygon':
|
|
103
|
-
out.writeStringAscii(
|
|
104
|
-
prefix +
|
|
105
|
-
"PolygonFromText('POLYGON(" +
|
|
106
|
-
CommonText.geoMultiArrayPointToString(value.coordinates) +
|
|
107
|
-
")')"
|
|
108
|
-
);
|
|
109
|
-
break;
|
|
110
|
-
|
|
111
|
-
case 'MultiPoint':
|
|
112
|
-
out.writeStringAscii(
|
|
113
|
-
prefix +
|
|
114
|
-
"MULTIPOINTFROMTEXT('MULTIPOINT(" +
|
|
115
|
-
CommonText.geoArrayPointToString(value.coordinates) +
|
|
116
|
-
")')"
|
|
117
|
-
);
|
|
118
|
-
break;
|
|
119
|
-
|
|
120
|
-
case 'MultiLineString':
|
|
121
|
-
out.writeStringAscii(
|
|
122
|
-
prefix +
|
|
123
|
-
"MLineFromText('MULTILINESTRING(" +
|
|
124
|
-
CommonText.geoMultiArrayPointToString(value.coordinates) +
|
|
125
|
-
")')"
|
|
126
|
-
);
|
|
127
|
-
break;
|
|
128
|
-
|
|
129
|
-
case 'MultiPolygon':
|
|
130
|
-
out.writeStringAscii(
|
|
131
|
-
prefix +
|
|
132
|
-
"MPolyFromText('MULTIPOLYGON(" +
|
|
133
|
-
CommonText.geoMultiPolygonToString(value.coordinates) +
|
|
134
|
-
")')"
|
|
135
|
-
);
|
|
136
|
-
break;
|
|
137
|
-
|
|
138
|
-
case 'GeometryCollection':
|
|
139
|
-
out.writeStringAscii(
|
|
140
|
-
prefix +
|
|
141
|
-
"GeomCollFromText('GEOMETRYCOLLECTION(" +
|
|
142
|
-
CommonText.geometricCollectionToString(value.geometries) +
|
|
143
|
-
")')"
|
|
144
|
-
);
|
|
145
|
-
break;
|
|
146
|
-
}
|
|
147
|
-
} else {
|
|
148
|
-
if (opts.permitSetMultiParamEntries) {
|
|
149
|
-
let first = true;
|
|
150
|
-
for (let key in value) {
|
|
151
|
-
const val = value[key];
|
|
152
|
-
if (typeof val === 'function') continue;
|
|
153
|
-
if (first) {
|
|
154
|
-
first = false;
|
|
155
|
-
} else {
|
|
156
|
-
out.writeStringAscii(',');
|
|
157
|
-
}
|
|
158
|
-
out.writeString('`' + key + '`');
|
|
159
|
-
out.writeStringAscii('=');
|
|
160
|
-
this.writeParam(out, val, opts, info);
|
|
161
|
-
}
|
|
162
|
-
if (first) out.writeStringEscapeQuote(JSON.stringify(value));
|
|
163
|
-
} else {
|
|
164
|
-
out.writeStringEscapeQuote(JSON.stringify(value));
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
break;
|
|
169
|
-
default:
|
|
170
|
-
out.writeStringEscapeQuote(value);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
static geometricCollectionToString(geo) {
|
|
175
|
-
if (!geo) return '';
|
|
176
|
-
let st = '';
|
|
177
|
-
for (let i = 0; i < geo.length; i++) {
|
|
178
|
-
//GeoJSON format.
|
|
179
|
-
st += i !== 0 ? ',' : '';
|
|
180
|
-
switch (geo[i].type) {
|
|
181
|
-
case 'Point':
|
|
182
|
-
st += 'POINT(' + CommonText.geoPointToString(geo[i].coordinates) + ')';
|
|
183
|
-
break;
|
|
184
|
-
|
|
185
|
-
case 'LineString':
|
|
186
|
-
st += 'LINESTRING(' + CommonText.geoArrayPointToString(geo[i].coordinates) + ')';
|
|
187
|
-
break;
|
|
188
|
-
|
|
189
|
-
case 'Polygon':
|
|
190
|
-
st += 'POLYGON(' + CommonText.geoMultiArrayPointToString(geo[i].coordinates) + ')';
|
|
191
|
-
break;
|
|
192
|
-
|
|
193
|
-
case 'MultiPoint':
|
|
194
|
-
st += 'MULTIPOINT(' + CommonText.geoArrayPointToString(geo[i].coordinates) + ')';
|
|
195
|
-
break;
|
|
196
|
-
|
|
197
|
-
case 'MultiLineString':
|
|
198
|
-
st +=
|
|
199
|
-
'MULTILINESTRING(' + CommonText.geoMultiArrayPointToString(geo[i].coordinates) + ')';
|
|
200
|
-
break;
|
|
201
|
-
|
|
202
|
-
case 'MultiPolygon':
|
|
203
|
-
st += 'MULTIPOLYGON(' + CommonText.geoMultiPolygonToString(geo[i].coordinates) + ')';
|
|
204
|
-
break;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
return st;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
static geoMultiPolygonToString(coords) {
|
|
211
|
-
if (!coords) return '';
|
|
212
|
-
let st = '';
|
|
213
|
-
for (let i = 0; i < coords.length; i++) {
|
|
214
|
-
st += (i !== 0 ? ',(' : '(') + CommonText.geoMultiArrayPointToString(coords[i]) + ')';
|
|
215
|
-
}
|
|
216
|
-
return st;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
static geoMultiArrayPointToString(coords) {
|
|
220
|
-
if (!coords) return '';
|
|
221
|
-
let st = '';
|
|
222
|
-
for (let i = 0; i < coords.length; i++) {
|
|
223
|
-
st += (i !== 0 ? ',(' : '(') + CommonText.geoArrayPointToString(coords[i]) + ')';
|
|
224
|
-
}
|
|
225
|
-
return st;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
static geoArrayPointToString(coords) {
|
|
229
|
-
if (!coords) return '';
|
|
230
|
-
let st = '';
|
|
231
|
-
for (let i = 0; i < coords.length; i++) {
|
|
232
|
-
st += (i !== 0 ? ',' : '') + CommonText.geoPointToString(coords[i]);
|
|
233
|
-
}
|
|
234
|
-
return st;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
static geoPointToString(coords) {
|
|
238
|
-
if (!coords) return '';
|
|
239
|
-
return (isNaN(coords[0]) ? '' : coords[0]) + ' ' + (isNaN(coords[1]) ? '' : coords[1]);
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
parseRowAsArray(columns, packet, connOpts) {
|
|
243
|
-
const row = new Array(this._columnCount);
|
|
244
|
-
for (let i = 0; i < this._columnCount; i++) {
|
|
245
|
-
row[i] = this._getValue(i, columns[i], this.opts, connOpts, packet);
|
|
246
|
-
}
|
|
247
|
-
return row;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
parseRowNested(columns, packet, connOpts) {
|
|
251
|
-
const row = {};
|
|
252
|
-
for (let i = 0; i < this._columnCount; i++) {
|
|
253
|
-
if (!row[this.tableHeader[i][0]]) row[this.tableHeader[i][0]] = {};
|
|
254
|
-
row[this.tableHeader[i][0]][this.tableHeader[i][1]] = this._getValue(
|
|
255
|
-
i,
|
|
256
|
-
columns[i],
|
|
257
|
-
this.opts,
|
|
258
|
-
connOpts,
|
|
259
|
-
packet
|
|
260
|
-
);
|
|
261
|
-
}
|
|
262
|
-
return row;
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
parseRowStd(columns, packet, connOpts) {
|
|
266
|
-
const row = {};
|
|
267
|
-
for (let i = 0; i < this._columnCount; i++) {
|
|
268
|
-
row[this.tableHeader[i]] = this._getValue(i, columns[i], this.opts, connOpts, packet);
|
|
269
|
-
}
|
|
270
|
-
return row;
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
castTextWrapper(column, opts, connOpts, packet) {
|
|
274
|
-
column.string = () => packet.readStringLength();
|
|
275
|
-
column.buffer = () => packet.readBufferLengthEncoded();
|
|
276
|
-
column.float = () => packet.readFloatLengthCoded();
|
|
277
|
-
column.int = () => packet.readIntLengthEncoded();
|
|
278
|
-
column.long = () =>
|
|
279
|
-
packet.readLongLengthEncoded(
|
|
280
|
-
opts.supportBigInt,
|
|
281
|
-
opts.supportBigNumbers,
|
|
282
|
-
opts.bigNumberStrings,
|
|
283
|
-
(column.flags & FieldDetail.UNSIGNED) > 0
|
|
284
|
-
);
|
|
285
|
-
column.decimal = () => packet.readDecimalLengthEncoded(opts.bigNumberStrings);
|
|
286
|
-
column.date = () => packet.readDateTime(opts);
|
|
287
|
-
column.geometry = () => {
|
|
288
|
-
return column.readGeometry();
|
|
289
|
-
};
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
readCastValue(index, column, opts, connOpts, packet) {
|
|
293
|
-
this.castTextWrapper(column, opts, connOpts, packet);
|
|
294
|
-
return opts.typeCast(
|
|
295
|
-
column,
|
|
296
|
-
this.readRowData.bind(this, index, column, opts, connOpts, packet)
|
|
297
|
-
);
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
/**
|
|
301
|
-
* Read row data.
|
|
302
|
-
*
|
|
303
|
-
* @param index current data index in row
|
|
304
|
-
* @param column associate metadata
|
|
305
|
-
* @param opts query options
|
|
306
|
-
* @param connOpts connection options
|
|
307
|
-
* @param packet row packet
|
|
308
|
-
* @returns {*} data
|
|
309
|
-
*/
|
|
310
|
-
readRowData(index, column, opts, connOpts, packet) {
|
|
311
|
-
switch (column.columnType) {
|
|
312
|
-
case FieldType.TINY:
|
|
313
|
-
case FieldType.SHORT:
|
|
314
|
-
case FieldType.LONG:
|
|
315
|
-
case FieldType.INT24:
|
|
316
|
-
case FieldType.YEAR:
|
|
317
|
-
return packet.readIntLengthEncoded();
|
|
318
|
-
case FieldType.FLOAT:
|
|
319
|
-
case FieldType.DOUBLE:
|
|
320
|
-
return packet.readFloatLengthCoded();
|
|
321
|
-
case FieldType.LONGLONG:
|
|
322
|
-
return packet.readLongLengthEncoded(
|
|
323
|
-
opts.supportBigInt,
|
|
324
|
-
opts.supportBigNumbers,
|
|
325
|
-
opts.bigNumberStrings,
|
|
326
|
-
(column.flags & FieldDetail.UNSIGNED) > 0
|
|
327
|
-
);
|
|
328
|
-
case FieldType.DECIMAL:
|
|
329
|
-
case FieldType.NEWDECIMAL:
|
|
330
|
-
return packet.readDecimalLengthEncoded(opts.bigNumberStrings);
|
|
331
|
-
case FieldType.DATE:
|
|
332
|
-
if (opts.dateStrings) {
|
|
333
|
-
return packet.readAsciiStringLengthEncoded();
|
|
334
|
-
}
|
|
335
|
-
return packet.readDate();
|
|
336
|
-
case FieldType.DATETIME:
|
|
337
|
-
case FieldType.TIMESTAMP:
|
|
338
|
-
if (opts.dateStrings) {
|
|
339
|
-
return packet.readAsciiStringLengthEncoded();
|
|
340
|
-
}
|
|
341
|
-
return packet.readDateTime(opts);
|
|
342
|
-
case FieldType.TIME:
|
|
343
|
-
return packet.readAsciiStringLengthEncoded();
|
|
344
|
-
case FieldType.GEOMETRY:
|
|
345
|
-
return packet.readGeometry(column.dataTypeName);
|
|
346
|
-
case FieldType.JSON:
|
|
347
|
-
//for mysql only => parse string as JSON object
|
|
348
|
-
return JSON.parse(packet.readStringLengthEncoded('utf8'));
|
|
349
|
-
|
|
350
|
-
default:
|
|
351
|
-
if (column.dataTypeFormat && column.dataTypeFormat === 'json' && opts.autoJsonMap) {
|
|
352
|
-
return JSON.parse(packet.readStringLengthEncoded('utf8'));
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
if (column.collation.index === 63) {
|
|
356
|
-
return packet.readBufferLengthEncoded();
|
|
357
|
-
}
|
|
358
|
-
const string = packet.readStringLength();
|
|
359
|
-
if (column.flags & 2048) {
|
|
360
|
-
//SET
|
|
361
|
-
return string == null ? null : string === '' ? [] : string.split(',');
|
|
362
|
-
}
|
|
363
|
-
return string;
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
function getDatePartQuote(year, mon, day, hour, min, sec, ms) {
|
|
369
|
-
//return 'YYYY-MM-DD HH:MM:SS' datetime format
|
|
370
|
-
//see https://mariadb.com/kb/en/library/datetime/
|
|
371
|
-
return (
|
|
372
|
-
"'" +
|
|
373
|
-
(year > 999 ? year : year > 99 ? '0' + year : year > 9 ? '00' + year : '000' + year) +
|
|
374
|
-
'-' +
|
|
375
|
-
(mon < 10 ? '0' : '') +
|
|
376
|
-
mon +
|
|
377
|
-
'-' +
|
|
378
|
-
(day < 10 ? '0' : '') +
|
|
379
|
-
day +
|
|
380
|
-
' ' +
|
|
381
|
-
(hour < 10 ? '0' : '') +
|
|
382
|
-
hour +
|
|
383
|
-
':' +
|
|
384
|
-
(min < 10 ? '0' : '') +
|
|
385
|
-
min +
|
|
386
|
-
':' +
|
|
387
|
-
(sec < 10 ? '0' : '') +
|
|
388
|
-
sec +
|
|
389
|
-
'.' +
|
|
390
|
-
(ms > 99 ? ms : ms > 9 ? '0' + ms : '00' + ms) +
|
|
391
|
-
"'"
|
|
392
|
-
);
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
function getLocalDate(date, opts) {
|
|
396
|
-
const year = date.getFullYear();
|
|
397
|
-
const mon = date.getMonth() + 1;
|
|
398
|
-
const day = date.getDate();
|
|
399
|
-
const hour = date.getHours();
|
|
400
|
-
const min = date.getMinutes();
|
|
401
|
-
const sec = date.getSeconds();
|
|
402
|
-
const ms = date.getMilliseconds();
|
|
403
|
-
return getDatePartQuote(year, mon, day, hour, min, sec, ms);
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
function getUtcDate(date, opts) {
|
|
407
|
-
const year = date.getUTCFullYear();
|
|
408
|
-
const mon = date.getUTCMonth() + 1;
|
|
409
|
-
const day = date.getUTCDate();
|
|
410
|
-
const hour = date.getUTCHours();
|
|
411
|
-
const min = date.getUTCMinutes();
|
|
412
|
-
const sec = date.getUTCSeconds();
|
|
413
|
-
const ms = date.getUTCMilliseconds();
|
|
414
|
-
return getDatePartQuote(year, mon, day, hour, min, sec, ms);
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
function getTimezoneDate(date, opts) {
|
|
418
|
-
if (date.getMilliseconds() != 0) {
|
|
419
|
-
return moment.tz(date, opts.tz).format("'YYYY-MM-DD HH:mm:ss.SSS'");
|
|
420
|
-
}
|
|
421
|
-
return moment.tz(date, opts.tz).format("'YYYY-MM-DD HH:mm:ss'");
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
module.exports = CommonText;
|
|
425
|
-
module.exports.getTimezoneDate = getTimezoneDate;
|
|
426
|
-
module.exports.getUtcDate = getUtcDate;
|
|
427
|
-
module.exports.getLocalDate = getLocalDate;
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
const PluginAuth = require('./plugin-auth');
|
|
2
|
-
const fs = require('fs');
|
|
3
|
-
const crypto = require('crypto');
|
|
4
|
-
const Errors = require('../../../misc/errors');
|
|
5
|
-
const NativePasswordAuth = require('./native-password-auth');
|
|
6
|
-
const Sha256PasswordAuth = require('./sha256-password-auth');
|
|
7
|
-
|
|
8
|
-
const State = {
|
|
9
|
-
INIT: 'INIT',
|
|
10
|
-
FAST_AUTH_RESULT: 'FAST_AUTH_RESULT',
|
|
11
|
-
REQUEST_SERVER_KEY: 'REQUEST_SERVER_KEY',
|
|
12
|
-
SEND_AUTH: 'SEND_AUTH'
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Use caching Sha2 password authentication
|
|
17
|
-
*/
|
|
18
|
-
class CachingSha2PasswordAuth extends PluginAuth {
|
|
19
|
-
constructor(packSeq, compressPackSeq, pluginData, resolve, reject, multiAuthResolver) {
|
|
20
|
-
super(resolve, reject, multiAuthResolver);
|
|
21
|
-
this.pluginData = pluginData;
|
|
22
|
-
this.sequenceNo = packSeq;
|
|
23
|
-
this.counter = 0;
|
|
24
|
-
this.state = State.INIT;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
start(out, opts, info) {
|
|
28
|
-
this.exchange(this.pluginData, out, opts, info);
|
|
29
|
-
this.onPacketReceive = this.response;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
exchange(buffer, out, opts, info) {
|
|
33
|
-
switch (this.state) {
|
|
34
|
-
case State.INIT:
|
|
35
|
-
const truncatedSeed = this.pluginData.slice(0, this.pluginData.length - 1);
|
|
36
|
-
const encPwd = NativePasswordAuth.encryptPassword(opts.password, truncatedSeed, 'sha256');
|
|
37
|
-
out.startPacket(this);
|
|
38
|
-
if (encPwd.length > 0) {
|
|
39
|
-
out.writeBuffer(encPwd, 0, encPwd.length);
|
|
40
|
-
out.flushBuffer(true);
|
|
41
|
-
} else {
|
|
42
|
-
out.writeEmptyPacket(true);
|
|
43
|
-
}
|
|
44
|
-
this.state = State.FAST_AUTH_RESULT;
|
|
45
|
-
return;
|
|
46
|
-
|
|
47
|
-
case State.FAST_AUTH_RESULT:
|
|
48
|
-
// length encoded numeric : 0x01 0x03/0x04
|
|
49
|
-
const fastAuthResult = buffer[1];
|
|
50
|
-
switch (fastAuthResult) {
|
|
51
|
-
case 0x03:
|
|
52
|
-
// success authentication
|
|
53
|
-
this.emit('send_end');
|
|
54
|
-
return this.successSend(packet, out, opts, info);
|
|
55
|
-
|
|
56
|
-
case 0x04:
|
|
57
|
-
if (opts.ssl) {
|
|
58
|
-
// using SSL, so sending password in clear
|
|
59
|
-
out.startPacket(this);
|
|
60
|
-
out.writeString(opts.password);
|
|
61
|
-
out.writeInt8(0);
|
|
62
|
-
out.flushBuffer(true);
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// retrieve public key from configuration or from server
|
|
67
|
-
if (opts.cachingRsaPublicKey) {
|
|
68
|
-
try {
|
|
69
|
-
let key = opts.cachingRsaPublicKey;
|
|
70
|
-
if (!key.includes('-----BEGIN')) {
|
|
71
|
-
// rsaPublicKey contain path
|
|
72
|
-
key = fs.readFileSync(key, 'utf8');
|
|
73
|
-
}
|
|
74
|
-
this.publicKey = Sha256PasswordAuth.retreivePublicKey(key);
|
|
75
|
-
} catch (err) {
|
|
76
|
-
return this.throwError(err, info);
|
|
77
|
-
}
|
|
78
|
-
// send Sha256Password Packet
|
|
79
|
-
Sha256PasswordAuth.sendSha256PwdPacket(
|
|
80
|
-
this,
|
|
81
|
-
this.pluginData,
|
|
82
|
-
this.publicKey,
|
|
83
|
-
opts.password,
|
|
84
|
-
out
|
|
85
|
-
);
|
|
86
|
-
} else {
|
|
87
|
-
if (!opts.allowPublicKeyRetrieval) {
|
|
88
|
-
return this.throwError(
|
|
89
|
-
Errors.createError(
|
|
90
|
-
'RSA public key is not available client side. Either set option `cachingRsaPublicKey` to indicate' +
|
|
91
|
-
' public key path, or allow public key retrieval with option `allowPublicKeyRetrieval`',
|
|
92
|
-
null,
|
|
93
|
-
true,
|
|
94
|
-
info,
|
|
95
|
-
'08S01',
|
|
96
|
-
Errors.ER_CANNOT_RETRIEVE_RSA_KEY
|
|
97
|
-
),
|
|
98
|
-
info
|
|
99
|
-
);
|
|
100
|
-
}
|
|
101
|
-
this.state = State.REQUEST_SERVER_KEY;
|
|
102
|
-
// ask caching public Key Retrieval
|
|
103
|
-
out.startPacket(this);
|
|
104
|
-
out.writeInt8(0x02);
|
|
105
|
-
out.flushBuffer(true);
|
|
106
|
-
}
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
case State.REQUEST_SERVER_KEY:
|
|
111
|
-
this.publicKey = Sha256PasswordAuth.retreivePublicKey(buffer.toString('utf8', 1));
|
|
112
|
-
this.state = State.SEND_AUTH;
|
|
113
|
-
Sha256PasswordAuth.sendSha256PwdPacket(
|
|
114
|
-
this,
|
|
115
|
-
this.pluginData,
|
|
116
|
-
this.publicKey,
|
|
117
|
-
opts.password,
|
|
118
|
-
out
|
|
119
|
-
);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
static retreivePublicKey(key) {
|
|
124
|
-
return key.replace('(-+BEGIN PUBLIC KEY-+\\r?\\n|\\n?-+END PUBLIC KEY-+\\r?\\n?)', '');
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
static sendSha256PwdPacket(cmd, pluginData, publicKey, password, out) {
|
|
128
|
-
const truncatedSeed = pluginData.slice(0, pluginData.length - 1);
|
|
129
|
-
out.startPacket(cmd);
|
|
130
|
-
const enc = Sha256PasswordAuth.encrypt(truncatedSeed, password, publicKey);
|
|
131
|
-
out.writeBuffer(enc, 0, enc.length);
|
|
132
|
-
out.flushBuffer(cmd);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
// encrypt password with public key
|
|
136
|
-
static encrypt(seed, password, publicKey) {
|
|
137
|
-
const nullFinishedPwd = Buffer.from(password + '\0');
|
|
138
|
-
const xorBytes = Buffer.allocUnsafe(nullFinishedPwd.length);
|
|
139
|
-
const seedLength = seed.length;
|
|
140
|
-
for (let i = 0; i < xorBytes.length; i++) {
|
|
141
|
-
xorBytes[i] = nullFinishedPwd[i] ^ seed[i % seedLength];
|
|
142
|
-
}
|
|
143
|
-
return crypto.publicEncrypt(
|
|
144
|
-
{ key: publicKey, padding: crypto.constants.RSA_PKCS1_OAEP_PADDING },
|
|
145
|
-
xorBytes
|
|
146
|
-
);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
response(packet, out, opts, info) {
|
|
150
|
-
const marker = packet.peek();
|
|
151
|
-
switch (marker) {
|
|
152
|
-
//*********************************************************************************************************
|
|
153
|
-
//* OK_Packet and Err_Packet ending packet
|
|
154
|
-
//*********************************************************************************************************
|
|
155
|
-
case 0x00:
|
|
156
|
-
case 0xff:
|
|
157
|
-
this.emit('send_end');
|
|
158
|
-
return this.successSend(packet, out, opts, info);
|
|
159
|
-
|
|
160
|
-
default:
|
|
161
|
-
let promptData = packet.readBufferRemaining();
|
|
162
|
-
this.exchange(promptData, out, opts, info);
|
|
163
|
-
this.onPacketReceive = this.response;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
module.exports = CachingSha2PasswordAuth;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
const PluginAuth = require('./plugin-auth');
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Send password in clear.
|
|
5
|
-
* (used only when SSL is active)
|
|
6
|
-
*/
|
|
7
|
-
class ClearPasswordAuth extends PluginAuth {
|
|
8
|
-
constructor(packSeq, compressPackSeq, pluginData, resolve, reject, multiAuthResolver) {
|
|
9
|
-
super(resolve, reject, multiAuthResolver);
|
|
10
|
-
this.sequenceNo = packSeq;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
start(out, opts, info) {
|
|
14
|
-
out.startPacket(this);
|
|
15
|
-
if (opts.password) out.writeString(opts.password);
|
|
16
|
-
out.writeInt8(0);
|
|
17
|
-
out.flushBuffer(true);
|
|
18
|
-
this.emit('send_end');
|
|
19
|
-
this.onPacketReceive = this.successSend;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
module.exports = ClearPasswordAuth;
|