@nocobase/plugin-multi-app-manager 2.0.0-beta.8 → 2.0.0

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 (143) hide show
  1. package/dist/client/{db3a142b120d6553.js → 00b71fff3c8c7167.js} +1 -1
  2. package/dist/client/Migrate.d.ts +10 -0
  3. package/dist/client/index.js +1 -1
  4. package/dist/externalVersion.js +7 -7
  5. package/dist/locale/en-US.json +3 -2
  6. package/dist/locale/zh-CN.json +3 -2
  7. package/dist/node_modules/p-queue/dist/index.d.ts +101 -0
  8. package/dist/node_modules/p-queue/dist/index.js +1 -0
  9. package/dist/node_modules/p-queue/dist/lower-bound.d.ts +1 -0
  10. package/dist/node_modules/p-queue/dist/lower-bound.js +21 -0
  11. package/dist/node_modules/p-queue/dist/options.d.ts +64 -0
  12. package/dist/node_modules/p-queue/dist/options.js +2 -0
  13. package/dist/node_modules/p-queue/dist/priority-queue.d.ts +12 -0
  14. package/dist/node_modules/p-queue/dist/priority-queue.js +32 -0
  15. package/dist/node_modules/p-queue/dist/queue.d.ts +7 -0
  16. package/dist/node_modules/p-queue/dist/queue.js +2 -0
  17. package/dist/node_modules/p-queue/license +9 -0
  18. package/dist/node_modules/p-queue/node_modules/eventemitter3/index.d.ts +134 -0
  19. package/dist/node_modules/p-queue/node_modules/eventemitter3/index.js +336 -0
  20. package/dist/node_modules/p-queue/node_modules/eventemitter3/package.json +56 -0
  21. package/dist/node_modules/p-queue/node_modules/eventemitter3/umd/eventemitter3.js +340 -0
  22. package/dist/node_modules/p-queue/node_modules/eventemitter3/umd/eventemitter3.min.js +1 -0
  23. package/dist/node_modules/p-queue/package.json +1 -0
  24. package/dist/server/adapters/legacy-adapter.d.ts +43 -0
  25. package/dist/server/adapters/legacy-adapter.js +207 -0
  26. package/dist/server/server.d.ts +4 -6
  27. package/dist/server/server.js +38 -191
  28. package/package.json +2 -2
  29. package/dist/node_modules/mariadb/LICENSE +0 -502
  30. package/dist/node_modules/mariadb/callback.js +0 -41
  31. package/dist/node_modules/mariadb/lib/cmd/batch-bulk.js +0 -278
  32. package/dist/node_modules/mariadb/lib/cmd/batch-rewrite.js +0 -372
  33. package/dist/node_modules/mariadb/lib/cmd/change-user.js +0 -149
  34. package/dist/node_modules/mariadb/lib/cmd/class/ok-packet.js +0 -17
  35. package/dist/node_modules/mariadb/lib/cmd/column-definition.js +0 -102
  36. package/dist/node_modules/mariadb/lib/cmd/command.js +0 -168
  37. package/dist/node_modules/mariadb/lib/cmd/common-binary-cmd.js +0 -327
  38. package/dist/node_modules/mariadb/lib/cmd/common-text-cmd.js +0 -427
  39. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/caching-sha2-password-auth.js +0 -168
  40. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/clear-password-auth.js +0 -23
  41. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/ed25519-password-auth.js +0 -761
  42. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/native-password-auth.js +0 -55
  43. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/pam-password-auth.js +0 -58
  44. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/plugin-auth.js +0 -19
  45. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/sha256-password-auth.js +0 -142
  46. package/dist/node_modules/mariadb/lib/cmd/handshake/client-capabilities.js +0 -74
  47. package/dist/node_modules/mariadb/lib/cmd/handshake/client-handshake-response.js +0 -126
  48. package/dist/node_modules/mariadb/lib/cmd/handshake/handshake.js +0 -292
  49. package/dist/node_modules/mariadb/lib/cmd/handshake/initial-handshake.js +0 -74
  50. package/dist/node_modules/mariadb/lib/cmd/handshake/ssl-request.js +0 -29
  51. package/dist/node_modules/mariadb/lib/cmd/ping.js +0 -52
  52. package/dist/node_modules/mariadb/lib/cmd/query.js +0 -255
  53. package/dist/node_modules/mariadb/lib/cmd/quit.js +0 -28
  54. package/dist/node_modules/mariadb/lib/cmd/reset.js +0 -54
  55. package/dist/node_modules/mariadb/lib/cmd/resultset.js +0 -607
  56. package/dist/node_modules/mariadb/lib/cmd/stream.js +0 -45
  57. package/dist/node_modules/mariadb/lib/config/connection-options.js +0 -258
  58. package/dist/node_modules/mariadb/lib/config/pool-cluster-options.js +0 -19
  59. package/dist/node_modules/mariadb/lib/config/pool-options.js +0 -47
  60. package/dist/node_modules/mariadb/lib/connection-callback.js +0 -160
  61. package/dist/node_modules/mariadb/lib/connection.js +0 -1460
  62. package/dist/node_modules/mariadb/lib/const/capabilities.js +0 -64
  63. package/dist/node_modules/mariadb/lib/const/collations.js +0 -473
  64. package/dist/node_modules/mariadb/lib/const/connection_status.js +0 -13
  65. package/dist/node_modules/mariadb/lib/const/error-code.js +0 -1282
  66. package/dist/node_modules/mariadb/lib/const/field-detail.js +0 -35
  67. package/dist/node_modules/mariadb/lib/const/field-type.js +0 -71
  68. package/dist/node_modules/mariadb/lib/const/server-status.js +0 -30
  69. package/dist/node_modules/mariadb/lib/const/state-change.js +0 -12
  70. package/dist/node_modules/mariadb/lib/filtered-pool-cluster.js +0 -81
  71. package/dist/node_modules/mariadb/lib/io/bulk-packet.js +0 -590
  72. package/dist/node_modules/mariadb/lib/io/compression-input-stream.js +0 -141
  73. package/dist/node_modules/mariadb/lib/io/compression-output-stream.js +0 -171
  74. package/dist/node_modules/mariadb/lib/io/packet-input-stream.js +0 -193
  75. package/dist/node_modules/mariadb/lib/io/packet-node-encoded.js +0 -36
  76. package/dist/node_modules/mariadb/lib/io/packet-node-iconv.js +0 -37
  77. package/dist/node_modules/mariadb/lib/io/packet-output-stream.js +0 -502
  78. package/dist/node_modules/mariadb/lib/io/packet.js +0 -515
  79. package/dist/node_modules/mariadb/lib/io/rewrite-packet.js +0 -481
  80. package/dist/node_modules/mariadb/lib/misc/connection-information.js +0 -96
  81. package/dist/node_modules/mariadb/lib/misc/errors.js +0 -123
  82. package/dist/node_modules/mariadb/lib/misc/parse.js +0 -1033
  83. package/dist/node_modules/mariadb/lib/misc/utils.js +0 -298
  84. package/dist/node_modules/mariadb/lib/pool-base.js +0 -611
  85. package/dist/node_modules/mariadb/lib/pool-callback.js +0 -202
  86. package/dist/node_modules/mariadb/lib/pool-cluster-callback.js +0 -66
  87. package/dist/node_modules/mariadb/lib/pool-cluster.js +0 -407
  88. package/dist/node_modules/mariadb/lib/pool-promise.js +0 -108
  89. package/dist/node_modules/mariadb/node_modules/@types/node/assert/strict.d.ts +0 -8
  90. package/dist/node_modules/mariadb/node_modules/@types/node/assert.d.ts +0 -912
  91. package/dist/node_modules/mariadb/node_modules/@types/node/async_hooks.d.ts +0 -501
  92. package/dist/node_modules/mariadb/node_modules/@types/node/buffer.d.ts +0 -2232
  93. package/dist/node_modules/mariadb/node_modules/@types/node/child_process.d.ts +0 -1366
  94. package/dist/node_modules/mariadb/node_modules/@types/node/cluster.d.ts +0 -414
  95. package/dist/node_modules/mariadb/node_modules/@types/node/console.d.ts +0 -412
  96. package/dist/node_modules/mariadb/node_modules/@types/node/constants.d.ts +0 -18
  97. package/dist/node_modules/mariadb/node_modules/@types/node/crypto.d.ts +0 -3338
  98. package/dist/node_modules/mariadb/node_modules/@types/node/dgram.d.ts +0 -545
  99. package/dist/node_modules/mariadb/node_modules/@types/node/diagnostics_channel.d.ts +0 -152
  100. package/dist/node_modules/mariadb/node_modules/@types/node/dns/promises.d.ts +0 -370
  101. package/dist/node_modules/mariadb/node_modules/@types/node/dns.d.ts +0 -659
  102. package/dist/node_modules/mariadb/node_modules/@types/node/domain.d.ts +0 -169
  103. package/dist/node_modules/mariadb/node_modules/@types/node/events.d.ts +0 -651
  104. package/dist/node_modules/mariadb/node_modules/@types/node/fs/promises.d.ts +0 -1091
  105. package/dist/node_modules/mariadb/node_modules/@types/node/fs.d.ts +0 -3869
  106. package/dist/node_modules/mariadb/node_modules/@types/node/globals.d.ts +0 -294
  107. package/dist/node_modules/mariadb/node_modules/@types/node/globals.global.d.ts +0 -1
  108. package/dist/node_modules/mariadb/node_modules/@types/node/http.d.ts +0 -1396
  109. package/dist/node_modules/mariadb/node_modules/@types/node/http2.d.ts +0 -2101
  110. package/dist/node_modules/mariadb/node_modules/@types/node/https.d.ts +0 -391
  111. package/dist/node_modules/mariadb/node_modules/@types/node/index.d.ts +0 -129
  112. package/dist/node_modules/mariadb/node_modules/@types/node/inspector.d.ts +0 -2744
  113. package/dist/node_modules/mariadb/node_modules/@types/node/module.d.ts +0 -114
  114. package/dist/node_modules/mariadb/node_modules/@types/node/net.d.ts +0 -791
  115. package/dist/node_modules/mariadb/node_modules/@types/node/os.d.ts +0 -455
  116. package/dist/node_modules/mariadb/node_modules/@types/node/package.json +0 -220
  117. package/dist/node_modules/mariadb/node_modules/@types/node/path.d.ts +0 -180
  118. package/dist/node_modules/mariadb/node_modules/@types/node/perf_hooks.d.ts +0 -557
  119. package/dist/node_modules/mariadb/node_modules/@types/node/process.d.ts +0 -1481
  120. package/dist/node_modules/mariadb/node_modules/@types/node/punycode.d.ts +0 -117
  121. package/dist/node_modules/mariadb/node_modules/@types/node/querystring.d.ts +0 -131
  122. package/dist/node_modules/mariadb/node_modules/@types/node/readline.d.ts +0 -650
  123. package/dist/node_modules/mariadb/node_modules/@types/node/repl.d.ts +0 -424
  124. package/dist/node_modules/mariadb/node_modules/@types/node/stream/consumers.d.ts +0 -24
  125. package/dist/node_modules/mariadb/node_modules/@types/node/stream/promises.d.ts +0 -42
  126. package/dist/node_modules/mariadb/node_modules/@types/node/stream/web.d.ts +0 -330
  127. package/dist/node_modules/mariadb/node_modules/@types/node/stream.d.ts +0 -1249
  128. package/dist/node_modules/mariadb/node_modules/@types/node/string_decoder.d.ts +0 -67
  129. package/dist/node_modules/mariadb/node_modules/@types/node/timers/promises.d.ts +0 -68
  130. package/dist/node_modules/mariadb/node_modules/@types/node/timers.d.ts +0 -94
  131. package/dist/node_modules/mariadb/node_modules/@types/node/tls.d.ts +0 -1020
  132. package/dist/node_modules/mariadb/node_modules/@types/node/trace_events.d.ts +0 -161
  133. package/dist/node_modules/mariadb/node_modules/@types/node/tty.d.ts +0 -204
  134. package/dist/node_modules/mariadb/node_modules/@types/node/url.d.ts +0 -891
  135. package/dist/node_modules/mariadb/node_modules/@types/node/util.d.ts +0 -1594
  136. package/dist/node_modules/mariadb/node_modules/@types/node/v8.d.ts +0 -378
  137. package/dist/node_modules/mariadb/node_modules/@types/node/vm.d.ts +0 -507
  138. package/dist/node_modules/mariadb/node_modules/@types/node/wasi.d.ts +0 -158
  139. package/dist/node_modules/mariadb/node_modules/@types/node/worker_threads.d.ts +0 -649
  140. package/dist/node_modules/mariadb/node_modules/@types/node/zlib.d.ts +0 -517
  141. package/dist/node_modules/mariadb/package.json +0 -1
  142. package/dist/node_modules/mariadb/promise.js +0 -34
  143. package/dist/node_modules/mariadb/types/index.d.ts +0 -870
