@nocobase/plugin-multi-app-manager 1.2.12-alpha → 1.3.0-alpha.20240710084543

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.
Files changed (175) hide show
  1. package/package.json +2 -2
  2. package/dist/client/AppManager.d.ts +0 -10
  3. package/dist/client/AppNameInput.d.ts +0 -10
  4. package/dist/client/MultiAppManagerProvider.d.ts +0 -10
  5. package/dist/client/MultiAppManagerProvider.style.d.ts +0 -13
  6. package/dist/client/Settings.d.ts +0 -10
  7. package/dist/client/index.d.ts +0 -14
  8. package/dist/client/index.js +0 -10
  9. package/dist/client/settings/schemas/applications.d.ts +0 -18
  10. package/dist/client/utils.d.ts +0 -12
  11. package/dist/externalVersion.js +0 -25
  12. package/dist/index.d.ts +0 -10
  13. package/dist/index.js +0 -48
  14. package/dist/locale/en-US.json +0 -11
  15. package/dist/locale/es-ES.json +0 -9
  16. package/dist/locale/index.d.ts +0 -9
  17. package/dist/locale/index.js +0 -36
  18. package/dist/locale/ko_KR.json +0 -11
  19. package/dist/locale/pt-BR.json +0 -9
  20. package/dist/locale/zh-CN.json +0 -14
  21. package/dist/node_modules/mariadb/LICENSE +0 -502
  22. package/dist/node_modules/mariadb/callback.js +0 -41
  23. package/dist/node_modules/mariadb/lib/cmd/batch-bulk.js +0 -278
  24. package/dist/node_modules/mariadb/lib/cmd/batch-rewrite.js +0 -372
  25. package/dist/node_modules/mariadb/lib/cmd/change-user.js +0 -149
  26. package/dist/node_modules/mariadb/lib/cmd/class/ok-packet.js +0 -17
  27. package/dist/node_modules/mariadb/lib/cmd/column-definition.js +0 -102
  28. package/dist/node_modules/mariadb/lib/cmd/command.js +0 -168
  29. package/dist/node_modules/mariadb/lib/cmd/common-binary-cmd.js +0 -327
  30. package/dist/node_modules/mariadb/lib/cmd/common-text-cmd.js +0 -427
  31. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/caching-sha2-password-auth.js +0 -168
  32. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/clear-password-auth.js +0 -23
  33. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/ed25519-password-auth.js +0 -761
  34. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/native-password-auth.js +0 -55
  35. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/pam-password-auth.js +0 -58
  36. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/plugin-auth.js +0 -19
  37. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/sha256-password-auth.js +0 -142
  38. package/dist/node_modules/mariadb/lib/cmd/handshake/client-capabilities.js +0 -74
  39. package/dist/node_modules/mariadb/lib/cmd/handshake/client-handshake-response.js +0 -126
  40. package/dist/node_modules/mariadb/lib/cmd/handshake/handshake.js +0 -292
  41. package/dist/node_modules/mariadb/lib/cmd/handshake/initial-handshake.js +0 -74
  42. package/dist/node_modules/mariadb/lib/cmd/handshake/ssl-request.js +0 -29
  43. package/dist/node_modules/mariadb/lib/cmd/ping.js +0 -52
  44. package/dist/node_modules/mariadb/lib/cmd/query.js +0 -255
  45. package/dist/node_modules/mariadb/lib/cmd/quit.js +0 -28
  46. package/dist/node_modules/mariadb/lib/cmd/reset.js +0 -54
  47. package/dist/node_modules/mariadb/lib/cmd/resultset.js +0 -607
  48. package/dist/node_modules/mariadb/lib/cmd/stream.js +0 -45
  49. package/dist/node_modules/mariadb/lib/config/connection-options.js +0 -258
  50. package/dist/node_modules/mariadb/lib/config/pool-cluster-options.js +0 -19
  51. package/dist/node_modules/mariadb/lib/config/pool-options.js +0 -47
  52. package/dist/node_modules/mariadb/lib/connection-callback.js +0 -160
  53. package/dist/node_modules/mariadb/lib/connection.js +0 -1460
  54. package/dist/node_modules/mariadb/lib/const/capabilities.js +0 -64
  55. package/dist/node_modules/mariadb/lib/const/collations.js +0 -473
  56. package/dist/node_modules/mariadb/lib/const/connection_status.js +0 -13
  57. package/dist/node_modules/mariadb/lib/const/error-code.js +0 -1282
  58. package/dist/node_modules/mariadb/lib/const/field-detail.js +0 -35
  59. package/dist/node_modules/mariadb/lib/const/field-type.js +0 -71
  60. package/dist/node_modules/mariadb/lib/const/server-status.js +0 -30
  61. package/dist/node_modules/mariadb/lib/const/state-change.js +0 -12
  62. package/dist/node_modules/mariadb/lib/filtered-pool-cluster.js +0 -81
  63. package/dist/node_modules/mariadb/lib/io/bulk-packet.js +0 -590
  64. package/dist/node_modules/mariadb/lib/io/compression-input-stream.js +0 -141
  65. package/dist/node_modules/mariadb/lib/io/compression-output-stream.js +0 -171
  66. package/dist/node_modules/mariadb/lib/io/packet-input-stream.js +0 -193
  67. package/dist/node_modules/mariadb/lib/io/packet-node-encoded.js +0 -36
  68. package/dist/node_modules/mariadb/lib/io/packet-node-iconv.js +0 -37
  69. package/dist/node_modules/mariadb/lib/io/packet-output-stream.js +0 -502
  70. package/dist/node_modules/mariadb/lib/io/packet.js +0 -515
  71. package/dist/node_modules/mariadb/lib/io/rewrite-packet.js +0 -481
  72. package/dist/node_modules/mariadb/lib/misc/connection-information.js +0 -96
  73. package/dist/node_modules/mariadb/lib/misc/errors.js +0 -123
  74. package/dist/node_modules/mariadb/lib/misc/parse.js +0 -1033
  75. package/dist/node_modules/mariadb/lib/misc/utils.js +0 -298
  76. package/dist/node_modules/mariadb/lib/pool-base.js +0 -611
  77. package/dist/node_modules/mariadb/lib/pool-callback.js +0 -202
  78. package/dist/node_modules/mariadb/lib/pool-cluster-callback.js +0 -66
  79. package/dist/node_modules/mariadb/lib/pool-cluster.js +0 -407
  80. package/dist/node_modules/mariadb/lib/pool-promise.js +0 -108
  81. package/dist/node_modules/mariadb/node_modules/@types/node/assert/strict.d.ts +0 -8
  82. package/dist/node_modules/mariadb/node_modules/@types/node/assert.d.ts +0 -912
  83. package/dist/node_modules/mariadb/node_modules/@types/node/async_hooks.d.ts +0 -501
  84. package/dist/node_modules/mariadb/node_modules/@types/node/buffer.d.ts +0 -2232
  85. package/dist/node_modules/mariadb/node_modules/@types/node/child_process.d.ts +0 -1366
  86. package/dist/node_modules/mariadb/node_modules/@types/node/cluster.d.ts +0 -414
  87. package/dist/node_modules/mariadb/node_modules/@types/node/console.d.ts +0 -412
  88. package/dist/node_modules/mariadb/node_modules/@types/node/constants.d.ts +0 -18
  89. package/dist/node_modules/mariadb/node_modules/@types/node/crypto.d.ts +0 -3338
  90. package/dist/node_modules/mariadb/node_modules/@types/node/dgram.d.ts +0 -545
  91. package/dist/node_modules/mariadb/node_modules/@types/node/diagnostics_channel.d.ts +0 -152
  92. package/dist/node_modules/mariadb/node_modules/@types/node/dns/promises.d.ts +0 -370
  93. package/dist/node_modules/mariadb/node_modules/@types/node/dns.d.ts +0 -659
  94. package/dist/node_modules/mariadb/node_modules/@types/node/domain.d.ts +0 -169
  95. package/dist/node_modules/mariadb/node_modules/@types/node/events.d.ts +0 -651
  96. package/dist/node_modules/mariadb/node_modules/@types/node/fs/promises.d.ts +0 -1091
  97. package/dist/node_modules/mariadb/node_modules/@types/node/fs.d.ts +0 -3869
  98. package/dist/node_modules/mariadb/node_modules/@types/node/globals.d.ts +0 -294
  99. package/dist/node_modules/mariadb/node_modules/@types/node/globals.global.d.ts +0 -1
  100. package/dist/node_modules/mariadb/node_modules/@types/node/http.d.ts +0 -1396
  101. package/dist/node_modules/mariadb/node_modules/@types/node/http2.d.ts +0 -2101
  102. package/dist/node_modules/mariadb/node_modules/@types/node/https.d.ts +0 -391
  103. package/dist/node_modules/mariadb/node_modules/@types/node/index.d.ts +0 -129
  104. package/dist/node_modules/mariadb/node_modules/@types/node/inspector.d.ts +0 -2744
  105. package/dist/node_modules/mariadb/node_modules/@types/node/module.d.ts +0 -114
  106. package/dist/node_modules/mariadb/node_modules/@types/node/net.d.ts +0 -791
  107. package/dist/node_modules/mariadb/node_modules/@types/node/os.d.ts +0 -455
  108. package/dist/node_modules/mariadb/node_modules/@types/node/package.json +0 -220
  109. package/dist/node_modules/mariadb/node_modules/@types/node/path.d.ts +0 -180
  110. package/dist/node_modules/mariadb/node_modules/@types/node/perf_hooks.d.ts +0 -557
  111. package/dist/node_modules/mariadb/node_modules/@types/node/process.d.ts +0 -1481
  112. package/dist/node_modules/mariadb/node_modules/@types/node/punycode.d.ts +0 -117
  113. package/dist/node_modules/mariadb/node_modules/@types/node/querystring.d.ts +0 -131
  114. package/dist/node_modules/mariadb/node_modules/@types/node/readline.d.ts +0 -650
  115. package/dist/node_modules/mariadb/node_modules/@types/node/repl.d.ts +0 -424
  116. package/dist/node_modules/mariadb/node_modules/@types/node/stream/consumers.d.ts +0 -24
  117. package/dist/node_modules/mariadb/node_modules/@types/node/stream/promises.d.ts +0 -42
  118. package/dist/node_modules/mariadb/node_modules/@types/node/stream/web.d.ts +0 -330
  119. package/dist/node_modules/mariadb/node_modules/@types/node/stream.d.ts +0 -1249
  120. package/dist/node_modules/mariadb/node_modules/@types/node/string_decoder.d.ts +0 -67
  121. package/dist/node_modules/mariadb/node_modules/@types/node/timers/promises.d.ts +0 -68
  122. package/dist/node_modules/mariadb/node_modules/@types/node/timers.d.ts +0 -94
  123. package/dist/node_modules/mariadb/node_modules/@types/node/tls.d.ts +0 -1020
  124. package/dist/node_modules/mariadb/node_modules/@types/node/trace_events.d.ts +0 -161
  125. package/dist/node_modules/mariadb/node_modules/@types/node/tty.d.ts +0 -204
  126. package/dist/node_modules/mariadb/node_modules/@types/node/url.d.ts +0 -891
  127. package/dist/node_modules/mariadb/node_modules/@types/node/util.d.ts +0 -1594
  128. package/dist/node_modules/mariadb/node_modules/@types/node/v8.d.ts +0 -378
  129. package/dist/node_modules/mariadb/node_modules/@types/node/vm.d.ts +0 -507
  130. package/dist/node_modules/mariadb/node_modules/@types/node/wasi.d.ts +0 -158
  131. package/dist/node_modules/mariadb/node_modules/@types/node/worker_threads.d.ts +0 -649
  132. package/dist/node_modules/mariadb/node_modules/@types/node/zlib.d.ts +0 -517
  133. package/dist/node_modules/mariadb/node_modules/iconv-lite/.github/dependabot.yml +0 -11
  134. package/dist/node_modules/mariadb/node_modules/iconv-lite/.idea/codeStyles/Project.xml +0 -47
  135. package/dist/node_modules/mariadb/node_modules/iconv-lite/.idea/codeStyles/codeStyleConfig.xml +0 -5
  136. package/dist/node_modules/mariadb/node_modules/iconv-lite/.idea/iconv-lite.iml +0 -12
  137. package/dist/node_modules/mariadb/node_modules/iconv-lite/.idea/inspectionProfiles/Project_Default.xml +0 -6
  138. package/dist/node_modules/mariadb/node_modules/iconv-lite/.idea/modules.xml +0 -8
  139. package/dist/node_modules/mariadb/node_modules/iconv-lite/.idea/vcs.xml +0 -6
  140. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/dbcs-codec.js +0 -597
  141. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/dbcs-data.js +0 -188
  142. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/index.js +0 -23
  143. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/internal.js +0 -198
  144. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/sbcs-codec.js +0 -72
  145. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/sbcs-data-generated.js +0 -451
  146. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/sbcs-data.js +0 -179
  147. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/tables/big5-added.json +0 -122
  148. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/tables/cp936.json +0 -264
  149. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/tables/cp949.json +0 -273
  150. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/tables/cp950.json +0 -177
  151. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/tables/eucjp.json +0 -182
  152. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/tables/gb18030-ranges.json +0 -1
  153. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/tables/gbk-added.json +0 -56
  154. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/tables/shiftjis.json +0 -125
  155. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/utf16.js +0 -197
  156. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/utf32.js +0 -319
  157. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/utf7.js +0 -290
  158. package/dist/node_modules/mariadb/node_modules/iconv-lite/lib/bom-handling.js +0 -52
  159. package/dist/node_modules/mariadb/node_modules/iconv-lite/lib/index.d.ts +0 -41
  160. package/dist/node_modules/mariadb/node_modules/iconv-lite/lib/index.js +0 -180
  161. package/dist/node_modules/mariadb/node_modules/iconv-lite/lib/streams.js +0 -109
  162. package/dist/node_modules/mariadb/node_modules/iconv-lite/package.json +0 -44
  163. package/dist/node_modules/mariadb/package.json +0 -1
  164. package/dist/node_modules/mariadb/promise.js +0 -34
  165. package/dist/node_modules/mariadb/types/index.d.ts +0 -870
  166. package/dist/server/collections/applications.d.ts +0 -10
  167. package/dist/server/collections/applications.js +0 -75
  168. package/dist/server/index.d.ts +0 -11
  169. package/dist/server/index.js +0 -40
  170. package/dist/server/models/application.d.ts +0 -18
  171. package/dist/server/models/application.js +0 -50
  172. package/dist/server/server.d.ts +0 -26
  173. package/dist/server/server.js +0 -310
  174. package/dist/swagger/index.d.ts +0 -195
  175. package/dist/swagger/index.js +0 -226
