node-server-dev 3.1.4 → 3.1.6
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/cjs/browser.js +1 -1
- package/dist/cjs/build.d.ts +2 -0
- package/dist/cjs/build.d.ts.map +1 -0
- package/dist/cjs/build.js +1 -0
- package/dist/cjs/getAllRouter/index.js +1 -1
- package/dist/cjs/hash/index.js +1 -1
- package/dist/cjs/id/index.js +1 -1
- package/dist/cjs/id/random.js +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/jwt/index.js +1 -1
- package/dist/cjs/mac/index.js +1 -1
- package/dist/cjs/package/mysql2/License +19 -0
- package/dist/cjs/package/mysql2/README.md +114 -0
- package/dist/cjs/package/mysql2/index.d.ts +1 -0
- package/dist/cjs/package/mysql2/index.js +77 -0
- package/dist/cjs/package/mysql2/lib/auth_41.js +95 -0
- package/dist/cjs/package/mysql2/lib/auth_plugins/caching_sha2_password.js +108 -0
- package/dist/cjs/package/mysql2/lib/auth_plugins/caching_sha2_password.md +18 -0
- package/dist/cjs/package/mysql2/lib/auth_plugins/index.js +8 -0
- package/dist/cjs/package/mysql2/lib/auth_plugins/mysql_clear_password.js +17 -0
- package/dist/cjs/package/mysql2/lib/auth_plugins/mysql_native_password.js +34 -0
- package/dist/cjs/package/mysql2/lib/auth_plugins/sha256_password.js +59 -0
- package/dist/cjs/package/mysql2/lib/base/connection.js +945 -0
- package/dist/cjs/package/mysql2/lib/base/pool.js +233 -0
- package/dist/cjs/package/mysql2/lib/base/pool_connection.js +63 -0
- package/dist/cjs/package/mysql2/lib/commands/auth_switch.js +111 -0
- package/dist/cjs/package/mysql2/lib/commands/binlog_dump.js +109 -0
- package/dist/cjs/package/mysql2/lib/commands/change_user.js +68 -0
- package/dist/cjs/package/mysql2/lib/commands/client_handshake.js +241 -0
- package/dist/cjs/package/mysql2/lib/commands/close_statement.js +18 -0
- package/dist/cjs/package/mysql2/lib/commands/command.js +54 -0
- package/dist/cjs/package/mysql2/lib/commands/execute.js +112 -0
- package/dist/cjs/package/mysql2/lib/commands/index.js +27 -0
- package/dist/cjs/package/mysql2/lib/commands/ping.js +36 -0
- package/dist/cjs/package/mysql2/lib/commands/prepare.js +143 -0
- package/dist/cjs/package/mysql2/lib/commands/query.js +329 -0
- package/dist/cjs/package/mysql2/lib/commands/quit.js +29 -0
- package/dist/cjs/package/mysql2/lib/commands/register_slave.js +27 -0
- package/dist/cjs/package/mysql2/lib/commands/server_handshake.js +203 -0
- package/dist/cjs/package/mysql2/lib/compressed_protocol.js +127 -0
- package/dist/cjs/package/mysql2/lib/connection.js +12 -0
- package/dist/cjs/package/mysql2/lib/connection_config.js +292 -0
- package/dist/cjs/package/mysql2/lib/constants/charset_encodings.js +316 -0
- package/dist/cjs/package/mysql2/lib/constants/charsets.js +317 -0
- package/dist/cjs/package/mysql2/lib/constants/client.js +39 -0
- package/dist/cjs/package/mysql2/lib/constants/commands.js +36 -0
- package/dist/cjs/package/mysql2/lib/constants/cursor.js +8 -0
- package/dist/cjs/package/mysql2/lib/constants/encoding_charset.js +49 -0
- package/dist/cjs/package/mysql2/lib/constants/errors.js +3973 -0
- package/dist/cjs/package/mysql2/lib/constants/field_flags.js +20 -0
- package/dist/cjs/package/mysql2/lib/constants/server_status.js +44 -0
- package/dist/cjs/package/mysql2/lib/constants/session_track.js +11 -0
- package/dist/cjs/package/mysql2/lib/constants/ssl_profiles.js +11 -0
- package/dist/cjs/package/mysql2/lib/constants/types.js +64 -0
- package/dist/cjs/package/mysql2/lib/create_connection.js +10 -0
- package/dist/cjs/package/mysql2/lib/create_pool.js +10 -0
- package/dist/cjs/package/mysql2/lib/create_pool_cluster.js +9 -0
- package/dist/cjs/package/mysql2/lib/helpers.js +86 -0
- package/dist/cjs/package/mysql2/lib/packet_parser.js +195 -0
- package/dist/cjs/package/mysql2/lib/packets/auth_next_factor.js +35 -0
- package/dist/cjs/package/mysql2/lib/packets/auth_switch_request.js +38 -0
- package/dist/cjs/package/mysql2/lib/packets/auth_switch_request_more_data.js +33 -0
- package/dist/cjs/package/mysql2/lib/packets/auth_switch_response.js +30 -0
- package/dist/cjs/package/mysql2/lib/packets/binary_row.js +95 -0
- package/dist/cjs/package/mysql2/lib/packets/binlog_dump.js +33 -0
- package/dist/cjs/package/mysql2/lib/packets/binlog_query_statusvars.js +115 -0
- package/dist/cjs/package/mysql2/lib/packets/change_user.js +97 -0
- package/dist/cjs/package/mysql2/lib/packets/close_statement.js +21 -0
- package/dist/cjs/package/mysql2/lib/packets/column_definition.js +291 -0
- package/dist/cjs/package/mysql2/lib/packets/execute.js +214 -0
- package/dist/cjs/package/mysql2/lib/packets/handshake.js +112 -0
- package/dist/cjs/package/mysql2/lib/packets/handshake_response.js +144 -0
- package/dist/cjs/package/mysql2/lib/packets/index.js +152 -0
- package/dist/cjs/package/mysql2/lib/packets/packet.js +931 -0
- package/dist/cjs/package/mysql2/lib/packets/prepare_statement.js +27 -0
- package/dist/cjs/package/mysql2/lib/packets/prepared_statement_header.js +16 -0
- package/dist/cjs/package/mysql2/lib/packets/query.js +27 -0
- package/dist/cjs/package/mysql2/lib/packets/register_slave.js +46 -0
- package/dist/cjs/package/mysql2/lib/packets/resultset_header.js +118 -0
- package/dist/cjs/package/mysql2/lib/packets/ssl_request.js +25 -0
- package/dist/cjs/package/mysql2/lib/packets/text_row.js +47 -0
- package/dist/cjs/package/mysql2/lib/parsers/binary_parser.js +231 -0
- package/dist/cjs/package/mysql2/lib/parsers/parser_cache.js +66 -0
- package/dist/cjs/package/mysql2/lib/parsers/static_binary_parser.js +211 -0
- package/dist/cjs/package/mysql2/lib/parsers/static_text_parser.js +152 -0
- package/dist/cjs/package/mysql2/lib/parsers/string.js +50 -0
- package/dist/cjs/package/mysql2/lib/parsers/text_parser.js +214 -0
- package/dist/cjs/package/mysql2/lib/pool.js +12 -0
- package/dist/cjs/package/mysql2/lib/pool_cluster.js +369 -0
- package/dist/cjs/package/mysql2/lib/pool_config.js +30 -0
- package/dist/cjs/package/mysql2/lib/pool_connection.js +12 -0
- package/dist/cjs/package/mysql2/lib/promise/connection.js +222 -0
- package/dist/cjs/package/mysql2/lib/promise/inherit_events.js +27 -0
- package/dist/cjs/package/mysql2/lib/promise/make_done_cb.js +19 -0
- package/dist/cjs/package/mysql2/lib/promise/pool.js +112 -0
- package/dist/cjs/package/mysql2/lib/promise/pool_cluster.js +54 -0
- package/dist/cjs/package/mysql2/lib/promise/pool_connection.js +19 -0
- package/dist/cjs/package/mysql2/lib/promise/prepared_statement_info.js +32 -0
- package/dist/cjs/package/mysql2/lib/results_stream.js +38 -0
- package/dist/cjs/package/mysql2/lib/server.js +37 -0
- package/dist/cjs/package/mysql2/package.json +80 -0
- package/dist/cjs/package/mysql2/promise.d.ts +131 -0
- package/dist/cjs/package/mysql2/promise.js +202 -0
- package/dist/cjs/package/mysql2/typings/mysql/LICENSE.txt +15 -0
- package/dist/cjs/package/mysql2/typings/mysql/index.d.ts +95 -0
- package/dist/cjs/package/mysql2/typings/mysql/info.txt +1 -0
- package/dist/cjs/package/mysql2/typings/mysql/lib/Auth.d.ts +30 -0
- package/dist/cjs/package/mysql2/typings/mysql/lib/Connection.d.ts +428 -0
- package/dist/cjs/package/mysql2/typings/mysql/lib/Pool.d.ts +69 -0
- package/dist/cjs/package/mysql2/typings/mysql/lib/PoolCluster.d.ts +90 -0
- package/dist/cjs/package/mysql2/typings/mysql/lib/PoolConnection.d.ts +10 -0
- package/dist/cjs/package/mysql2/typings/mysql/lib/Server.d.ts +11 -0
- package/dist/cjs/package/mysql2/typings/mysql/lib/constants/CharsetToEncoding.d.ts +8 -0
- package/dist/cjs/package/mysql2/typings/mysql/lib/constants/Charsets.d.ts +326 -0
- package/dist/cjs/package/mysql2/typings/mysql/lib/constants/Types.d.ts +70 -0
- package/dist/cjs/package/mysql2/typings/mysql/lib/constants/index.d.ts +5 -0
- package/dist/cjs/package/mysql2/typings/mysql/lib/parsers/ParserCache.d.ts +4 -0
- package/dist/cjs/package/mysql2/typings/mysql/lib/parsers/index.d.ts +18 -0
- package/dist/cjs/package/mysql2/typings/mysql/lib/parsers/typeCast.d.ts +54 -0
- package/dist/cjs/package/mysql2/typings/mysql/lib/protocol/packets/Field.d.ts +10 -0
- package/dist/cjs/package/mysql2/typings/mysql/lib/protocol/packets/FieldPacket.d.ts +27 -0
- package/dist/cjs/package/mysql2/typings/mysql/lib/protocol/packets/OkPacket.d.ts +23 -0
- package/dist/cjs/package/mysql2/typings/mysql/lib/protocol/packets/ProcedurePacket.d.ts +13 -0
- package/dist/cjs/package/mysql2/typings/mysql/lib/protocol/packets/ResultSetHeader.d.ts +18 -0
- package/dist/cjs/package/mysql2/typings/mysql/lib/protocol/packets/RowDataPacket.d.ts +9 -0
- package/dist/cjs/package/mysql2/typings/mysql/lib/protocol/packets/index.d.ts +28 -0
- package/dist/cjs/package/mysql2/typings/mysql/lib/protocol/packets/params/ErrorPacketParams.d.ts +6 -0
- package/dist/cjs/package/mysql2/typings/mysql/lib/protocol/packets/params/OkPacketParams.d.ts +9 -0
- package/dist/cjs/package/mysql2/typings/mysql/lib/protocol/sequences/ExecutableBase.d.ts +40 -0
- package/dist/cjs/package/mysql2/typings/mysql/lib/protocol/sequences/Prepare.d.ts +65 -0
- package/dist/cjs/package/mysql2/typings/mysql/lib/protocol/sequences/Query.d.ts +170 -0
- package/dist/cjs/package/mysql2/typings/mysql/lib/protocol/sequences/QueryableBase.d.ts +40 -0
- package/dist/cjs/package/mysql2/typings/mysql/lib/protocol/sequences/Sequence.d.ts +5 -0
- package/dist/cjs/package/mysql2/typings/mysql/lib/protocol/sequences/promise/ExecutableBase.d.ts +21 -0
- package/dist/cjs/package/mysql2/typings/mysql/lib/protocol/sequences/promise/QueryableBase.d.ts +21 -0
- package/dist/cjs/server.d.ts +1 -1
- package/dist/cjs/server.d.ts.map +1 -1
- package/dist/cjs/server.js +1 -1
- package/dist/cjs/src/browser.d.ts +3 -0
- package/dist/cjs/src/browser.d.ts.map +1 -0
- package/dist/cjs/src/browser.js +1 -0
- package/dist/cjs/src/getAllRouter/index.d.ts +3 -0
- package/dist/cjs/src/getAllRouter/index.d.ts.map +1 -0
- package/dist/cjs/src/getAllRouter/index.js +1 -0
- package/dist/cjs/src/hash/index.d.ts +4 -0
- package/dist/cjs/src/hash/index.d.ts.map +1 -0
- package/dist/cjs/src/hash/index.js +1 -0
- package/dist/cjs/src/id/index.d.ts +3 -0
- package/dist/cjs/src/id/index.d.ts.map +1 -0
- package/dist/cjs/src/id/index.js +1 -0
- package/dist/cjs/src/id/random.d.ts +4 -0
- package/dist/cjs/src/id/random.d.ts.map +1 -0
- package/dist/cjs/src/id/random.js +1 -0
- package/dist/cjs/src/index.d.ts +25 -0
- package/dist/cjs/src/index.d.ts.map +1 -0
- package/dist/cjs/src/index.js +1 -0
- package/dist/cjs/src/jwt/index.d.ts +9 -0
- package/dist/cjs/src/jwt/index.d.ts.map +1 -0
- package/dist/cjs/src/jwt/index.js +1 -0
- package/dist/cjs/src/mac/index.d.ts +6 -0
- package/dist/cjs/src/mac/index.d.ts.map +1 -0
- package/dist/cjs/src/mac/index.js +1 -0
- package/dist/cjs/src/server.d.ts +7 -0
- package/dist/cjs/src/server.d.ts.map +1 -0
- package/dist/cjs/src/server.js +1 -0
- package/dist/cjs/src/start.d.ts +4 -0
- package/dist/cjs/src/start.d.ts.map +1 -0
- package/dist/cjs/src/start.js +1 -0
- package/dist/cjs/src/update.d.ts +3 -0
- package/dist/cjs/src/update.d.ts.map +1 -0
- package/dist/cjs/src/update.js +1 -0
- package/dist/cjs/start.js +1 -1
- package/dist/cjs/update.js +1 -1
- package/dist/esm/browser.js +1 -1
- package/dist/esm/build.d.ts +2 -0
- package/dist/esm/build.d.ts.map +1 -0
- package/dist/esm/build.js +1 -0
- package/dist/esm/getAllRouter/index.js +1 -1
- package/dist/esm/hash/index.js +1 -1
- package/dist/esm/id/index.js +1 -1
- package/dist/esm/id/random.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/jwt/index.js +1 -1
- package/dist/esm/mac/index.js +1 -1
- package/dist/esm/package/mysql2/License +19 -0
- package/dist/esm/package/mysql2/README.md +114 -0
- package/dist/esm/package/mysql2/index.d.ts +1 -0
- package/dist/esm/package/mysql2/index.js +77 -0
- package/dist/esm/package/mysql2/lib/auth_41.js +95 -0
- package/dist/esm/package/mysql2/lib/auth_plugins/caching_sha2_password.js +108 -0
- package/dist/esm/package/mysql2/lib/auth_plugins/caching_sha2_password.md +18 -0
- package/dist/esm/package/mysql2/lib/auth_plugins/index.js +8 -0
- package/dist/esm/package/mysql2/lib/auth_plugins/mysql_clear_password.js +17 -0
- package/dist/esm/package/mysql2/lib/auth_plugins/mysql_native_password.js +34 -0
- package/dist/esm/package/mysql2/lib/auth_plugins/sha256_password.js +59 -0
- package/dist/esm/package/mysql2/lib/base/connection.js +945 -0
- package/dist/esm/package/mysql2/lib/base/pool.js +233 -0
- package/dist/esm/package/mysql2/lib/base/pool_connection.js +63 -0
- package/dist/esm/package/mysql2/lib/commands/auth_switch.js +111 -0
- package/dist/esm/package/mysql2/lib/commands/binlog_dump.js +109 -0
- package/dist/esm/package/mysql2/lib/commands/change_user.js +68 -0
- package/dist/esm/package/mysql2/lib/commands/client_handshake.js +241 -0
- package/dist/esm/package/mysql2/lib/commands/close_statement.js +18 -0
- package/dist/esm/package/mysql2/lib/commands/command.js +54 -0
- package/dist/esm/package/mysql2/lib/commands/execute.js +112 -0
- package/dist/esm/package/mysql2/lib/commands/index.js +27 -0
- package/dist/esm/package/mysql2/lib/commands/ping.js +36 -0
- package/dist/esm/package/mysql2/lib/commands/prepare.js +143 -0
- package/dist/esm/package/mysql2/lib/commands/query.js +329 -0
- package/dist/esm/package/mysql2/lib/commands/quit.js +29 -0
- package/dist/esm/package/mysql2/lib/commands/register_slave.js +27 -0
- package/dist/esm/package/mysql2/lib/commands/server_handshake.js +203 -0
- package/dist/esm/package/mysql2/lib/compressed_protocol.js +127 -0
- package/dist/esm/package/mysql2/lib/connection.js +12 -0
- package/dist/esm/package/mysql2/lib/connection_config.js +292 -0
- package/dist/esm/package/mysql2/lib/constants/charset_encodings.js +316 -0
- package/dist/esm/package/mysql2/lib/constants/charsets.js +317 -0
- package/dist/esm/package/mysql2/lib/constants/client.js +39 -0
- package/dist/esm/package/mysql2/lib/constants/commands.js +36 -0
- package/dist/esm/package/mysql2/lib/constants/cursor.js +8 -0
- package/dist/esm/package/mysql2/lib/constants/encoding_charset.js +49 -0
- package/dist/esm/package/mysql2/lib/constants/errors.js +3973 -0
- package/dist/esm/package/mysql2/lib/constants/field_flags.js +20 -0
- package/dist/esm/package/mysql2/lib/constants/server_status.js +44 -0
- package/dist/esm/package/mysql2/lib/constants/session_track.js +11 -0
- package/dist/esm/package/mysql2/lib/constants/ssl_profiles.js +11 -0
- package/dist/esm/package/mysql2/lib/constants/types.js +64 -0
- package/dist/esm/package/mysql2/lib/create_connection.js +10 -0
- package/dist/esm/package/mysql2/lib/create_pool.js +10 -0
- package/dist/esm/package/mysql2/lib/create_pool_cluster.js +9 -0
- package/dist/esm/package/mysql2/lib/helpers.js +86 -0
- package/dist/esm/package/mysql2/lib/packet_parser.js +195 -0
- package/dist/esm/package/mysql2/lib/packets/auth_next_factor.js +35 -0
- package/dist/esm/package/mysql2/lib/packets/auth_switch_request.js +38 -0
- package/dist/esm/package/mysql2/lib/packets/auth_switch_request_more_data.js +33 -0
- package/dist/esm/package/mysql2/lib/packets/auth_switch_response.js +30 -0
- package/dist/esm/package/mysql2/lib/packets/binary_row.js +95 -0
- package/dist/esm/package/mysql2/lib/packets/binlog_dump.js +33 -0
- package/dist/esm/package/mysql2/lib/packets/binlog_query_statusvars.js +115 -0
- package/dist/esm/package/mysql2/lib/packets/change_user.js +97 -0
- package/dist/esm/package/mysql2/lib/packets/close_statement.js +21 -0
- package/dist/esm/package/mysql2/lib/packets/column_definition.js +291 -0
- package/dist/esm/package/mysql2/lib/packets/execute.js +214 -0
- package/dist/esm/package/mysql2/lib/packets/handshake.js +112 -0
- package/dist/esm/package/mysql2/lib/packets/handshake_response.js +144 -0
- package/dist/esm/package/mysql2/lib/packets/index.js +152 -0
- package/dist/esm/package/mysql2/lib/packets/packet.js +931 -0
- package/dist/esm/package/mysql2/lib/packets/prepare_statement.js +27 -0
- package/dist/esm/package/mysql2/lib/packets/prepared_statement_header.js +16 -0
- package/dist/esm/package/mysql2/lib/packets/query.js +27 -0
- package/dist/esm/package/mysql2/lib/packets/register_slave.js +46 -0
- package/dist/esm/package/mysql2/lib/packets/resultset_header.js +118 -0
- package/dist/esm/package/mysql2/lib/packets/ssl_request.js +25 -0
- package/dist/esm/package/mysql2/lib/packets/text_row.js +47 -0
- package/dist/esm/package/mysql2/lib/parsers/binary_parser.js +231 -0
- package/dist/esm/package/mysql2/lib/parsers/parser_cache.js +66 -0
- package/dist/esm/package/mysql2/lib/parsers/static_binary_parser.js +211 -0
- package/dist/esm/package/mysql2/lib/parsers/static_text_parser.js +152 -0
- package/dist/esm/package/mysql2/lib/parsers/string.js +50 -0
- package/dist/esm/package/mysql2/lib/parsers/text_parser.js +214 -0
- package/dist/esm/package/mysql2/lib/pool.js +12 -0
- package/dist/esm/package/mysql2/lib/pool_cluster.js +369 -0
- package/dist/esm/package/mysql2/lib/pool_config.js +30 -0
- package/dist/esm/package/mysql2/lib/pool_connection.js +12 -0
- package/dist/esm/package/mysql2/lib/promise/connection.js +222 -0
- package/dist/esm/package/mysql2/lib/promise/inherit_events.js +27 -0
- package/dist/esm/package/mysql2/lib/promise/make_done_cb.js +19 -0
- package/dist/esm/package/mysql2/lib/promise/pool.js +112 -0
- package/dist/esm/package/mysql2/lib/promise/pool_cluster.js +54 -0
- package/dist/esm/package/mysql2/lib/promise/pool_connection.js +19 -0
- package/dist/esm/package/mysql2/lib/promise/prepared_statement_info.js +32 -0
- package/dist/esm/package/mysql2/lib/results_stream.js +38 -0
- package/dist/esm/package/mysql2/lib/server.js +37 -0
- package/dist/esm/package/mysql2/package.json +80 -0
- package/dist/esm/package/mysql2/promise.d.ts +131 -0
- package/dist/esm/package/mysql2/promise.js +202 -0
- package/dist/esm/package/mysql2/typings/mysql/LICENSE.txt +15 -0
- package/dist/esm/package/mysql2/typings/mysql/index.d.ts +95 -0
- package/dist/esm/package/mysql2/typings/mysql/info.txt +1 -0
- package/dist/esm/package/mysql2/typings/mysql/lib/Auth.d.ts +30 -0
- package/dist/esm/package/mysql2/typings/mysql/lib/Connection.d.ts +428 -0
- package/dist/esm/package/mysql2/typings/mysql/lib/Pool.d.ts +69 -0
- package/dist/esm/package/mysql2/typings/mysql/lib/PoolCluster.d.ts +90 -0
- package/dist/esm/package/mysql2/typings/mysql/lib/PoolConnection.d.ts +10 -0
- package/dist/esm/package/mysql2/typings/mysql/lib/Server.d.ts +11 -0
- package/dist/esm/package/mysql2/typings/mysql/lib/constants/CharsetToEncoding.d.ts +8 -0
- package/dist/esm/package/mysql2/typings/mysql/lib/constants/Charsets.d.ts +326 -0
- package/dist/esm/package/mysql2/typings/mysql/lib/constants/Types.d.ts +70 -0
- package/dist/esm/package/mysql2/typings/mysql/lib/constants/index.d.ts +5 -0
- package/dist/esm/package/mysql2/typings/mysql/lib/parsers/ParserCache.d.ts +4 -0
- package/dist/esm/package/mysql2/typings/mysql/lib/parsers/index.d.ts +18 -0
- package/dist/esm/package/mysql2/typings/mysql/lib/parsers/typeCast.d.ts +54 -0
- package/dist/esm/package/mysql2/typings/mysql/lib/protocol/packets/Field.d.ts +10 -0
- package/dist/esm/package/mysql2/typings/mysql/lib/protocol/packets/FieldPacket.d.ts +27 -0
- package/dist/esm/package/mysql2/typings/mysql/lib/protocol/packets/OkPacket.d.ts +23 -0
- package/dist/esm/package/mysql2/typings/mysql/lib/protocol/packets/ProcedurePacket.d.ts +13 -0
- package/dist/esm/package/mysql2/typings/mysql/lib/protocol/packets/ResultSetHeader.d.ts +18 -0
- package/dist/esm/package/mysql2/typings/mysql/lib/protocol/packets/RowDataPacket.d.ts +9 -0
- package/dist/esm/package/mysql2/typings/mysql/lib/protocol/packets/index.d.ts +28 -0
- package/dist/esm/package/mysql2/typings/mysql/lib/protocol/packets/params/ErrorPacketParams.d.ts +6 -0
- package/dist/esm/package/mysql2/typings/mysql/lib/protocol/packets/params/OkPacketParams.d.ts +9 -0
- package/dist/esm/package/mysql2/typings/mysql/lib/protocol/sequences/ExecutableBase.d.ts +40 -0
- package/dist/esm/package/mysql2/typings/mysql/lib/protocol/sequences/Prepare.d.ts +65 -0
- package/dist/esm/package/mysql2/typings/mysql/lib/protocol/sequences/Query.d.ts +170 -0
- package/dist/esm/package/mysql2/typings/mysql/lib/protocol/sequences/QueryableBase.d.ts +40 -0
- package/dist/esm/package/mysql2/typings/mysql/lib/protocol/sequences/Sequence.d.ts +5 -0
- package/dist/esm/package/mysql2/typings/mysql/lib/protocol/sequences/promise/ExecutableBase.d.ts +21 -0
- package/dist/esm/package/mysql2/typings/mysql/lib/protocol/sequences/promise/QueryableBase.d.ts +21 -0
- package/dist/esm/server.d.ts +1 -1
- package/dist/esm/server.d.ts.map +1 -1
- package/dist/esm/server.js +1 -1
- package/dist/esm/src/browser.d.ts +3 -0
- package/dist/esm/src/browser.d.ts.map +1 -0
- package/dist/esm/src/browser.js +1 -0
- package/dist/esm/src/getAllRouter/index.d.ts +3 -0
- package/dist/esm/src/getAllRouter/index.d.ts.map +1 -0
- package/dist/esm/src/getAllRouter/index.js +1 -0
- package/dist/esm/src/hash/index.d.ts +4 -0
- package/dist/esm/src/hash/index.d.ts.map +1 -0
- package/dist/esm/src/hash/index.js +1 -0
- package/dist/esm/src/id/index.d.ts +3 -0
- package/dist/esm/src/id/index.d.ts.map +1 -0
- package/dist/esm/src/id/index.js +1 -0
- package/dist/esm/src/id/random.d.ts +4 -0
- package/dist/esm/src/id/random.d.ts.map +1 -0
- package/dist/esm/src/id/random.js +1 -0
- package/dist/esm/src/index.d.ts +25 -0
- package/dist/esm/src/index.d.ts.map +1 -0
- package/dist/esm/src/index.js +1 -0
- package/dist/esm/src/jwt/index.d.ts +9 -0
- package/dist/esm/src/jwt/index.d.ts.map +1 -0
- package/dist/esm/src/jwt/index.js +1 -0
- package/dist/esm/src/mac/index.d.ts +6 -0
- package/dist/esm/src/mac/index.d.ts.map +1 -0
- package/dist/esm/src/mac/index.js +1 -0
- package/dist/esm/src/server.d.ts +7 -0
- package/dist/esm/src/server.d.ts.map +1 -0
- package/dist/esm/src/server.js +1 -0
- package/dist/esm/src/start.d.ts +4 -0
- package/dist/esm/src/start.d.ts.map +1 -0
- package/dist/esm/src/start.js +1 -0
- package/dist/esm/src/update.d.ts +3 -0
- package/dist/esm/src/update.d.ts.map +1 -0
- package/dist/esm/src/update.js +1 -0
- package/dist/esm/start.js +1 -1
- package/dist/esm/update.js +1 -1
- package/package.json +3 -3
@@ -0,0 +1,241 @@
|
|
1
|
+
// This file was modified by Oracle on June 17, 2021.
|
2
|
+
// Handshake errors are now maked as fatal and the corresponding events are
|
3
|
+
// emitted in the command instance itself.
|
4
|
+
// Modifications copyright (c) 2021, Oracle and/or its affiliates.
|
5
|
+
|
6
|
+
// This file was modified by Oracle on September 21, 2021.
|
7
|
+
// Handshake workflow now supports additional authentication factors requested
|
8
|
+
// by the server.
|
9
|
+
// Modifications copyright (c) 2021, Oracle and/or its affiliates.
|
10
|
+
|
11
|
+
'use strict';
|
12
|
+
|
13
|
+
const Command = require('./command.js');
|
14
|
+
const Packets = require('../packets/index.js');
|
15
|
+
const ClientConstants = require('../constants/client.js');
|
16
|
+
const CharsetToEncoding = require('../constants/charset_encodings.js');
|
17
|
+
const auth41 = require('../auth_41.js');
|
18
|
+
|
19
|
+
function flagNames(flags) {
|
20
|
+
const res = [];
|
21
|
+
for (const c in ClientConstants) {
|
22
|
+
if (flags & ClientConstants[c]) {
|
23
|
+
res.push(c.replace(/_/g, ' ').toLowerCase());
|
24
|
+
}
|
25
|
+
}
|
26
|
+
return res;
|
27
|
+
}
|
28
|
+
|
29
|
+
class ClientHandshake extends Command {
|
30
|
+
constructor(clientFlags) {
|
31
|
+
super();
|
32
|
+
this.handshake = null;
|
33
|
+
this.clientFlags = clientFlags;
|
34
|
+
this.authenticationFactor = 0;
|
35
|
+
}
|
36
|
+
|
37
|
+
start() {
|
38
|
+
return ClientHandshake.prototype.handshakeInit;
|
39
|
+
}
|
40
|
+
|
41
|
+
sendSSLRequest(connection) {
|
42
|
+
const sslRequest = new Packets.SSLRequest(
|
43
|
+
this.clientFlags,
|
44
|
+
connection.config.charsetNumber
|
45
|
+
);
|
46
|
+
connection.writePacket(sslRequest.toPacket());
|
47
|
+
}
|
48
|
+
|
49
|
+
sendCredentials(connection) {
|
50
|
+
if (connection.config.debug) {
|
51
|
+
// eslint-disable-next-line
|
52
|
+
console.log(
|
53
|
+
'Sending handshake packet: flags:%d=(%s)',
|
54
|
+
this.clientFlags,
|
55
|
+
flagNames(this.clientFlags).join(', ')
|
56
|
+
);
|
57
|
+
}
|
58
|
+
this.user = connection.config.user;
|
59
|
+
this.password = connection.config.password;
|
60
|
+
// "password1" is an alias to the original "password" value
|
61
|
+
// to make it easier to integrate multi-factor authentication
|
62
|
+
this.password1 = connection.config.password;
|
63
|
+
// "password2" and "password3" are the 2nd and 3rd factor authentication
|
64
|
+
// passwords, which can be undefined depending on the authentication
|
65
|
+
// plugin being used
|
66
|
+
this.password2 = connection.config.password2;
|
67
|
+
this.password3 = connection.config.password3;
|
68
|
+
this.passwordSha1 = connection.config.passwordSha1;
|
69
|
+
this.database = connection.config.database;
|
70
|
+
this.authPluginName = this.handshake.authPluginName;
|
71
|
+
const handshakeResponse = new Packets.HandshakeResponse({
|
72
|
+
flags: this.clientFlags,
|
73
|
+
user: this.user,
|
74
|
+
database: this.database,
|
75
|
+
password: this.password,
|
76
|
+
passwordSha1: this.passwordSha1,
|
77
|
+
charsetNumber: connection.config.charsetNumber,
|
78
|
+
authPluginData1: this.handshake.authPluginData1,
|
79
|
+
authPluginData2: this.handshake.authPluginData2,
|
80
|
+
compress: connection.config.compress,
|
81
|
+
connectAttributes: connection.config.connectAttributes,
|
82
|
+
});
|
83
|
+
connection.writePacket(handshakeResponse.toPacket());
|
84
|
+
}
|
85
|
+
|
86
|
+
calculateNativePasswordAuthToken(authPluginData) {
|
87
|
+
// TODO: dont split into authPluginData1 and authPluginData2, instead join when 1 & 2 received
|
88
|
+
const authPluginData1 = authPluginData.slice(0, 8);
|
89
|
+
const authPluginData2 = authPluginData.slice(8, 20);
|
90
|
+
let authToken;
|
91
|
+
if (this.passwordSha1) {
|
92
|
+
authToken = auth41.calculateTokenFromPasswordSha(
|
93
|
+
this.passwordSha1,
|
94
|
+
authPluginData1,
|
95
|
+
authPluginData2
|
96
|
+
);
|
97
|
+
} else {
|
98
|
+
authToken = auth41.calculateToken(
|
99
|
+
this.password,
|
100
|
+
authPluginData1,
|
101
|
+
authPluginData2
|
102
|
+
);
|
103
|
+
}
|
104
|
+
return authToken;
|
105
|
+
}
|
106
|
+
|
107
|
+
handshakeInit(helloPacket, connection) {
|
108
|
+
this.on('error', (e) => {
|
109
|
+
connection._fatalError = e;
|
110
|
+
connection._protocolError = e;
|
111
|
+
});
|
112
|
+
this.handshake = Packets.Handshake.fromPacket(helloPacket);
|
113
|
+
if (connection.config.debug) {
|
114
|
+
// eslint-disable-next-line
|
115
|
+
console.log(
|
116
|
+
'Server hello packet: capability flags:%d=(%s)',
|
117
|
+
this.handshake.capabilityFlags,
|
118
|
+
flagNames(this.handshake.capabilityFlags).join(', ')
|
119
|
+
);
|
120
|
+
}
|
121
|
+
connection.serverCapabilityFlags = this.handshake.capabilityFlags;
|
122
|
+
connection.serverEncoding = CharsetToEncoding[this.handshake.characterSet];
|
123
|
+
connection.connectionId = this.handshake.connectionId;
|
124
|
+
const serverSSLSupport =
|
125
|
+
this.handshake.capabilityFlags & ClientConstants.SSL;
|
126
|
+
// multi factor authentication is enabled with the
|
127
|
+
// "MULTI_FACTOR_AUTHENTICATION" capability and should only be used if it
|
128
|
+
// is supported by the server
|
129
|
+
const multiFactorAuthentication =
|
130
|
+
this.handshake.capabilityFlags &
|
131
|
+
ClientConstants.MULTI_FACTOR_AUTHENTICATION;
|
132
|
+
this.clientFlags = this.clientFlags | multiFactorAuthentication;
|
133
|
+
// use compression only if requested by client and supported by server
|
134
|
+
connection.config.compress =
|
135
|
+
connection.config.compress &&
|
136
|
+
this.handshake.capabilityFlags & ClientConstants.COMPRESS;
|
137
|
+
this.clientFlags = this.clientFlags | connection.config.compress;
|
138
|
+
if (connection.config.ssl) {
|
139
|
+
// client requires SSL but server does not support it
|
140
|
+
if (!serverSSLSupport) {
|
141
|
+
const err = new Error('Server does not support secure connection');
|
142
|
+
err.code = 'HANDSHAKE_NO_SSL_SUPPORT';
|
143
|
+
err.fatal = true;
|
144
|
+
this.emit('error', err);
|
145
|
+
return false;
|
146
|
+
}
|
147
|
+
// send ssl upgrade request and immediately upgrade connection to secure
|
148
|
+
this.clientFlags |= ClientConstants.SSL;
|
149
|
+
this.sendSSLRequest(connection);
|
150
|
+
connection.startTLS((err) => {
|
151
|
+
// after connection is secure
|
152
|
+
if (err) {
|
153
|
+
// SSL negotiation error are fatal
|
154
|
+
err.code = 'HANDSHAKE_SSL_ERROR';
|
155
|
+
err.fatal = true;
|
156
|
+
this.emit('error', err);
|
157
|
+
return;
|
158
|
+
}
|
159
|
+
// rest of communication is encrypted
|
160
|
+
this.sendCredentials(connection);
|
161
|
+
});
|
162
|
+
} else {
|
163
|
+
this.sendCredentials(connection);
|
164
|
+
}
|
165
|
+
if (multiFactorAuthentication) {
|
166
|
+
// if the server supports multi-factor authentication, we enable it in
|
167
|
+
// the client
|
168
|
+
this.authenticationFactor = 1;
|
169
|
+
}
|
170
|
+
return ClientHandshake.prototype.handshakeResult;
|
171
|
+
}
|
172
|
+
|
173
|
+
handshakeResult(packet, connection) {
|
174
|
+
const marker = packet.peekByte();
|
175
|
+
// packet can be OK_Packet, ERR_Packet, AuthSwitchRequest, AuthNextFactor
|
176
|
+
// or AuthMoreData
|
177
|
+
if (marker === 0xfe || marker === 1 || marker === 0x02) {
|
178
|
+
const authSwitch = require('./auth_switch');
|
179
|
+
try {
|
180
|
+
if (marker === 1) {
|
181
|
+
authSwitch.authSwitchRequestMoreData(packet, connection, this);
|
182
|
+
} else {
|
183
|
+
// if authenticationFactor === 0, it means the server does not support
|
184
|
+
// the multi-factor authentication capability
|
185
|
+
if (this.authenticationFactor !== 0) {
|
186
|
+
// if we are past the first authentication factor, we should use the
|
187
|
+
// corresponding password (if there is one)
|
188
|
+
connection.config.password =
|
189
|
+
this[`password${this.authenticationFactor}`];
|
190
|
+
// update the current authentication factor
|
191
|
+
this.authenticationFactor += 1;
|
192
|
+
}
|
193
|
+
// if marker === 0x02, it means it is an AuthNextFactor packet,
|
194
|
+
// which is similar in structure to an AuthSwitchRequest packet,
|
195
|
+
// so, we can use it directly
|
196
|
+
authSwitch.authSwitchRequest(packet, connection, this);
|
197
|
+
}
|
198
|
+
return ClientHandshake.prototype.handshakeResult;
|
199
|
+
} catch (err) {
|
200
|
+
// Authentication errors are fatal
|
201
|
+
err.code = 'AUTH_SWITCH_PLUGIN_ERROR';
|
202
|
+
err.fatal = true;
|
203
|
+
|
204
|
+
if (this.onResult) {
|
205
|
+
this.onResult(err);
|
206
|
+
} else {
|
207
|
+
this.emit('error', err);
|
208
|
+
}
|
209
|
+
return null;
|
210
|
+
}
|
211
|
+
}
|
212
|
+
if (marker !== 0) {
|
213
|
+
const err = new Error('Unexpected packet during handshake phase');
|
214
|
+
// Unknown handshake errors are fatal
|
215
|
+
err.code = 'HANDSHAKE_UNKNOWN_ERROR';
|
216
|
+
err.fatal = true;
|
217
|
+
|
218
|
+
if (this.onResult) {
|
219
|
+
this.onResult(err);
|
220
|
+
} else {
|
221
|
+
this.emit('error', err);
|
222
|
+
}
|
223
|
+
return null;
|
224
|
+
}
|
225
|
+
// this should be called from ClientHandshake command only
|
226
|
+
// and skipped when called from ChangeUser command
|
227
|
+
if (!connection.authorized) {
|
228
|
+
connection.authorized = true;
|
229
|
+
if (connection.config.compress) {
|
230
|
+
const enableCompression =
|
231
|
+
require('../compressed_protocol.js').enableCompression;
|
232
|
+
enableCompression(connection);
|
233
|
+
}
|
234
|
+
}
|
235
|
+
if (this.onResult) {
|
236
|
+
this.onResult(null);
|
237
|
+
}
|
238
|
+
return null;
|
239
|
+
}
|
240
|
+
}
|
241
|
+
module.exports = ClientHandshake;
|
@@ -0,0 +1,18 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
const Command = require('./command');
|
4
|
+
const Packets = require('../packets/index.js');
|
5
|
+
|
6
|
+
class CloseStatement extends Command {
|
7
|
+
constructor(id) {
|
8
|
+
super();
|
9
|
+
this.id = id;
|
10
|
+
}
|
11
|
+
|
12
|
+
start(packet, connection) {
|
13
|
+
connection.writePacket(new Packets.CloseStatement(this.id).toPacket(1));
|
14
|
+
return null;
|
15
|
+
}
|
16
|
+
}
|
17
|
+
|
18
|
+
module.exports = CloseStatement;
|
@@ -0,0 +1,54 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
const EventEmitter = require('events').EventEmitter;
|
4
|
+
const Timers = require('timers');
|
5
|
+
|
6
|
+
class Command extends EventEmitter {
|
7
|
+
constructor() {
|
8
|
+
super();
|
9
|
+
this.next = null;
|
10
|
+
}
|
11
|
+
|
12
|
+
// slow. debug only
|
13
|
+
stateName() {
|
14
|
+
const state = this.next;
|
15
|
+
for (const i in this) {
|
16
|
+
if (this[i] === state && i !== 'next') {
|
17
|
+
return i;
|
18
|
+
}
|
19
|
+
}
|
20
|
+
return 'unknown name';
|
21
|
+
}
|
22
|
+
|
23
|
+
execute(packet, connection) {
|
24
|
+
if (!this.next) {
|
25
|
+
this.next = this.start;
|
26
|
+
connection._resetSequenceId();
|
27
|
+
}
|
28
|
+
if (packet && packet.isError()) {
|
29
|
+
const err = packet.asError(connection.clientEncoding);
|
30
|
+
err.sql = this.sql || this.query;
|
31
|
+
if (this.queryTimeout) {
|
32
|
+
Timers.clearTimeout(this.queryTimeout);
|
33
|
+
this.queryTimeout = null;
|
34
|
+
}
|
35
|
+
if (this.onResult) {
|
36
|
+
this.onResult(err);
|
37
|
+
this.emit('end');
|
38
|
+
} else {
|
39
|
+
this.emit('error', err);
|
40
|
+
this.emit('end');
|
41
|
+
}
|
42
|
+
return true;
|
43
|
+
}
|
44
|
+
// TODO: don't return anything from execute, it's ugly and error-prone. Listen for 'end' event in connection
|
45
|
+
this.next = this.next(packet, connection);
|
46
|
+
if (this.next) {
|
47
|
+
return false;
|
48
|
+
}
|
49
|
+
this.emit('end');
|
50
|
+
return true;
|
51
|
+
}
|
52
|
+
}
|
53
|
+
|
54
|
+
module.exports = Command;
|
@@ -0,0 +1,112 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
const Command = require('./command.js');
|
4
|
+
const Query = require('./query.js');
|
5
|
+
const Packets = require('../packets/index.js');
|
6
|
+
|
7
|
+
const getBinaryParser = require('../parsers/binary_parser.js');
|
8
|
+
const getStaticBinaryParser = require('../parsers/static_binary_parser.js');
|
9
|
+
|
10
|
+
class Execute extends Command {
|
11
|
+
constructor(options, callback) {
|
12
|
+
super();
|
13
|
+
this.statement = options.statement;
|
14
|
+
this.sql = options.sql;
|
15
|
+
this.values = options.values;
|
16
|
+
this.onResult = callback;
|
17
|
+
this.parameters = options.values;
|
18
|
+
this.insertId = 0;
|
19
|
+
this.timeout = options.timeout;
|
20
|
+
this.queryTimeout = null;
|
21
|
+
this._rows = [];
|
22
|
+
this._fields = [];
|
23
|
+
this._result = [];
|
24
|
+
this._fieldCount = 0;
|
25
|
+
this._rowParser = null;
|
26
|
+
this._executeOptions = options;
|
27
|
+
this._resultIndex = 0;
|
28
|
+
this._localStream = null;
|
29
|
+
this._unpipeStream = function () {};
|
30
|
+
this._streamFactory = options.infileStreamFactory;
|
31
|
+
this._connection = null;
|
32
|
+
}
|
33
|
+
|
34
|
+
buildParserFromFields(fields, connection) {
|
35
|
+
if (this.options.disableEval) {
|
36
|
+
return getStaticBinaryParser(fields, this.options, connection.config);
|
37
|
+
}
|
38
|
+
|
39
|
+
return getBinaryParser(fields, this.options, connection.config);
|
40
|
+
}
|
41
|
+
|
42
|
+
start(packet, connection) {
|
43
|
+
this._connection = connection;
|
44
|
+
this.options = Object.assign({}, connection.config, this._executeOptions);
|
45
|
+
this._setTimeout();
|
46
|
+
const executePacket = new Packets.Execute(
|
47
|
+
this.statement.id,
|
48
|
+
this.parameters,
|
49
|
+
connection.config.charsetNumber,
|
50
|
+
connection.config.timezone
|
51
|
+
);
|
52
|
+
//For reasons why this try-catch is here, please see
|
53
|
+
// https://github.com/sidorares/node-mysql2/pull/689
|
54
|
+
//For additional discussion, see
|
55
|
+
// 1. https://github.com/sidorares/node-mysql2/issues/493
|
56
|
+
// 2. https://github.com/sidorares/node-mysql2/issues/187
|
57
|
+
// 3. https://github.com/sidorares/node-mysql2/issues/480
|
58
|
+
try {
|
59
|
+
connection.writePacket(executePacket.toPacket(1));
|
60
|
+
} catch (error) {
|
61
|
+
this.onResult(error);
|
62
|
+
}
|
63
|
+
return Execute.prototype.resultsetHeader;
|
64
|
+
}
|
65
|
+
|
66
|
+
readField(packet, connection) {
|
67
|
+
let fields;
|
68
|
+
// disabling for now, but would be great to find reliable way to parse fields only once
|
69
|
+
// fields reported by prepare can be empty at all or just incorrect - see #169
|
70
|
+
//
|
71
|
+
// perfomance optimisation: if we already have this field parsed in statement header, use one from header
|
72
|
+
// const field = this.statement.columns.length == this._fieldCount ?
|
73
|
+
// this.statement.columns[this._receivedFieldsCount] : new Packets.ColumnDefinition(packet);
|
74
|
+
const field = new Packets.ColumnDefinition(
|
75
|
+
packet,
|
76
|
+
connection.clientEncoding
|
77
|
+
);
|
78
|
+
this._receivedFieldsCount++;
|
79
|
+
this._fields[this._resultIndex].push(field);
|
80
|
+
if (this._receivedFieldsCount === this._fieldCount) {
|
81
|
+
fields = this._fields[this._resultIndex];
|
82
|
+
this.emit('fields', fields, this._resultIndex);
|
83
|
+
return Execute.prototype.fieldsEOF;
|
84
|
+
}
|
85
|
+
return Execute.prototype.readField;
|
86
|
+
}
|
87
|
+
|
88
|
+
fieldsEOF(packet, connection) {
|
89
|
+
// check EOF
|
90
|
+
if (!packet.isEOF()) {
|
91
|
+
return connection.protocolError('Expected EOF packet');
|
92
|
+
}
|
93
|
+
this._rowParser = new (this.buildParserFromFields(
|
94
|
+
this._fields[this._resultIndex],
|
95
|
+
connection
|
96
|
+
))();
|
97
|
+
return Execute.prototype.row;
|
98
|
+
}
|
99
|
+
}
|
100
|
+
|
101
|
+
Execute.prototype.done = Query.prototype.done;
|
102
|
+
Execute.prototype.doneInsert = Query.prototype.doneInsert;
|
103
|
+
Execute.prototype.resultsetHeader = Query.prototype.resultsetHeader;
|
104
|
+
Execute.prototype._findOrCreateReadStream =
|
105
|
+
Query.prototype._findOrCreateReadStream;
|
106
|
+
Execute.prototype._streamLocalInfile = Query.prototype._streamLocalInfile;
|
107
|
+
Execute.prototype._setTimeout = Query.prototype._setTimeout;
|
108
|
+
Execute.prototype._handleTimeoutError = Query.prototype._handleTimeoutError;
|
109
|
+
Execute.prototype.row = Query.prototype.row;
|
110
|
+
Execute.prototype.stream = Query.prototype.stream;
|
111
|
+
|
112
|
+
module.exports = Execute;
|
@@ -0,0 +1,27 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
const ClientHandshake = require('./client_handshake.js');
|
4
|
+
const ServerHandshake = require('./server_handshake.js');
|
5
|
+
const Query = require('./query.js');
|
6
|
+
const Prepare = require('./prepare.js');
|
7
|
+
const CloseStatement = require('./close_statement.js');
|
8
|
+
const Execute = require('./execute.js');
|
9
|
+
const Ping = require('./ping.js');
|
10
|
+
const RegisterSlave = require('./register_slave.js');
|
11
|
+
const BinlogDump = require('./binlog_dump.js');
|
12
|
+
const ChangeUser = require('./change_user.js');
|
13
|
+
const Quit = require('./quit.js');
|
14
|
+
|
15
|
+
module.exports = {
|
16
|
+
ClientHandshake,
|
17
|
+
ServerHandshake,
|
18
|
+
Query,
|
19
|
+
Prepare,
|
20
|
+
CloseStatement,
|
21
|
+
Execute,
|
22
|
+
Ping,
|
23
|
+
RegisterSlave,
|
24
|
+
BinlogDump,
|
25
|
+
ChangeUser,
|
26
|
+
Quit,
|
27
|
+
};
|
@@ -0,0 +1,36 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
const Command = require('./command');
|
4
|
+
const CommandCode = require('../constants/commands');
|
5
|
+
const Packet = require('../packets/packet');
|
6
|
+
|
7
|
+
// TODO: time statistics?
|
8
|
+
// usefull for queue size and network latency monitoring
|
9
|
+
// store created,sent,reply timestamps
|
10
|
+
class Ping extends Command {
|
11
|
+
constructor(callback) {
|
12
|
+
super();
|
13
|
+
this.onResult = callback;
|
14
|
+
}
|
15
|
+
|
16
|
+
start(packet, connection) {
|
17
|
+
const ping = new Packet(
|
18
|
+
0,
|
19
|
+
Buffer.from([1, 0, 0, 0, CommandCode.PING]),
|
20
|
+
0,
|
21
|
+
5
|
22
|
+
);
|
23
|
+
connection.writePacket(ping);
|
24
|
+
return Ping.prototype.pingResponse;
|
25
|
+
}
|
26
|
+
|
27
|
+
pingResponse() {
|
28
|
+
// TODO: check it's OK packet. error check already done in caller
|
29
|
+
if (this.onResult) {
|
30
|
+
process.nextTick(this.onResult.bind(this));
|
31
|
+
}
|
32
|
+
return null;
|
33
|
+
}
|
34
|
+
}
|
35
|
+
|
36
|
+
module.exports = Ping;
|
@@ -0,0 +1,143 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
const Packets = require('../packets/index.js');
|
4
|
+
const Command = require('./command.js');
|
5
|
+
const CloseStatement = require('./close_statement.js');
|
6
|
+
const Execute = require('./execute.js');
|
7
|
+
|
8
|
+
class PreparedStatementInfo {
|
9
|
+
constructor(query, id, columns, parameters, connection) {
|
10
|
+
this.query = query;
|
11
|
+
this.id = id;
|
12
|
+
this.columns = columns;
|
13
|
+
this.parameters = parameters;
|
14
|
+
this.rowParser = null;
|
15
|
+
this._connection = connection;
|
16
|
+
}
|
17
|
+
|
18
|
+
close() {
|
19
|
+
return this._connection.addCommand(new CloseStatement(this.id));
|
20
|
+
}
|
21
|
+
|
22
|
+
execute(parameters, callback) {
|
23
|
+
if (typeof parameters === 'function') {
|
24
|
+
callback = parameters;
|
25
|
+
parameters = [];
|
26
|
+
}
|
27
|
+
return this._connection.addCommand(
|
28
|
+
new Execute({ statement: this, values: parameters }, callback)
|
29
|
+
);
|
30
|
+
}
|
31
|
+
}
|
32
|
+
|
33
|
+
class Prepare extends Command {
|
34
|
+
constructor(options, callback) {
|
35
|
+
super();
|
36
|
+
this.query = options.sql;
|
37
|
+
this.onResult = callback;
|
38
|
+
this.id = 0;
|
39
|
+
this.fieldCount = 0;
|
40
|
+
this.parameterCount = 0;
|
41
|
+
this.fields = [];
|
42
|
+
this.parameterDefinitions = [];
|
43
|
+
this.options = options;
|
44
|
+
}
|
45
|
+
|
46
|
+
start(packet, connection) {
|
47
|
+
const Connection = connection.constructor;
|
48
|
+
this.key = Connection.statementKey(this.options);
|
49
|
+
const statement = connection._statements.get(this.key);
|
50
|
+
if (statement) {
|
51
|
+
if (this.onResult) {
|
52
|
+
this.onResult(null, statement);
|
53
|
+
}
|
54
|
+
return null;
|
55
|
+
}
|
56
|
+
const cmdPacket = new Packets.PrepareStatement(
|
57
|
+
this.query,
|
58
|
+
connection.config.charsetNumber,
|
59
|
+
this.options.values
|
60
|
+
);
|
61
|
+
connection.writePacket(cmdPacket.toPacket(1));
|
62
|
+
return Prepare.prototype.prepareHeader;
|
63
|
+
}
|
64
|
+
|
65
|
+
prepareHeader(packet, connection) {
|
66
|
+
const header = new Packets.PreparedStatementHeader(packet);
|
67
|
+
this.id = header.id;
|
68
|
+
this.fieldCount = header.fieldCount;
|
69
|
+
this.parameterCount = header.parameterCount;
|
70
|
+
if (this.parameterCount > 0) {
|
71
|
+
return Prepare.prototype.readParameter;
|
72
|
+
}
|
73
|
+
if (this.fieldCount > 0) {
|
74
|
+
return Prepare.prototype.readField;
|
75
|
+
}
|
76
|
+
return this.prepareDone(connection);
|
77
|
+
}
|
78
|
+
|
79
|
+
readParameter(packet, connection) {
|
80
|
+
// there might be scenarios when mysql server reports more parameters than
|
81
|
+
// are actually present in the array of parameter definitions.
|
82
|
+
// if EOF packet is received we switch to "read fields" state if there are
|
83
|
+
// any fields reported by the server, otherwise we finish the command.
|
84
|
+
if (packet.isEOF()) {
|
85
|
+
if (this.fieldCount > 0) {
|
86
|
+
return Prepare.prototype.readField;
|
87
|
+
}
|
88
|
+
return this.prepareDone(connection);
|
89
|
+
}
|
90
|
+
const def = new Packets.ColumnDefinition(packet, connection.clientEncoding);
|
91
|
+
this.parameterDefinitions.push(def);
|
92
|
+
if (this.parameterDefinitions.length === this.parameterCount) {
|
93
|
+
return Prepare.prototype.parametersEOF;
|
94
|
+
}
|
95
|
+
return this.readParameter;
|
96
|
+
}
|
97
|
+
|
98
|
+
readField(packet, connection) {
|
99
|
+
if (packet.isEOF()) {
|
100
|
+
return this.prepareDone(connection);
|
101
|
+
}
|
102
|
+
const def = new Packets.ColumnDefinition(packet, connection.clientEncoding);
|
103
|
+
this.fields.push(def);
|
104
|
+
if (this.fields.length === this.fieldCount) {
|
105
|
+
return Prepare.prototype.fieldsEOF;
|
106
|
+
}
|
107
|
+
return Prepare.prototype.readField;
|
108
|
+
}
|
109
|
+
|
110
|
+
parametersEOF(packet, connection) {
|
111
|
+
if (!packet.isEOF()) {
|
112
|
+
return connection.protocolError('Expected EOF packet after parameters');
|
113
|
+
}
|
114
|
+
if (this.fieldCount > 0) {
|
115
|
+
return Prepare.prototype.readField;
|
116
|
+
}
|
117
|
+
return this.prepareDone(connection);
|
118
|
+
}
|
119
|
+
|
120
|
+
fieldsEOF(packet, connection) {
|
121
|
+
if (!packet.isEOF()) {
|
122
|
+
return connection.protocolError('Expected EOF packet after fields');
|
123
|
+
}
|
124
|
+
return this.prepareDone(connection);
|
125
|
+
}
|
126
|
+
|
127
|
+
prepareDone(connection) {
|
128
|
+
const statement = new PreparedStatementInfo(
|
129
|
+
this.query,
|
130
|
+
this.id,
|
131
|
+
this.fields,
|
132
|
+
this.parameterDefinitions,
|
133
|
+
connection
|
134
|
+
);
|
135
|
+
connection._statements.set(this.key, statement);
|
136
|
+
if (this.onResult) {
|
137
|
+
this.onResult(null, statement);
|
138
|
+
}
|
139
|
+
return null;
|
140
|
+
}
|
141
|
+
}
|
142
|
+
|
143
|
+
module.exports = Prepare;
|