@@ -1,791 +0,0 @@
1
- /**
2
- * > Stability: 2 - Stable
3
- *
4
- * The `net` module provides an asynchronous network API for creating stream-based
5
- * TCP or `IPC` servers ({@link createServer}) and clients
6
- * ({@link createConnection}).
7
- *
8
- * It can be accessed using:
9
- *
10
- * ```js
11
- * const net = require('net');
12
- * ```
13
- * @see [source](https://github.com/nodejs/node/blob/v17.0.0/lib/net.js)
14
- */
15
- declare module 'net' {
16
- import * as stream from 'node:stream';
17
- import { Abortable, EventEmitter } from 'node:events';
18
- import * as dns from 'node:dns';
19
- type LookupFunction = (hostname: string, options: dns.LookupOneOptions, callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void) => void;
20
- interface AddressInfo {
21
- address: string;
22
- family: string;
23
- port: number;
24
- }
25
- interface SocketConstructorOpts {
26
- fd?: number | undefined;
27
- allowHalfOpen?: boolean | undefined;
28
- readable?: boolean | undefined;
29
- writable?: boolean | undefined;
30
- signal?: AbortSignal;
31
- }
32
- interface OnReadOpts {
33
- buffer: Uint8Array | (() => Uint8Array);
34
- /**
35
- * This function is called for every chunk of incoming data.
36
- * Two arguments are passed to it: the number of bytes written to buffer and a reference to buffer.
37
- * Return false from this function to implicitly pause() the socket.
38
- */
39
- callback(bytesWritten: number, buf: Uint8Array): boolean;
40
- }
41
- interface ConnectOpts {
42
- /**
43
- * If specified, incoming data is stored in a single buffer and passed to the supplied callback when data arrives on the socket.
44
- * Note: this will cause the streaming functionality to not provide any data, however events like 'error', 'end', and 'close' will
45
- * still be emitted as normal and methods like pause() and resume() will also behave as expected.
46
- */
47
- onread?: OnReadOpts | undefined;
48
- }
49
- interface TcpSocketConnectOpts extends ConnectOpts {
50
- port: number;
51
- host?: string | undefined;
52
- localAddress?: string | undefined;
53
- localPort?: number | undefined;
54
- hints?: number | undefined;
55
- family?: number | undefined;
56
- lookup?: LookupFunction | undefined;
57
- }
58
- interface IpcSocketConnectOpts extends ConnectOpts {
59
- path: string;
60
- }
61
- type SocketConnectOpts = TcpSocketConnectOpts | IpcSocketConnectOpts;
62
- type SocketReadyState = 'opening' | 'open' | 'readOnly' | 'writeOnly' | 'closed';
63
- /**
64
- * This class is an abstraction of a TCP socket or a streaming `IPC` endpoint
65
- * (uses named pipes on Windows, and Unix domain sockets otherwise). It is also
66
- * an `EventEmitter`.
67
- *
68
- * A `net.Socket` can be created by the user and used directly to interact with
69
- * a server. For example, it is returned by {@link createConnection},
70
- * so the user can use it to talk to the server.
71
- *
72
- * It can also be created by Node.js and passed to the user when a connection
73
- * is received. For example, it is passed to the listeners of a `'connection'` event emitted on a {@link Server}, so the user can use
74
- * it to interact with the client.
75
- * @since v0.3.4
76
- */
77
- class Socket extends stream.Duplex {
78
- constructor(options?: SocketConstructorOpts);
79
- /**
80
- * Sends data on the socket. The second parameter specifies the encoding in the
81
- * case of a string. It defaults to UTF8 encoding.
82
- *
83
- * Returns `true` if the entire data was flushed successfully to the kernel
84
- * buffer. Returns `false` if all or part of the data was queued in user memory.`'drain'` will be emitted when the buffer is again free.
85
- *
86
- * The optional `callback` parameter will be executed when the data is finally
87
- * written out, which may not be immediately.
88
- *
89
- * See `Writable` stream `write()` method for more
90
- * information.
91
- * @since v0.1.90
92
- * @param [encoding='utf8'] Only used when data is `string`.
93
- */
94
- write(buffer: Uint8Array | string, cb?: (err?: Error) => void): boolean;
95
- write(str: Uint8Array | string, encoding?: BufferEncoding, cb?: (err?: Error) => void): boolean;
96
- /**
97
- * Initiate a connection on a given socket.
98
- *
99
- * Possible signatures:
100
- *
101
- * * `socket.connect(options[, connectListener])`
102
- * * `socket.connect(path[, connectListener])` for `IPC` connections.
103
- * * `socket.connect(port[, host][, connectListener])` for TCP connections.
104
- * * Returns: `net.Socket` The socket itself.
105
- *
106
- * This function is asynchronous. When the connection is established, the `'connect'` event will be emitted. If there is a problem connecting,
107
- * instead of a `'connect'` event, an `'error'` event will be emitted with
108
- * the error passed to the `'error'` listener.
109
- * The last parameter `connectListener`, if supplied, will be added as a listener
110
- * for the `'connect'` event **once**.
111
- *
112
- * This function should only be used for reconnecting a socket after`'close'` has been emitted or otherwise it may lead to undefined
113
- * behavior.
114
- */
115
- connect(options: SocketConnectOpts, connectionListener?: () => void): this;
116
- connect(port: number, host: string, connectionListener?: () => void): this;
117
- connect(port: number, connectionListener?: () => void): this;
118
- connect(path: string, connectionListener?: () => void): this;
119
- /**
120
- * Set the encoding for the socket as a `Readable Stream`. See `readable.setEncoding()` for more information.
121
- * @since v0.1.90
122
- * @return The socket itself.
123
- */
124
- setEncoding(encoding?: BufferEncoding): this;
125
- /**
126
- * Pauses the reading of data. That is, `'data'` events will not be emitted.
127
- * Useful to throttle back an upload.
128
- * @return The socket itself.
129
- */
130
- pause(): this;
131
- /**
132
- * Resumes reading after a call to `socket.pause()`.
133
- * @return The socket itself.
134
- */
135
- resume(): this;
136
- /**
137
- * Sets the socket to timeout after `timeout` milliseconds of inactivity on
138
- * the socket. By default `net.Socket` do not have a timeout.
139
- *
140
- * When an idle timeout is triggered the socket will receive a `'timeout'` event but the connection will not be severed. The user must manually call `socket.end()` or `socket.destroy()` to
141
- * end the connection.
142
- *
143
- * ```js
144
- * socket.setTimeout(3000);
145
- * socket.on('timeout', () => {
146
- * console.log('socket timeout');
147
- * socket.end();
148
- * });
149
- * ```
150
- *
151
- * If `timeout` is 0, then the existing idle timeout is disabled.
152
- *
153
- * The optional `callback` parameter will be added as a one-time listener for the `'timeout'` event.
154
- * @since v0.1.90
155
- * @return The socket itself.
156
- */
157
- setTimeout(timeout: number, callback?: () => void): this;
158
- /**
159
- * Enable/disable the use of Nagle's algorithm.
160
- *
161
- * When a TCP connection is created, it will have Nagle's algorithm enabled.
162
- *
163
- * Nagle's algorithm delays data before it is sent via the network. It attempts
164
- * to optimize throughput at the expense of latency.
165
- *
166
- * Passing `true` for `noDelay` or not passing an argument will disable Nagle's
167
- * algorithm for the socket. Passing `false` for `noDelay` will enable Nagle's
168
- * algorithm.
169
- * @since v0.1.90
170
- * @param [noDelay=true]
171
- * @return The socket itself.
172
- */
173
- setNoDelay(noDelay?: boolean): this;
174
- /**
175
- * Enable/disable keep-alive functionality, and optionally set the initial
176
- * delay before the first keepalive probe is sent on an idle socket.
177
- *
178
- * Set `initialDelay` (in milliseconds) to set the delay between the last
179
- * data packet received and the first keepalive probe. Setting `0` for`initialDelay` will leave the value unchanged from the default
180
- * (or previous) setting.
181
- *
182
- * Enabling the keep-alive functionality will set the following socket options:
183
- *
184
- * * `SO_KEEPALIVE=1`
185
- * * `TCP_KEEPIDLE=initialDelay`
186
- * * `TCP_KEEPCNT=10`
187
- * * `TCP_KEEPINTVL=1`
188
- * @since v0.1.92
189
- * @param [enable=false]
190
- * @param [initialDelay=0]
191
- * @return The socket itself.
192
- */
193
- setKeepAlive(enable?: boolean, initialDelay?: number): this;
194
- /**
195
- * Returns the bound `address`, the address `family` name and `port` of the
196
- * socket as reported by the operating system:`{ port: 12346, family: 'IPv4', address: '127.0.0.1' }`
197
- * @since v0.1.90
198
- */
199
- address(): AddressInfo | {};
200
- /**
201
- * Calling `unref()` on a socket will allow the program to exit if this is the only
202
- * active socket in the event system. If the socket is already `unref`ed calling`unref()` again will have no effect.
203
- * @since v0.9.1
204
- * @return The socket itself.
205
- */
206
- unref(): this;
207
- /**
208
- * Opposite of `unref()`, calling `ref()` on a previously `unref`ed socket will_not_ let the program exit if it's the only socket left (the default behavior).
209
- * If the socket is `ref`ed calling `ref` again will have no effect.
210
- * @since v0.9.1
211
- * @return The socket itself.
212
- */
213
- ref(): this;
214
- /**
215
- * This property shows the number of characters buffered for writing. The buffer
216
- * may contain strings whose length after encoding is not yet known. So this number
217
- * is only an approximation of the number of bytes in the buffer.
218
- *
219
- * `net.Socket` has the property that `socket.write()` always works. This is to
220
- * help users get up and running quickly. The computer cannot always keep up
221
- * with the amount of data that is written to a socket. The network connection
222
- * simply might be too slow. Node.js will internally queue up the data written to a
223
- * socket and send it out over the wire when it is possible.
224
- *
225
- * The consequence of this internal buffering is that memory may grow.
226
- * Users who experience large or growing `bufferSize` should attempt to
227
- * "throttle" the data flows in their program with `socket.pause()` and `socket.resume()`.
228
- * @since v0.3.8
229
- * @deprecated Since v14.6.0 - Use `writableLength` instead.
230
- */
231
- readonly bufferSize: number;
232
- /**
233
- * The amount of received bytes.
234
- * @since v0.5.3
235
- */
236
- readonly bytesRead: number;
237
- /**
238
- * The amount of bytes sent.
239
- * @since v0.5.3
240
- */
241
- readonly bytesWritten: number;
242
- /**
243
- * If `true`,`socket.connect(options[, connectListener])` was
244
- * called and has not yet finished. It will stay `true` until the socket becomes
245
- * connected, then it is set to `false` and the `'connect'` event is emitted. Note
246
- * that the `socket.connect(options[, connectListener])` callback is a listener for the `'connect'` event.
247
- * @since v6.1.0
248
- */
249
- readonly connecting: boolean;
250
- /**
251
- * See `writable.destroyed` for further details.
252
- */
253
- readonly destroyed: boolean;
254
- /**
255
- * The string representation of the local IP address the remote client is
256
- * connecting on. For example, in a server listening on `'0.0.0.0'`, if a client
257
- * connects on `'192.168.1.1'`, the value of `socket.localAddress` would be`'192.168.1.1'`.
258
- * @since v0.9.6
259
- */
260
- readonly localAddress?: string;
261
- /**
262
- * The numeric representation of the local port. For example, `80` or `21`.
263
- * @since v0.9.6
264
- */
265
- readonly localPort?: number;
266
- /**
267
- * This property represents the state of the connection as a string.
268
- * @see {https://nodejs.org/api/net.html#socketreadystate}
269
- * @since v0.5.0
270
- */
271
- readonly readyState: SocketReadyState;
272
- /**
273
- * The string representation of the remote IP address. For example,`'74.125.127.100'` or `'2001:4860:a005::68'`. Value may be `undefined` if
274
- * the socket is destroyed (for example, if the client disconnected).
275
- * @since v0.5.10
276
- */
277
- readonly remoteAddress?: string | undefined;
278
- /**
279
- * The string representation of the remote IP family. `'IPv4'` or `'IPv6'`.
280
- * @since v0.11.14
281
- */
282
- readonly remoteFamily?: string | undefined;
283
- /**
284
- * The numeric representation of the remote port. For example, `80` or `21`.
285
- * @since v0.5.10
286
- */
287
- readonly remotePort?: number | undefined;
288
- /**
289
- * Half-closes the socket. i.e., it sends a FIN packet. It is possible the
290
- * server will still send some data.
291
- *
292
- * See `writable.end()` for further details.
293
- * @since v0.1.90
294
- * @param [encoding='utf8'] Only used when data is `string`.
295
- * @param callback Optional callback for when the socket is finished.
296
- * @return The socket itself.
297
- */
298
- end(callback?: () => void): this;
299
- end(buffer: Uint8Array | string, callback?: () => void): this;
300
- end(str: Uint8Array | string, encoding?: BufferEncoding, callback?: () => void): this;
301
- /**
302
- * events.EventEmitter
303
- * 1. close
304
- * 2. connect
305
- * 3. data
306
- * 4. drain
307
- * 5. end
308
- * 6. error
309
- * 7. lookup
310
- * 8. timeout
311
- */
312
- addListener(event: string, listener: (...args: any[]) => void): this;
313
- addListener(event: 'close', listener: (hadError: boolean) => void): this;
314
- addListener(event: 'connect', listener: () => void): this;
315
- addListener(event: 'data', listener: (data: Buffer) => void): this;
316
- addListener(event: 'drain', listener: () => void): this;
317
- addListener(event: 'end', listener: () => void): this;
318
- addListener(event: 'error', listener: (err: Error) => void): this;
319
- addListener(event: 'lookup', listener: (err: Error, address: string, family: string | number, host: string) => void): this;
320
- addListener(event: 'ready', listener: () => void): this;
321
- addListener(event: 'timeout', listener: () => void): this;
322
- emit(event: string | symbol, ...args: any[]): boolean;
323
- emit(event: 'close', hadError: boolean): boolean;
324
- emit(event: 'connect'): boolean;
325
- emit(event: 'data', data: Buffer): boolean;
326
- emit(event: 'drain'): boolean;
327
- emit(event: 'end'): boolean;
328
- emit(event: 'error', err: Error): boolean;
329
- emit(event: 'lookup', err: Error, address: string, family: string | number, host: string): boolean;
330
- emit(event: 'ready'): boolean;
331
- emit(event: 'timeout'): boolean;
332
- on(event: string, listener: (...args: any[]) => void): this;
333
- on(event: 'close', listener: (hadError: boolean) => void): this;
334
- on(event: 'connect', listener: () => void): this;
335
- on(event: 'data', listener: (data: Buffer) => void): this;
336
- on(event: 'drain', listener: () => void): this;
337
- on(event: 'end', listener: () => void): this;
338
- on(event: 'error', listener: (err: Error) => void): this;
339
- on(event: 'lookup', listener: (err: Error, address: string, family: string | number, host: string) => void): this;
340
- on(event: 'ready', listener: () => void): this;
341
- on(event: 'timeout', listener: () => void): this;
342
- once(event: string, listener: (...args: any[]) => void): this;
343
- once(event: 'close', listener: (hadError: boolean) => void): this;
344
- once(event: 'connect', listener: () => void): this;
345
- once(event: 'data', listener: (data: Buffer) => void): this;
346
- once(event: 'drain', listener: () => void): this;
347
- once(event: 'end', listener: () => void): this;
348
- once(event: 'error', listener: (err: Error) => void): this;
349
- once(event: 'lookup', listener: (err: Error, address: string, family: string | number, host: string) => void): this;
350
- once(event: 'ready', listener: () => void): this;
351
- once(event: 'timeout', listener: () => void): this;
352
- prependListener(event: string, listener: (...args: any[]) => void): this;
353
- prependListener(event: 'close', listener: (hadError: boolean) => void): this;
354
- prependListener(event: 'connect', listener: () => void): this;
355
- prependListener(event: 'data', listener: (data: Buffer) => void): this;
356
- prependListener(event: 'drain', listener: () => void): this;
357
- prependListener(event: 'end', listener: () => void): this;
358
- prependListener(event: 'error', listener: (err: Error) => void): this;
359
- prependListener(event: 'lookup', listener: (err: Error, address: string, family: string | number, host: string) => void): this;
360
- prependListener(event: 'ready', listener: () => void): this;
361
- prependListener(event: 'timeout', listener: () => void): this;
362
- prependOnceListener(event: string, listener: (...args: any[]) => void): this;
363
- prependOnceListener(event: 'close', listener: (hadError: boolean) => void): this;
364
- prependOnceListener(event: 'connect', listener: () => void): this;
365
- prependOnceListener(event: 'data', listener: (data: Buffer) => void): this;
366
- prependOnceListener(event: 'drain', listener: () => void): this;
367
- prependOnceListener(event: 'end', listener: () => void): this;
368
- prependOnceListener(event: 'error', listener: (err: Error) => void): this;
369
- prependOnceListener(event: 'lookup', listener: (err: Error, address: string, family: string | number, host: string) => void): this;
370
- prependOnceListener(event: 'ready', listener: () => void): this;
371
- prependOnceListener(event: 'timeout', listener: () => void): this;
372
- }
373
- interface ListenOptions extends Abortable {
374
- port?: number | undefined;
375
- host?: string | undefined;
376
- backlog?: number | undefined;
377
- path?: string | undefined;
378
- exclusive?: boolean | undefined;
379
- readableAll?: boolean | undefined;
380
- writableAll?: boolean | undefined;
381
- /**
382
- * @default false
383
- */
384
- ipv6Only?: boolean | undefined;
385
- }
386
- interface ServerOpts {
387
- /**
388
- * Indicates whether half-opened TCP connections are allowed.
389
- * @default false
390
- */
391
- allowHalfOpen?: boolean | undefined;
392
- /**
393
- * Indicates whether the socket should be paused on incoming connections.
394
- * @default false
395
- */
396
- pauseOnConnect?: boolean | undefined;
397
- }
398
- /**
399
- * This class is used to create a TCP or `IPC` server.
400
- * @since v0.1.90
401
- */
402
- class Server extends EventEmitter {
403
- constructor(connectionListener?: (socket: Socket) => void);
404
- constructor(options?: ServerOpts, connectionListener?: (socket: Socket) => void);
405
- /**
406
- * Start a server listening for connections. A `net.Server` can be a TCP or
407
- * an `IPC` server depending on what it listens to.
408
- *
409
- * Possible signatures:
410
- *
411
- * * `server.listen(handle[, backlog][, callback])`
412
- * * `server.listen(options[, callback])`
413
- * * `server.listen(path[, backlog][, callback])` for `IPC` servers
414
- * * `server.listen([port[, host[, backlog]]][, callback])` for TCP servers
415
- *
416
- * This function is asynchronous. When the server starts listening, the `'listening'` event will be emitted. The last parameter `callback`will be added as a listener for the `'listening'`
417
- * event.
418
- *
419
- * All `listen()` methods can take a `backlog` parameter to specify the maximum
420
- * length of the queue of pending connections. The actual length will be determined
421
- * by the OS through sysctl settings such as `tcp_max_syn_backlog` and `somaxconn`on Linux. The default value of this parameter is 511 (not 512).
422
- *
423
- * All {@link Socket} are set to `SO_REUSEADDR` (see [`socket(7)`](https://man7.org/linux/man-pages/man7/socket.7.html) for
424
- * details).
425
- *
426
- * The `server.listen()` method can be called again if and only if there was an
427
- * error during the first `server.listen()` call or `server.close()` has been
428
- * called. Otherwise, an `ERR_SERVER_ALREADY_LISTEN` error will be thrown.
429
- *
430
- * One of the most common errors raised when listening is `EADDRINUSE`.
431
- * This happens when another server is already listening on the requested`port`/`path`/`handle`. One way to handle this would be to retry
432
- * after a certain amount of time:
433
- *
434
- * ```js
435
- * server.on('error', (e) => {
436
- * if (e.code === 'EADDRINUSE') {
437
- * console.log('Address in use, retrying...');
438
- * setTimeout(() => {
439
- * server.close();
440
- * server.listen(PORT, HOST);
441
- * }, 1000);
442
- * }
443
- * });
444
- * ```
445
- */
446
- listen(port?: number, hostname?: string, backlog?: number, listeningListener?: () => void): this;
447
- listen(port?: number, hostname?: string, listeningListener?: () => void): this;
448
- listen(port?: number, backlog?: number, listeningListener?: () => void): this;
449
- listen(port?: number, listeningListener?: () => void): this;
450
- listen(path: string, backlog?: number, listeningListener?: () => void): this;
451
- listen(path: string, listeningListener?: () => void): this;
452
- listen(options: ListenOptions, listeningListener?: () => void): this;
453
- listen(handle: any, backlog?: number, listeningListener?: () => void): this;
454
- listen(handle: any, listeningListener?: () => void): this;
455
- /**
456
- * Stops the server from accepting new connections and keeps existing
457
- * connections. This function is asynchronous, the server is finally closed
458
- * when all connections are ended and the server emits a `'close'` event.
459
- * The optional `callback` will be called once the `'close'` event occurs. Unlike
460
- * that event, it will be called with an `Error` as its only argument if the server
461
- * was not open when it was closed.
462
- * @since v0.1.90
463
- * @param callback Called when the server is closed.
464
- */
465
- close(callback?: (err?: Error) => void): this;
466
- /**
467
- * Returns the bound `address`, the address `family` name, and `port` of the server
468
- * as reported by the operating system if listening on an IP socket
469
- * (useful to find which port was assigned when getting an OS-assigned address):`{ port: 12346, family: 'IPv4', address: '127.0.0.1' }`.
470
- *
471
- * For a server listening on a pipe or Unix domain socket, the name is returned
472
- * as a string.
473
- *
474
- * ```js
475
- * const server = net.createServer((socket) => {
476
- * socket.end('goodbye\n');
477
- * }).on('error', (err) => {
478
- * // Handle errors here.
479
- * throw err;
480
- * });
481
- *
482
- * // Grab an arbitrary unused port.
483
- * server.listen(() => {
484
- * console.log('opened server on', server.address());
485
- * });
486
- * ```
487
- *
488
- * `server.address()` returns `null` before the `'listening'` event has been
489
- * emitted or after calling `server.close()`.
490
- * @since v0.1.90
491
- */
492
- address(): AddressInfo | string | null;
493
- /**
494
- * Asynchronously get the number of concurrent connections on the server. Works
495
- * when sockets were sent to forks.
496
- *
497
- * Callback should take two arguments `err` and `count`.
498
- * @since v0.9.7
499
- */
500
- getConnections(cb: (error: Error | null, count: number) => void): void;
501
- /**
502
- * Opposite of `unref()`, calling `ref()` on a previously `unref`ed server will_not_ let the program exit if it's the only server left (the default behavior).
503
- * If the server is `ref`ed calling `ref()` again will have no effect.
504
- * @since v0.9.1
505
- */
506
- ref(): this;
507
- /**
508
- * Calling `unref()` on a server will allow the program to exit if this is the only
509
- * active server in the event system. If the server is already `unref`ed calling`unref()` again will have no effect.
510
- * @since v0.9.1
511
- */
512
- unref(): this;
513
- /**
514
- * Set this property to reject connections when the server's connection count gets
515
- * high.
516
- *
517
- * It is not recommended to use this option once a socket has been sent to a child
518
- * with `child_process.fork()`.
519
- * @since v0.2.0
520
- */
521
- maxConnections: number;
522
- connections: number;
523
- /**
524
- * Indicates whether or not the server is listening for connections.
525
- * @since v5.7.0
526
- */
527
- listening: boolean;
528
- /**
529
- * events.EventEmitter
530
- * 1. close
531
- * 2. connection
532
- * 3. error
533
- * 4. listening
534
- */
535
- addListener(event: string, listener: (...args: any[]) => void): this;
536
- addListener(event: 'close', listener: () => void): this;
537
- addListener(event: 'connection', listener: (socket: Socket) => void): this;
538
- addListener(event: 'error', listener: (err: Error) => void): this;
539
- addListener(event: 'listening', listener: () => void): this;
540
- emit(event: string | symbol, ...args: any[]): boolean;
541
- emit(event: 'close'): boolean;
542
- emit(event: 'connection', socket: Socket): boolean;
543
- emit(event: 'error', err: Error): boolean;
544
- emit(event: 'listening'): boolean;
545
- on(event: string, listener: (...args: any[]) => void): this;
546
- on(event: 'close', listener: () => void): this;
547
- on(event: 'connection', listener: (socket: Socket) => void): this;
548
- on(event: 'error', listener: (err: Error) => void): this;
549
- on(event: 'listening', listener: () => void): this;
550
- once(event: string, listener: (...args: any[]) => void): this;
551
- once(event: 'close', listener: () => void): this;
552
- once(event: 'connection', listener: (socket: Socket) => void): this;
553
- once(event: 'error', listener: (err: Error) => void): this;
554
- once(event: 'listening', listener: () => void): this;
555
- prependListener(event: string, listener: (...args: any[]) => void): this;
556
- prependListener(event: 'close', listener: () => void): this;
557
- prependListener(event: 'connection', listener: (socket: Socket) => void): this;
558
- prependListener(event: 'error', listener: (err: Error) => void): this;
559
- prependListener(event: 'listening', listener: () => void): this;
560
- prependOnceListener(event: string, listener: (...args: any[]) => void): this;
561
- prependOnceListener(event: 'close', listener: () => void): this;
562
- prependOnceListener(event: 'connection', listener: (socket: Socket) => void): this;
563
- prependOnceListener(event: 'error', listener: (err: Error) => void): this;
564
- prependOnceListener(event: 'listening', listener: () => void): this;
565
- }
566
- type IPVersion = 'ipv4' | 'ipv6';
567
- /**
568
- * The `BlockList` object can be used with some network APIs to specify rules for
569
- * disabling inbound or outbound access to specific IP addresses, IP ranges, or
570
- * IP subnets.
571
- * @since v15.0.0, v14.18.0
572
- */
573
- class BlockList {
574
- /**
575
- * Adds a rule to block the given IP address.
576
- * @since v15.0.0, v14.18.0
577
- * @param address An IPv4 or IPv6 address.
578
- * @param [type='ipv4'] Either `'ipv4'` or `'ipv6'`.
579
- */
580
- addAddress(address: string, type?: IPVersion): void;
581
- addAddress(address: SocketAddress): void;
582
- /**
583
- * Adds a rule to block a range of IP addresses from `start` (inclusive) to`end` (inclusive).
584
- * @since v15.0.0, v14.18.0
585
- * @param start The starting IPv4 or IPv6 address in the range.
586
- * @param end The ending IPv4 or IPv6 address in the range.
587
- * @param [type='ipv4'] Either `'ipv4'` or `'ipv6'`.
588
- */
589
- addRange(start: string, end: string, type?: IPVersion): void;
590
- addRange(start: SocketAddress, end: SocketAddress): void;
591
- /**
592
- * Adds a rule to block a range of IP addresses specified as a subnet mask.
593
- * @since v15.0.0, v14.18.0
594
- * @param net The network IPv4 or IPv6 address.
595
- * @param prefix The number of CIDR prefix bits. For IPv4, this must be a value between `0` and `32`. For IPv6, this must be between `0` and `128`.
596
- * @param [type='ipv4'] Either `'ipv4'` or `'ipv6'`.
597
- */
598
- addSubnet(net: SocketAddress, prefix: number): void;
599
- addSubnet(net: string, prefix: number, type?: IPVersion): void;
600
- /**
601
- * Returns `true` if the given IP address matches any of the rules added to the`BlockList`.
602
- *
603
- * ```js
604
- * const blockList = new net.BlockList();
605
- * blockList.addAddress('123.123.123.123');
606
- * blockList.addRange('10.0.0.1', '10.0.0.10');
607
- * blockList.addSubnet('8592:757c:efae:4e45::', 64, 'ipv6');
608
- *
609
- * console.log(blockList.check('123.123.123.123')); // Prints: true
610
- * console.log(blockList.check('10.0.0.3')); // Prints: true
611
- * console.log(blockList.check('222.111.111.222')); // Prints: false
612
- *
613
- * // IPv6 notation for IPv4 addresses works:
614
- * console.log(blockList.check('::ffff:7b7b:7b7b', 'ipv6')); // Prints: true
615
- * console.log(blockList.check('::ffff:123.123.123.123', 'ipv6')); // Prints: true
616
- * ```
617
- * @since v15.0.0, v14.18.0
618
- * @param address The IP address to check
619
- * @param [type='ipv4'] Either `'ipv4'` or `'ipv6'`.
620
- */
621
- check(address: SocketAddress): boolean;
622
- check(address: string, type?: IPVersion): boolean;
623
- }
624
- interface TcpNetConnectOpts extends TcpSocketConnectOpts, SocketConstructorOpts {
625
- timeout?: number | undefined;
626
- }
627
- interface IpcNetConnectOpts extends IpcSocketConnectOpts, SocketConstructorOpts {
628
- timeout?: number | undefined;
629
- }
630
- type NetConnectOpts = TcpNetConnectOpts | IpcNetConnectOpts;
631
- /**
632
- * Creates a new TCP or `IPC` server.
633
- *
634
- * If `allowHalfOpen` is set to `true`, when the other end of the socket
635
- * signals the end of transmission, the server will only send back the end of
636
- * transmission when `socket.end()` is explicitly called. For example, in the
637
- * context of TCP, when a FIN packed is received, a FIN packed is sent
638
- * back only when `socket.end()` is explicitly called. Until then the
639
- * connection is half-closed (non-readable but still writable). See `'end'` event and [RFC 1122](https://tools.ietf.org/html/rfc1122) (section 4.2.2.13) for more information.
640
- *
641
- * If `pauseOnConnect` is set to `true`, then the socket associated with each
642
- * incoming connection will be paused, and no data will be read from its handle.
643
- * This allows connections to be passed between processes without any data being
644
- * read by the original process. To begin reading data from a paused socket, call `socket.resume()`.
645
- *
646
- * The server can be a TCP server or an `IPC` server, depending on what it `listen()` to.
647
- *
648
- * Here is an example of an TCP echo server which listens for connections
649
- * on port 8124:
650
- *
651
- * ```js
652
- * const net = require('net');
653
- * const server = net.createServer((c) => {
654
- * // 'connection' listener.
655
- * console.log('client connected');
656
- * c.on('end', () => {
657
- * console.log('client disconnected');
658
- * });
659
- * c.write('hello\r\n');
660
- * c.pipe(c);
661
- * });
662
- * server.on('error', (err) => {
663
- * throw err;
664
- * });
665
- * server.listen(8124, () => {
666
- * console.log('server bound');
667
- * });
668
- * ```
669
- *
670
- * Test this by using `telnet`:
671
- *
672
- * ```console
673
- * $ telnet localhost 8124
674
- * ```
675
- *
676
- * To listen on the socket `/tmp/echo.sock`:
677
- *
678
- * ```js
679
- * server.listen('/tmp/echo.sock', () => {
680
- * console.log('server bound');
681
- * });
682
- * ```
683
- *
684
- * Use `nc` to connect to a Unix domain socket server:
685
- *
686
- * ```console
687
- * $ nc -U /tmp/echo.sock
688
- * ```
689
- * @since v0.5.0
690
- * @param connectionListener Automatically set as a listener for the {@link 'connection'} event.
691
- */
692
- function createServer(connectionListener?: (socket: Socket) => void): Server;
693
- function createServer(options?: ServerOpts, connectionListener?: (socket: Socket) => void): Server;
694
- /**
695
- * Aliases to {@link createConnection}.
696
- *
697
- * Possible signatures:
698
- *
699
- * * {@link connect}
700
- * * {@link connect} for `IPC` connections.
701
- * * {@link connect} for TCP connections.
702
- */
703
- function connect(options: NetConnectOpts, connectionListener?: () => void): Socket;
704
- function connect(port: number, host?: string, connectionListener?: () => void): Socket;
705
- function connect(path: string, connectionListener?: () => void): Socket;
706
- /**
707
- * A factory function, which creates a new {@link Socket},
708
- * immediately initiates connection with `socket.connect()`,
709
- * then returns the `net.Socket` that starts the connection.
710
- *
711
- * When the connection is established, a `'connect'` event will be emitted
712
- * on the returned socket. The last parameter `connectListener`, if supplied,
713
- * will be added as a listener for the `'connect'` event **once**.
714
- *
715
- * Possible signatures:
716
- *
717
- * * {@link createConnection}
718
- * * {@link createConnection} for `IPC` connections.
719
- * * {@link createConnection} for TCP connections.
720
- *
721
- * The {@link connect} function is an alias to this function.
722
- */
723
- function createConnection(options: NetConnectOpts, connectionListener?: () => void): Socket;
724
- function createConnection(port: number, host?: string, connectionListener?: () => void): Socket;
725
- function createConnection(path: string, connectionListener?: () => void): Socket;
726
- /**
727
- * Tests if input is an IP address. Returns `0` for invalid strings,
728
- * returns `4` for IP version 4 addresses, and returns `6` for IP version 6
729
- * addresses.
730
- * @since v0.3.0
731
- */
732
- function isIP(input: string): number;
733
- /**
734
- * Returns `true` if input is a version 4 IP address, otherwise returns `false`.
735
- * @since v0.3.0
736
- */
737
- function isIPv4(input: string): boolean;
738
- /**
739
- * Returns `true` if input is a version 6 IP address, otherwise returns `false`.
740
- * @since v0.3.0
741
- */
742
- function isIPv6(input: string): boolean;
743
- interface SocketAddressInitOptions {
744
- /**
745
- * The network address as either an IPv4 or IPv6 string.
746
- * @default 127.0.0.1
747
- */
748
- address?: string | undefined;
749
- /**
750
- * @default `'ipv4'`
751
- */
752
- family?: IPVersion | undefined;
753
- /**
754
- * An IPv6 flow-label used only if `family` is `'ipv6'`.
755
- * @default 0
756
- */
757
- flowlabel?: number | undefined;
758
- /**
759
- * An IP port.
760
- * @default 0
761
- */
762
- port?: number | undefined;
763
- }
764
- /**
765
- * @since v15.14.0, v14.18.0
766
- */
767
- class SocketAddress {
768
- constructor(options: SocketAddressInitOptions);
769
- /**
770
- * Either \`'ipv4'\` or \`'ipv6'\`.
771
- * @since v15.14.0, v14.18.0
772
- */
773
- readonly address: string;
774
- /**
775
- * Either \`'ipv4'\` or \`'ipv6'\`.
776
- * @since v15.14.0, v14.18.0
777
- */
778
- readonly family: IPVersion;
779
- /**
780
- * @since v15.14.0, v14.18.0
781
- */
782
- readonly port: number;
783
- /**
784
- * @since v15.14.0, v14.18.0
785
- */
786
- readonly flowlabel: number;
787
- }
788
- }
789
- declare module 'node:net' {
790
- export * from 'net';
791
- }