@@ -1,292 +0,0 @@
1
- 'use strict';
2
-
3
- const Command = require('../command');
4
- const InitialHandshake = require('./initial-handshake');
5
- const ClientHandshakeResponse = require('./client-handshake-response');
6
- const SslRequest = require('./ssl-request');
7
- const ClientCapabilities = require('./client-capabilities');
8
- const Errors = require('../../misc/errors');
9
- const Capabilities = require('../../const/capabilities');
10
- const process = require('process');
11
-
12
- /**
13
- * Handle handshake.
14
- * see https://mariadb.com/kb/en/library/1-connecting-connecting/
15
- */
16
- class Handshake extends Command {
17
- constructor(resolve, reject, _createSecureContext, _addCommand, getSocket) {
18
- super(resolve, reject);
19
- this._createSecureContext = _createSecureContext;
20
- this._addCommand = _addCommand;
21
- this.getSocket = getSocket;
22
- this.onPacketReceive = this.parseHandshakeInit;
23
- this.plugin = this;
24
- }
25
-
26
- ensureOptionCompatibility(opts, info) {
27
- if (
28
- opts.multipleStatements &&
29
- (info.serverCapabilities & Capabilities.MULTI_STATEMENTS) === 0
30
- ) {
31
- return this.throwNewError(
32
- "Option `multipleStatements` enable, but server doesn'permits multi-statment",
33
- true,
34
- info,
35
- '08S01',
36
- Errors.ER_CLIENT_OPTION_INCOMPATIBILITY
37
- );
38
- }
39
-
40
- if (opts.permitLocalInfile && (info.serverCapabilities & Capabilities.LOCAL_FILES) === 0) {
41
- return this.throwNewError(
42
- "Option `permitLocalInfile` enable, but server doesn'permits using local file",
43
- true,
44
- info,
45
- '08S01',
46
- Errors.ER_CLIENT_OPTION_INCOMPATIBILITY
47
- );
48
- }
49
- }
50
-
51
- parseHandshakeInit(packet, out, opts, info) {
52
- if (packet.peek() === 0xff) {
53
- //in case that some host is not permit to connect server
54
- const authErr = packet.readError(info);
55
- authErr.fatal = true;
56
- return this.throwError(authErr, info);
57
- }
58
-
59
- let handshake = new InitialHandshake(packet, info);
60
- this.ensureOptionCompatibility(opts, info);
61
- ClientCapabilities.init(opts, info);
62
-
63
- if (opts.ssl) {
64
- if (info.serverCapabilities & Capabilities.SSL) {
65
- info.clientCapabilities |= Capabilities.SSL;
66
- SslRequest.send(this, out, info, opts);
67
- this._createSecureContext(
68
- function () {
69
- ClientHandshakeResponse.send(this, out, opts, handshake.pluginName, info);
70
- }.bind(this)
71
- );
72
- } else {
73
- return this.throwNewError(
74
- 'Trying to connect with ssl, but ssl not enabled in the server',
75
- true,
76
- info,
77
- '08S01',
78
- Errors.ER_SERVER_SSL_DISABLED
79
- );
80
- }
81
- } else {
82
- ClientHandshakeResponse.send(this, out, opts, handshake.pluginName, info);
83
- }
84
- this.onPacketReceive = this.handshakeResult;
85
- }
86
-
87
- /**
88
- * Fast-path handshake results :
89
- * - if plugin was the one expected by server, server will send OK_Packet / ERR_Packet.
90
- * - if not, server send an AuthSwitchRequest packet, indicating the specific PLUGIN to use with this user.
91
- * dispatching to plugin handler then.
92
- *
93
- * @param packet current packet
94
- * @param out output buffer
95
- * @param opts options
96
- * @param info connection info
97
- * @returns {*} return null if authentication succeed, depending on plugin conversation if not finished
98
- */
99
- handshakeResult(packet, out, opts, info) {
100
- const marker = packet.peek();
101
- switch (marker) {
102
- //*********************************************************************************************************
103
- //* AuthSwitchRequest packet
104
- //*********************************************************************************************************
105
- case 0xfe:
106
- this.plugin.onPacketReceive = null;
107
- this.plugin.emit('send_end');
108
- this.plugin.emit('end');
109
- this.dispatchAuthSwitchRequest(packet, out, opts, info);
110
- return;
111
-
112
- //*********************************************************************************************************
113
- //* OK_Packet - authentication succeeded
114
- //*********************************************************************************************************
115
- case 0x00:
116
- this.plugin.onPacketReceive = null;
117
- packet.skip(1); //skip header
118
- packet.skipLengthCodedNumber(); //skip affected rows
119
- packet.skipLengthCodedNumber(); //skip last insert id
120
- info.status = packet.readUInt16();
121
- this.plugin.emit('send_end');
122
- return this.plugin.successEnd();
123
-
124
- //*********************************************************************************************************
125
- //* ERR_Packet
126
- //*********************************************************************************************************
127
- case 0xff:
128
- this.plugin.onPacketReceive = null;
129
- const authErr = packet.readError(info, this.displaySql());
130
- authErr.fatal = true;
131
- return this.plugin.throwError(authErr, info);
132
-
133
- //*********************************************************************************************************
134
- //* unexpected
135
- //*********************************************************************************************************
136
- default:
137
- this.throwNewError(
138
- 'Unexpected type of packet during handshake phase : ' + marker,
139
- true,
140
- info,
141
- '42000',
142
- Errors.ER_AUTHENTICATION_BAD_PACKET
143
- );
144
- }
145
- }
146
-
147
- /**
148
- * Handle authentication switch request : dispatch to plugin handler.
149
- *
150
- * @param packet packet
151
- * @param out output writer
152
- * @param opts options
153
- * @param info connection information
154
- */
155
- dispatchAuthSwitchRequest(packet, out, opts, info) {
156
- let pluginName, pluginData;
157
- if (info.clientCapabilities & Capabilities.PLUGIN_AUTH) {
158
- packet.skip(1); //header
159
- if (packet.remaining()) {
160
- //AuthSwitchRequest packet.
161
- pluginName = packet.readStringNullEnded();
162
- pluginData = packet.readBufferRemaining();
163
- } else {
164
- //OldAuthSwitchRequest
165
- pluginName = 'mysql_old_password';
166
- pluginData = info.seed.slice(0, 8);
167
- }
168
- } else {
169
- pluginName = packet.readStringNullEnded('cesu8');
170
- pluginData = packet.readBufferRemaining();
171
- }
172
-
173
- try {
174
- this.plugin = Handshake.pluginHandler(
175
- pluginName,
176
- this.plugin.sequenceNo,
177
- this.plugin.compressSequenceNo,
178
- pluginData,
179
- info,
180
- opts,
181
- out,
182
- this.resolve,
183
- this.reject,
184
- this.handshakeResult.bind(this)
185
- );
186
- } catch (err) {
187
- this.reject(err);
188
- return;
189
- }
190
-
191
- if (!this.plugin) {
192
- this.reject(
193
- Errors.createError(
194
- "Client does not support authentication protocol '" +
195
- pluginName +
196
- "' requested by server. ",
197
- null,
198
- true,
199
- info,
200
- '08004',
201
- Errors.ER_AUTHENTICATION_PLUGIN_NOT_SUPPORTED
202
- )
203
- );
204
- } else {
205
- this._addCommand(this.plugin, false);
206
- }
207
- }
208
-
209
- static pluginHandler(
210
- pluginName,
211
- packSeq,
212
- compressPackSeq,
213
- pluginData,
214
- info,
215
- opts,
216
- out,
217
- authResolve,
218
- authReject,
219
- multiAuthResolver
220
- ) {
221
- let pluginAuth;
222
- switch (pluginName) {
223
- case 'mysql_native_password':
224
- pluginAuth = require('./auth/native-password-auth.js');
225
- break;
226
-
227
- case 'mysql_clear_password':
228
- pluginAuth = require('./auth/clear-password-auth.js');
229
- break;
230
-
231
- case 'client_ed25519':
232
- pluginAuth = require('./auth/ed25519-password-auth.js');
233
- break;
234
-
235
- case 'dialog':
236
- pluginAuth = require('./auth/pam-password-auth.js');
237
- break;
238
-
239
- case 'sha256_password':
240
- if (!Handshake.ensureNodeVersion(11, 6, 0)) {
241
- throw Errors.createError(
242
- 'sha256_password authentication plugin require node 11.6+',
243
- null,
244
- true,
245
- info,
246
- '08004',
247
- Errors.ER_MINIMUM_NODE_VERSION_REQUIRED
248
- );
249
- }
250
- pluginAuth = require('./auth/sha256-password-auth.js');
251
- break;
252
-
253
- case 'caching_sha2_password':
254
- if (!Handshake.ensureNodeVersion(11, 6, 0)) {
255
- throw Errors.createError(
256
- 'caching_sha2_password authentication plugin require node 11.6+',
257
- null,
258
- true,
259
- info,
260
- '08004',
261
- Errors.ER_MINIMUM_NODE_VERSION_REQUIRED
262
- );
263
- }
264
- pluginAuth = require('./auth/caching-sha2-password-auth.js');
265
- break;
266
-
267
- //TODO "auth_gssapi_client"
268
-
269
- default:
270
- return null;
271
- }
272
- return new pluginAuth(
273
- packSeq,
274
- compressPackSeq,
275
- pluginData,
276
- authResolve,
277
- authReject,
278
- multiAuthResolver
279
- );
280
- }
281
-
282
- static ensureNodeVersion(major, minor, patch) {
283
- const ver = process.versions.node.split('.');
284
- return (
285
- ver[0] > major ||
286
- (ver[0] === major && ver[1] > minor) ||
287
- (ver[0] === major && ver[1] === minor && ver[2] >= patch)
288
- );
289
- }
290
- }
291
-
292
- module.exports = Handshake;
@@ -1,74 +0,0 @@
1
- 'use strict';
2
-
3
- const Capabilities = require('../../const/capabilities');
4
- const ConnectionInformation = require('../../misc/connection-information');
5
-
6
- /**
7
- * Parser server initial handshake.
8
- * see https://mariadb.com/kb/en/library/1-connecting-connecting/#initial-handshake-packet
9
- */
10
- class InitialHandshake {
11
- constructor(packet, info) {
12
- //protocolVersion
13
- packet.skip(1);
14
- info.serverVersion = {};
15
- info.serverVersion.raw = packet.readStringNullEnded();
16
- info.threadId = packet.readUInt32();
17
-
18
- let seed1 = packet.readBuffer(8);
19
- packet.skip(1); //reserved byte
20
-
21
- let serverCapabilities = BigInt(packet.readUInt16());
22
- //skip characterSet
23
- packet.skip(1);
24
- info.status = packet.readUInt16();
25
- serverCapabilities += BigInt(packet.readUInt16()) << BigInt(16);
26
-
27
- let saltLength = 0;
28
- if (serverCapabilities & Capabilities.PLUGIN_AUTH) {
29
- saltLength = Math.max(12, packet.readUInt8() - 9);
30
- } else {
31
- packet.skip(1);
32
- }
33
- if (serverCapabilities & Capabilities.MYSQL) {
34
- packet.skip(10);
35
- } else {
36
- packet.skip(6);
37
- serverCapabilities += BigInt(packet.readUInt32()) << BigInt(32);
38
- }
39
-
40
- if (serverCapabilities & Capabilities.SECURE_CONNECTION) {
41
- let seed2 = packet.readBuffer(saltLength);
42
- info.seed = Buffer.concat([seed1, seed2]);
43
- } else {
44
- info.seed = seed1;
45
- }
46
- packet.skip(1);
47
- info.serverCapabilities = serverCapabilities;
48
-
49
- /**
50
- * check for MariaDB 10.x replication hack , remove fake prefix if needed
51
- * MDEV-4088: in 10.0+, the real version string maybe prefixed with "5.5.5-",
52
- * to workaround bugs in Oracle MySQL replication
53
- **/
54
-
55
- if (info.serverVersion.raw.startsWith('5.5.5-')) {
56
- info.serverVersion.mariaDb = true;
57
- info.serverVersion.raw = info.serverVersion.raw.substring('5.5.5-'.length);
58
- } else {
59
- //Support for MDEV-7780 faking server version
60
- info.serverVersion.mariaDb =
61
- info.serverVersion.raw.includes('MariaDB') ||
62
- (serverCapabilities & Capabilities.MYSQL) === BigInt(0);
63
- }
64
-
65
- if (serverCapabilities & Capabilities.PLUGIN_AUTH) {
66
- this.pluginName = packet.readStringNullEnded();
67
- } else {
68
- this.pluginName = '';
69
- }
70
- ConnectionInformation.parseVersionString(info);
71
- }
72
- }
73
-
74
- module.exports = InitialHandshake;
@@ -1,29 +0,0 @@
1
- 'use strict';
2
- const Capabilities = require('../../const/capabilities');
3
-
4
- /**
5
- * Send SSL Request packet.
6
- * see : https://mariadb.com/kb/en/library/1-connecting-connecting/#sslrequest-packet
7
- *
8
- * @param cmd current command
9
- * @param out output writer
10
- * @param info client information
11
- * @param opts connection options
12
- */
13
- module.exports.send = function sendSSLRequest(cmd, out, info, opts) {
14
- out.startPacket(cmd);
15
- out.writeInt32(Number(info.clientCapabilities & BigInt(0xffffffff)));
16
- out.writeInt32(1024 * 1024 * 1024); // max packet size
17
- out.writeInt8(opts.collation.index);
18
- for (let i = 0; i < 19; i++) {
19
- out.writeInt8(0);
20
- }
21
-
22
- if (info.serverCapabilities & Capabilities.MYSQL) {
23
- out.writeInt32(0);
24
- } else {
25
- out.writeInt32(Number(info.clientCapabilities >> BigInt(32)));
26
- }
27
-
28
- out.flushBuffer(true);
29
- };
@@ -1,52 +0,0 @@
1
- 'use strict';
2
-
3
- const Command = require('./command');
4
- const Errors = require('../misc/errors');
5
-
6
- /**
7
- * send a COM_PING: permits sending a packet containing one byte to check that the connection is active.
8
- * see https://mariadb.com/kb/en/library/com_ping/
9
- */
10
- class Ping extends Command {
11
- constructor(resolve, reject) {
12
- super(resolve, reject);
13
- }
14
-
15
- start(out, opts, info) {
16
- out.startPacket(this);
17
- out.writeInt8(0x0e);
18
- out.flushBuffer(true);
19
- this.emit('send_end');
20
- this.onPacketReceive = this.readPingResponsePacket;
21
- }
22
-
23
- /**
24
- * Read ping response packet.
25
- * packet can be :
26
- * - an ERR_Packet
27
- * - a OK_Packet
28
- *
29
- * @param packet query response
30
- * @param out output writer
31
- * @param opts connection options
32
- * @param info connection info
33
- */
34
- readPingResponsePacket(packet, out, opts, info) {
35
- if (packet.peek() !== 0x00) {
36
- return this.throwNewError(
37
- 'unexpected packet',
38
- false,
39
- info,
40
- '42000',
41
- Errors.ER_PING_BAD_PACKET
42
- );
43
- }
44
- packet.skip(1); //skip header
45
- packet.skipLengthCodedNumber(); //affected rows
46
- packet.skipLengthCodedNumber(); //insert ids
47
- info.status = packet.readUInt16();
48
- this.successEnd(null);
49
- }
50
- }
51
-
52
- module.exports = Ping;
@@ -1,255 +0,0 @@
1
- 'use strict';
2
-
3
- const CommonText = require('./common-text-cmd');
4
- const Errors = require('../misc/errors');
5
- const Parse = require('../misc/parse');
6
- const QUOTE = 0x27;
7
-
8
- /**
9
- * Protocol COM_QUERY
10
- * see : https://mariadb.com/kb/en/library/com_query/
11
- */
12
- class Query extends CommonText {
13
- constructor(resolve, reject, options, connOpts, sql, values) {
14
- super(resolve, reject, options, connOpts, sql, values);
15
- }
16
-
17
- /**
18
- * Send COM_QUERY
19
- *
20
- * @param out output writer
21
- * @param opts connection options
22
- * @param info connection information
23
- */
24
- start(out, opts, info) {
25
- if (this.initialValues === undefined) {
26
- //shortcut if no parameters
27
- out.startPacket(this);
28
- out.writeInt8(0x03);
29
- if (!this.handleTimeout(out, info)) return;
30
- out.writeString(this.sql);
31
- out.flushBuffer(true);
32
- this.emit('send_end');
33
- return (this.onPacketReceive = this.readResponsePacket);
34
- }
35
-
36
- if (this.opts.namedPlaceholders) {
37
- try {
38
- const parsed = Parse.splitQueryPlaceholder(
39
- this.sql,
40
- info,
41
- this.initialValues,
42
- this.displaySql.bind(this)
43
- );
44
- this.queryParts = parsed.parts;
45
- this.values = parsed.values;
46
- } catch (err) {
47
- this.emit('send_end');
48
- return this.throwError(err, info);
49
- }
50
- } else {
51
- this.queryParts = Parse.splitQuery(this.sql);
52
- this.values = Array.isArray(this.initialValues) ? this.initialValues : [this.initialValues];
53
- if (!this.validateParameters(info)) return;
54
- }
55
-
56
- out.startPacket(this);
57
- out.writeInt8(0x03);
58
- if (!this.handleTimeout(out, info)) return;
59
- out.writeString(this.queryParts[0]);
60
- this.onPacketReceive = this.readResponsePacket;
61
-
62
- //********************************************
63
- // send params
64
- //********************************************
65
- const len = this.queryParts.length;
66
- for (let i = 1; i < len; i++) {
67
- const value = this.values[i - 1];
68
-
69
- if (
70
- value !== null &&
71
- typeof value === 'object' &&
72
- typeof value.pipe === 'function' &&
73
- typeof value.read === 'function'
74
- ) {
75
- this.sending = true;
76
- //********************************************
77
- // param is stream,
78
- // now all params will be written by event
79
- //********************************************
80
- this.registerStreamSendEvent(out, info);
81
- this.currentParam = i;
82
- out.writeInt8(QUOTE); //'
83
-
84
- value.on('data', function (chunk) {
85
- out.writeBufferEscape(chunk);
86
- });
87
-
88
- value.on(
89
- 'end',
90
- function () {
91
- out.writeInt8(QUOTE); //'
92
- out.writeString(this.queryParts[this.currentParam++]);
93
- this.paramWritten();
94
- }.bind(this)
95
- );
96
-
97
- return;
98
- } else {
99
- //********************************************
100
- // param isn't stream. directly write in buffer
101
- //********************************************
102
- this.writeParam(out, value, this.opts, info);
103
- out.writeString(this.queryParts[i]);
104
- }
105
- }
106
- out.flushBuffer(true);
107
- this.emit('send_end');
108
- }
109
-
110
- /**
111
- * If timeout is set, prepend query with SET STATEMENT max_statement_time=xx FOR, or throw an error
112
- * @param out buffer
113
- * @param info server information
114
- * @returns {boolean} false if an error has been thrown
115
- */
116
- handleTimeout(out, info) {
117
- if (this.opts.timeout) {
118
- if (info.isMariaDB()) {
119
- if (info.hasMinVersion(10, 1, 2)) {
120
- out.writeString('SET STATEMENT max_statement_time=' + this.opts.timeout / 1000 + ' FOR ');
121
- return true;
122
- } else {
123
- const err = Errors.createError(
124
- 'Cannot use timeout for MariaDB server before 10.1.2. timeout value: ' +
125
- this.opts.timeout,
126
- this.sql,
127
- false,
128
- info,
129
- 'HY000',
130
- Errors.ER_TIMEOUT_NOT_SUPPORTED
131
- );
132
- this.emit('send_end');
133
- this.throwError(err, info);
134
- return false;
135
- }
136
- } else {
137
- //not available for MySQL
138
- // max_execution time exist, but only for select, and as hint
139
- const err = Errors.createError(
140
- 'Cannot use timeout for MySQL server. timeout value: ' + this.opts.timeout,
141
- this.sql,
142
- false,
143
- info,
144
- 'HY000',
145
- Errors.ER_TIMEOUT_NOT_SUPPORTED
146
- );
147
- this.emit('send_end');
148
- this.throwError(err, info);
149
- return false;
150
- }
151
- }
152
- return true;
153
- }
154
-
155
- /**
156
- * Validate that parameters exists and are defined.
157
- *
158
- * @param info connection info
159
- * @returns {boolean} return false if any error occur.
160
- */
161
- validateParameters(info) {
162
- //validate parameter size.
163
- if (this.queryParts.length - 1 > this.values.length) {
164
- this.emit('send_end');
165
- this.throwNewError(
166
- 'Parameter at position ' + (this.values.length + 1) + ' is not set',
167
- false,
168
- info,
169
- 'HY000',
170
- Errors.ER_MISSING_PARAMETER
171
- );
172
- return false;
173
- }
174
-
175
- //validate parameter is defined.
176
- for (let i = 0; i < this.queryParts.length - 1; i++) {
177
- if (this.values[i] === undefined) {
178
- this.emit('send_end');
179
- this.throwNewError(
180
- 'Parameter at position ' + (i + 1) + ' is undefined\n' + this.displaySql(),
181
- false,
182
- info,
183
- 'HY000',
184
- Errors.ER_PARAMETER_UNDEFINED
185
- );
186
- return false;
187
- }
188
- }
189
-
190
- return true;
191
- }
192
-
193
- /**
194
- * Define params events.
195
- * Each parameter indicate that he is written to socket,
196
- * emitting event so next stream parameter can be written.
197
- */
198
- registerStreamSendEvent(out, info) {
199
- // note : Implementation use recursive calls, but stack won't never get near v8 max call stack size
200
- //since event launched for stream parameter only
201
- this.paramWritten = function () {
202
- while (true) {
203
- if (this.currentParam === this.queryParts.length) {
204
- //********************************************
205
- // all parameters are written.
206
- // flush packet
207
- //********************************************
208
- out.flushBuffer(true);
209
- this.sending = false;
210
- this.emit('send_end');
211
- return;
212
- } else {
213
- const value = this.values[this.currentParam - 1];
214
-
215
- if (value === null) {
216
- out.writeStringAscii('NULL');
217
- out.writeString(this.queryParts[this.currentParam++]);
218
- continue;
219
- }
220
-
221
- if (
222
- typeof value === 'object' &&
223
- typeof value.pipe === 'function' &&
224
- typeof value.read === 'function'
225
- ) {
226
- //********************************************
227
- // param is stream,
228
- //********************************************
229
- out.writeInt8(QUOTE);
230
- value.once(
231
- 'end',
232
- function () {
233
- out.writeInt8(QUOTE);
234
- out.writeString(this.queryParts[this.currentParam++]);
235
- this.paramWritten();
236
- }.bind(this)
237
- );
238
- value.on('data', function (chunk) {
239
- out.writeBufferEscape(chunk);
240
- });
241
- return;
242
- }
243
-
244
- //********************************************
245
- // param isn't stream. directly write in buffer
246
- //********************************************
247
- this.writeParam(out, value, this.opts, info);
248
- out.writeString(this.queryParts[this.currentParam++]);
249
- }
250
- }
251
- }.bind(this);
252
- }
253
- }
254
-
255
- module.exports = Query;