@litert/televoke 0.4.7 → 1.0.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.
- package/CHANGES.md +4 -2
- package/README.md +13 -8
- package/lib/client/Client.decl.d.ts +47 -0
- package/lib/client/Client.decl.d.ts.map +1 -0
- package/lib/client/Client.decl.js +18 -0
- package/lib/client/Client.decl.js.map +1 -0
- package/lib/client/JsonApiClient.impl.d.ts +28 -0
- package/lib/client/JsonApiClient.impl.d.ts.map +1 -0
- package/lib/client/JsonApiClient.impl.js +169 -0
- package/lib/client/JsonApiClient.impl.js.map +1 -0
- package/lib/client/LegacyHttpClient.impl.d.ts +62 -0
- package/lib/client/LegacyHttpClient.impl.d.ts.map +1 -0
- package/lib/client/LegacyHttpClient.impl.js +163 -0
- package/lib/client/LegacyHttpClient.impl.js.map +1 -0
- package/lib/client/index.d.ts +19 -0
- package/lib/client/index.d.ts.map +1 -0
- package/lib/client/index.js +35 -0
- package/lib/client/index.js.map +1 -0
- package/lib/index.d.ts +18 -20
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +19 -20
- package/lib/index.js.map +1 -1
- package/lib/server/LegacyServerChannel.impl.d.ts +38 -0
- package/lib/server/LegacyServerChannel.impl.d.ts.map +1 -0
- package/lib/server/LegacyServerChannel.impl.js +51 -0
- package/lib/server/LegacyServerChannel.impl.js.map +1 -0
- package/lib/server/Server.decl.d.ts +81 -0
- package/lib/server/Server.decl.d.ts.map +1 -0
- package/lib/server/Server.decl.js +18 -0
- package/lib/server/Server.decl.js.map +1 -0
- package/lib/server/Server.impl.d.ts +33 -0
- package/lib/server/Server.impl.d.ts.map +1 -0
- package/lib/server/Server.impl.js +58 -0
- package/lib/server/Server.impl.js.map +1 -0
- package/lib/server/ServerChannel.d.ts +20 -0
- package/lib/server/ServerChannel.d.ts.map +1 -0
- package/lib/server/ServerChannel.js +23 -0
- package/lib/server/ServerChannel.js.map +1 -0
- package/lib/server/SimpleJsonApiRouter.d.ts +28 -0
- package/lib/server/SimpleJsonApiRouter.d.ts.map +1 -0
- package/lib/server/SimpleJsonApiRouter.js +92 -0
- package/lib/server/SimpleJsonApiRouter.js.map +1 -0
- package/lib/server/index.d.ts +19 -0
- package/lib/server/index.d.ts.map +1 -0
- package/lib/server/index.js +35 -0
- package/lib/server/index.js.map +1 -0
- package/lib/shared/BinaryStream.d.ts +32 -0
- package/lib/shared/BinaryStream.d.ts.map +1 -0
- package/lib/shared/BinaryStream.js +93 -0
- package/lib/shared/BinaryStream.js.map +1 -0
- package/lib/shared/BinaryStreamManager.d.ts +52 -0
- package/lib/shared/BinaryStreamManager.d.ts.map +1 -0
- package/lib/shared/BinaryStreamManager.js +105 -0
- package/lib/shared/BinaryStreamManager.js.map +1 -0
- package/lib/shared/Channel.impl.d.ts +79 -0
- package/lib/shared/Channel.impl.d.ts.map +1 -0
- package/lib/shared/Channel.impl.js +433 -0
- package/lib/shared/Channel.impl.js.map +1 -0
- package/lib/shared/Constants.d.ts +32 -0
- package/lib/shared/Constants.d.ts.map +1 -0
- package/lib/shared/Constants.js +35 -0
- package/lib/shared/Constants.js.map +1 -0
- package/lib/shared/Encodings/index.d.ts +18 -0
- package/lib/shared/Encodings/index.d.ts.map +1 -0
- package/lib/shared/Encodings/index.js +21 -0
- package/lib/shared/Encodings/index.js.map +1 -0
- package/lib/shared/Encodings/v1/EncoderV1.d.ts +22 -0
- package/lib/shared/Encodings/v1/EncoderV1.d.ts.map +1 -0
- package/lib/shared/Encodings/v1/EncoderV1.js +47 -0
- package/lib/shared/Encodings/v1/EncoderV1.js.map +1 -0
- package/lib/shared/Encodings/v1/Protocol.v1.decls.d.ts +78 -0
- package/lib/shared/Encodings/v1/Protocol.v1.decls.d.ts.map +1 -0
- package/lib/shared/Encodings/v1/Protocol.v1.decls.js +53 -0
- package/lib/shared/Encodings/v1/Protocol.v1.decls.js.map +1 -0
- package/lib/shared/Encodings/v1/index.d.ts +18 -0
- package/lib/shared/Encodings/v1/index.d.ts.map +1 -0
- package/lib/shared/Encodings/v1/index.js +34 -0
- package/lib/shared/Encodings/v1/index.js.map +1 -0
- package/lib/shared/Encodings/v2/Constants.v2.d.ts +29 -0
- package/lib/shared/Encodings/v2/Constants.v2.d.ts.map +1 -0
- package/lib/shared/Encodings/v2/Constants.v2.js +34 -0
- package/lib/shared/Encodings/v2/Constants.v2.js.map +1 -0
- package/lib/shared/Encodings/v2/DecoderV2.d.ts +27 -0
- package/lib/shared/Encodings/v2/DecoderV2.d.ts.map +1 -0
- package/lib/shared/Encodings/v2/DecoderV2.js +279 -0
- package/lib/shared/Encodings/v2/DecoderV2.js.map +1 -0
- package/lib/shared/Encodings/v2/EncoderV2.d.ts +21 -0
- package/lib/shared/Encodings/v2/EncoderV2.d.ts.map +1 -0
- package/lib/shared/Encodings/v2/EncoderV2.js +176 -0
- package/lib/shared/Encodings/v2/EncoderV2.js.map +1 -0
- package/lib/shared/Encodings/v2/Encoding.v2.decl.d.ts +95 -0
- package/lib/shared/Encodings/v2/Encoding.v2.decl.d.ts.map +1 -0
- package/lib/shared/Encodings/v2/Encoding.v2.decl.js +18 -0
- package/lib/shared/Encodings/v2/Encoding.v2.decl.js.map +1 -0
- package/lib/shared/Encodings/v2/index.d.ts +20 -0
- package/lib/shared/Encodings/v2/index.d.ts.map +1 -0
- package/lib/shared/Encodings/v2/index.js +35 -0
- package/lib/shared/Encodings/v2/index.js.map +1 -0
- package/lib/shared/Errors.d.ts +60 -0
- package/lib/shared/Errors.d.ts.map +1 -0
- package/lib/shared/Errors.js +75 -0
- package/lib/shared/Errors.js.map +1 -0
- package/lib/shared/Shared.decl.d.ts +296 -0
- package/lib/shared/Shared.decl.d.ts.map +1 -0
- package/lib/shared/Shared.decl.js +18 -0
- package/lib/shared/Shared.decl.js.map +1 -0
- package/lib/shared/Utils.d.ts +25 -0
- package/lib/shared/Utils.d.ts.map +1 -0
- package/lib/shared/Utils.js +46 -0
- package/lib/shared/Utils.js.map +1 -0
- package/lib/shared/index.d.ts +23 -0
- package/lib/shared/index.d.ts.map +1 -0
- package/lib/shared/index.js +39 -0
- package/lib/shared/index.js.map +1 -0
- package/lib/transporters/Transporter.decl.d.ts +90 -0
- package/lib/transporters/Transporter.decl.d.ts.map +1 -0
- package/lib/transporters/Transporter.decl.js +18 -0
- package/lib/transporters/Transporter.decl.js.map +1 -0
- package/lib/transporters/http-listener/AbstractHttpListener.d.ts +32 -0
- package/lib/transporters/http-listener/AbstractHttpListener.d.ts.map +1 -0
- package/lib/transporters/http-listener/AbstractHttpListener.js +46 -0
- package/lib/transporters/http-listener/AbstractHttpListener.js.map +1 -0
- package/lib/transporters/http-listener/Http.Decl.d.ts +95 -0
- package/lib/transporters/http-listener/Http.Decl.d.ts.map +1 -0
- package/lib/transporters/http-listener/Http.Decl.js +52 -0
- package/lib/transporters/http-listener/Http.Decl.js.map +1 -0
- package/lib/transporters/http-listener/HttpListener.d.ts +18 -0
- package/lib/transporters/http-listener/HttpListener.d.ts.map +1 -0
- package/lib/transporters/http-listener/HttpListener.js +73 -0
- package/lib/transporters/http-listener/HttpListener.js.map +1 -0
- package/lib/transporters/http-listener/HttpUnixSocketListener.d.ts +18 -0
- package/lib/transporters/http-listener/HttpUnixSocketListener.d.ts.map +1 -0
- package/lib/transporters/http-listener/HttpUnixSocketListener.js +72 -0
- package/lib/transporters/http-listener/HttpUnixSocketListener.js.map +1 -0
- package/lib/transporters/http-listener/HttpsListener.d.ts +18 -0
- package/lib/transporters/http-listener/HttpsListener.d.ts.map +1 -0
- package/lib/transporters/http-listener/HttpsListener.js +73 -0
- package/lib/transporters/http-listener/HttpsListener.js.map +1 -0
- package/lib/transporters/http-listener/index.d.ts +20 -0
- package/lib/transporters/http-listener/index.d.ts.map +1 -0
- package/lib/transporters/http-listener/index.js +36 -0
- package/lib/transporters/http-listener/index.js.map +1 -0
- package/lib/transporters/index.d.ts +17 -0
- package/lib/transporters/index.d.ts.map +1 -0
- package/lib/transporters/index.js +18 -0
- package/lib/transporters/index.js.map +1 -0
- package/lib/transporters/legacy-http/LegacyHttp.Server.d.ts +24 -0
- package/lib/transporters/legacy-http/LegacyHttp.Server.d.ts.map +1 -0
- package/lib/transporters/legacy-http/LegacyHttp.Server.js +167 -0
- package/lib/transporters/legacy-http/LegacyHttp.Server.js.map +1 -0
- package/lib/transporters/legacy-http/LegacyHttp.Transporter.d.ts +28 -0
- package/lib/transporters/legacy-http/LegacyHttp.Transporter.d.ts.map +1 -0
- package/lib/transporters/legacy-http/LegacyHttp.Transporter.js +55 -0
- package/lib/transporters/legacy-http/LegacyHttp.Transporter.js.map +1 -0
- package/lib/transporters/legacy-http/index.d.ts +18 -0
- package/lib/transporters/legacy-http/index.d.ts.map +1 -0
- package/lib/transporters/legacy-http/index.js +34 -0
- package/lib/transporters/legacy-http/index.js.map +1 -0
- package/lib/transporters/lwdfx/LwDFX.Tcp.Client.d.ts +19 -0
- package/lib/transporters/lwdfx/LwDFX.Tcp.Client.d.ts.map +1 -0
- package/lib/transporters/lwdfx/LwDFX.Tcp.Client.js +33 -0
- package/lib/transporters/lwdfx/LwDFX.Tcp.Client.js.map +1 -0
- package/lib/transporters/lwdfx/LwDFX.Tcp.Server.d.ts +21 -0
- package/lib/transporters/lwdfx/LwDFX.Tcp.Server.d.ts.map +1 -0
- package/lib/transporters/lwdfx/LwDFX.Tcp.Server.js +64 -0
- package/lib/transporters/lwdfx/LwDFX.Tcp.Server.js.map +1 -0
- package/lib/transporters/lwdfx/LwDFX.Tls.Client.d.ts +19 -0
- package/lib/transporters/lwdfx/LwDFX.Tls.Client.d.ts.map +1 -0
- package/lib/transporters/lwdfx/LwDFX.Tls.Client.js +33 -0
- package/lib/transporters/lwdfx/LwDFX.Tls.Client.js.map +1 -0
- package/lib/transporters/lwdfx/LwDFX.Tls.Server.d.ts +21 -0
- package/lib/transporters/lwdfx/LwDFX.Tls.Server.d.ts.map +1 -0
- package/lib/transporters/lwdfx/LwDFX.Tls.Server.js +64 -0
- package/lib/transporters/lwdfx/LwDFX.Tls.Server.js.map +1 -0
- package/lib/transporters/lwdfx/LwDFX.Transporter.d.ts +34 -0
- package/lib/transporters/lwdfx/LwDFX.Transporter.d.ts.map +1 -0
- package/lib/transporters/lwdfx/LwDFX.Transporter.js +78 -0
- package/lib/transporters/lwdfx/LwDFX.Transporter.js.map +1 -0
- package/lib/transporters/lwdfx/LwDFX.UnixSocket.Client.d.ts +19 -0
- package/lib/transporters/lwdfx/LwDFX.UnixSocket.Client.d.ts.map +1 -0
- package/lib/transporters/lwdfx/LwDFX.UnixSocket.Client.js +33 -0
- package/lib/transporters/lwdfx/LwDFX.UnixSocket.Client.js.map +1 -0
- package/lib/transporters/lwdfx/LwDFX.UnixSocket.Server.d.ts +21 -0
- package/lib/transporters/lwdfx/LwDFX.UnixSocket.Server.d.ts.map +1 -0
- package/lib/transporters/lwdfx/LwDFX.UnixSocket.Server.js +64 -0
- package/lib/transporters/lwdfx/LwDFX.UnixSocket.Server.js.map +1 -0
- package/lib/transporters/lwdfx/LwDFX.decl.d.ts +18 -0
- package/lib/transporters/lwdfx/LwDFX.decl.d.ts.map +1 -0
- package/lib/transporters/lwdfx/LwDFX.decl.js +18 -0
- package/lib/transporters/lwdfx/LwDFX.decl.js.map +1 -0
- package/lib/transporters/lwdfx/index.d.ts +23 -0
- package/lib/transporters/lwdfx/index.d.ts.map +1 -0
- package/lib/transporters/lwdfx/index.js +39 -0
- package/lib/transporters/lwdfx/index.js.map +1 -0
- package/lib/transporters/memory/Memory.Impl.d.ts +43 -0
- package/lib/transporters/memory/Memory.Impl.d.ts.map +1 -0
- package/lib/transporters/memory/Memory.Impl.js +227 -0
- package/lib/transporters/memory/Memory.Impl.js.map +1 -0
- package/lib/transporters/memory/index.d.ts +17 -0
- package/lib/transporters/memory/index.d.ts.map +1 -0
- package/lib/transporters/memory/index.js +33 -0
- package/lib/transporters/memory/index.js.map +1 -0
- package/lib/transporters/websocket/WebSocket.Client.d.ts +20 -0
- package/lib/transporters/websocket/WebSocket.Client.d.ts.map +1 -0
- package/lib/transporters/websocket/WebSocket.Client.js +68 -0
- package/lib/transporters/websocket/WebSocket.Client.js.map +1 -0
- package/lib/transporters/websocket/WebSocket.Server.d.ts +25 -0
- package/lib/transporters/websocket/WebSocket.Server.d.ts.map +1 -0
- package/lib/transporters/websocket/WebSocket.Server.js +87 -0
- package/lib/transporters/websocket/WebSocket.Server.js.map +1 -0
- package/lib/transporters/websocket/WebSocket.Transporter.d.ts +34 -0
- package/lib/transporters/websocket/WebSocket.Transporter.d.ts.map +1 -0
- package/lib/transporters/websocket/WebSocket.Transporter.js +106 -0
- package/lib/transporters/websocket/WebSocket.Transporter.js.map +1 -0
- package/lib/transporters/websocket/WebSocket.decl.d.ts +19 -0
- package/lib/transporters/websocket/WebSocket.decl.d.ts.map +1 -0
- package/lib/transporters/websocket/WebSocket.decl.js +22 -0
- package/lib/transporters/websocket/WebSocket.decl.js.map +1 -0
- package/lib/transporters/websocket/index.d.ts +19 -0
- package/lib/transporters/websocket/index.d.ts.map +1 -0
- package/lib/transporters/websocket/index.js +35 -0
- package/lib/transporters/websocket/index.js.map +1 -0
- package/package.json +12 -12
- package/src/lib/client/Client.decl.ts +61 -0
- package/src/lib/client/JsonApiClient.impl.ts +258 -0
- package/src/lib/client/LegacyHttpClient.impl.ts +278 -0
- package/src/lib/client/index.ts +19 -0
- package/src/lib/index.ts +18 -20
- package/src/lib/server/LegacyServerChannel.impl.ts +71 -0
- package/src/lib/server/Server.decl.ts +109 -0
- package/src/lib/server/Server.impl.ts +90 -0
- package/src/lib/server/ServerChannel.ts +20 -0
- package/src/lib/server/SimpleJsonApiRouter.ts +135 -0
- package/src/lib/server/index.ts +19 -0
- package/src/lib/shared/BinaryStream.ts +131 -0
- package/src/lib/shared/BinaryStreamManager.ts +142 -0
- package/src/lib/shared/Channel.impl.ts +641 -0
- package/src/lib/shared/Constants.ts +35 -0
- package/src/lib/shared/Encodings/index.ts +18 -0
- package/src/lib/shared/Encodings/v1/EncoderV1.ts +66 -0
- package/src/lib/shared/Encodings/v1/Protocol.v1.decls.ts +96 -0
- package/src/lib/shared/Encodings/v1/index.ts +18 -0
- package/src/lib/shared/Encodings/v2/Constants.v2.ts +31 -0
- package/src/lib/shared/Encodings/v2/DecoderV2.ts +404 -0
- package/src/lib/shared/Encodings/v2/EncoderV2.ts +283 -0
- package/src/lib/shared/Encodings/v2/Encoding.v2.decl.ts +133 -0
- package/src/lib/shared/Encodings/v2/index.ts +20 -0
- package/src/lib/shared/Errors.ts +94 -0
- package/src/lib/shared/Shared.decl.ts +347 -0
- package/src/lib/shared/Utils.ts +51 -0
- package/src/lib/shared/index.ts +23 -0
- package/src/lib/transporters/Transporter.decl.ts +117 -0
- package/src/lib/transporters/http-listener/AbstractHttpListener.ts +57 -0
- package/src/lib/transporters/http-listener/Http.Decl.ts +141 -0
- package/src/lib/transporters/http-listener/HttpListener.ts +102 -0
- package/src/lib/transporters/http-listener/HttpUnixSocketListener.ts +97 -0
- package/src/lib/transporters/http-listener/HttpsListener.ts +102 -0
- package/src/lib/transporters/http-listener/index.ts +20 -0
- package/src/lib/transporters/index.ts +17 -0
- package/src/lib/transporters/legacy-http/LegacyHttp.Server.ts +262 -0
- package/src/lib/transporters/legacy-http/LegacyHttp.Transporter.ts +66 -0
- package/src/lib/transporters/legacy-http/index.ts +18 -0
- package/src/lib/transporters/lwdfx/LwDFX.Tcp.Client.ts +34 -0
- package/src/lib/transporters/lwdfx/LwDFX.Tcp.Server.ts +94 -0
- package/src/lib/transporters/lwdfx/LwDFX.Tls.Client.ts +34 -0
- package/src/lib/transporters/lwdfx/LwDFX.Tls.Server.ts +94 -0
- package/src/lib/transporters/lwdfx/LwDFX.Transporter.ts +100 -0
- package/src/lib/transporters/lwdfx/LwDFX.UnixSocket.Client.ts +34 -0
- package/src/lib/transporters/lwdfx/LwDFX.UnixSocket.Server.ts +94 -0
- package/src/lib/transporters/lwdfx/LwDFX.decl.ts +19 -0
- package/src/lib/transporters/lwdfx/index.ts +23 -0
- package/src/lib/transporters/memory/Memory.Impl.ts +363 -0
- package/src/lib/transporters/memory/index.ts +17 -0
- package/src/lib/transporters/websocket/WebSocket.Client.ts +76 -0
- package/src/lib/transporters/websocket/WebSocket.Server.ts +118 -0
- package/src/lib/transporters/websocket/WebSocket.Transporter.ts +132 -0
- package/src/lib/transporters/websocket/WebSocket.decl.ts +21 -0
- package/src/lib/transporters/websocket/index.ts +19 -0
- package/lib/Client/BuiltInRIDGenerator.d.ts +0 -4
- package/lib/Client/BuiltInRIDGenerator.d.ts.map +0 -1
- package/lib/Client/BuiltInRIDGenerator.js +0 -18
- package/lib/Client/BuiltInRIDGenerator.js.map +0 -1
- package/lib/Client/Common.d.ts +0 -47
- package/lib/Client/Common.d.ts.map +0 -1
- package/lib/Client/Common.js +0 -18
- package/lib/Client/Common.js.map +0 -1
- package/lib/Client/Errors.d.ts +0 -26
- package/lib/Client/Errors.d.ts.map +0 -1
- package/lib/Client/Errors.js +0 -80
- package/lib/Client/Errors.js.map +0 -1
- package/lib/Client/HttpClient.d.ts +0 -37
- package/lib/Client/HttpClient.d.ts.map +0 -1
- package/lib/Client/HttpClient.js +0 -148
- package/lib/Client/HttpClient.js.map +0 -1
- package/lib/Client/HttpsClient.d.ts +0 -40
- package/lib/Client/HttpsClient.d.ts.map +0 -1
- package/lib/Client/HttpsClient.js +0 -144
- package/lib/Client/HttpsClient.js.map +0 -1
- package/lib/Client/TCPClient.d.ts +0 -34
- package/lib/Client/TCPClient.d.ts.map +0 -1
- package/lib/Client/TCPClient.js +0 -271
- package/lib/Client/TCPClient.js.map +0 -1
- package/lib/Client/TLSClient.d.ts +0 -34
- package/lib/Client/TLSClient.d.ts.map +0 -1
- package/lib/Client/TLSClient.js +0 -265
- package/lib/Client/TLSClient.js.map +0 -1
- package/lib/Client/index.d.ts +0 -23
- package/lib/Client/index.d.ts.map +0 -1
- package/lib/Client/index.js +0 -39
- package/lib/Client/index.js.map +0 -1
- package/lib/Common/API.d.ts +0 -19
- package/lib/Common/API.d.ts.map +0 -1
- package/lib/Common/API.js +0 -18
- package/lib/Common/API.js.map +0 -1
- package/lib/Common/Encoding.d.ts +0 -32
- package/lib/Common/Encoding.d.ts.map +0 -1
- package/lib/Common/Encoding.js +0 -20
- package/lib/Common/Encoding.js.map +0 -1
- package/lib/Common/Request.d.ts +0 -23
- package/lib/Common/Request.d.ts.map +0 -1
- package/lib/Common/Request.js +0 -18
- package/lib/Common/Request.js.map +0 -1
- package/lib/Common/Response.d.ts +0 -60
- package/lib/Common/Response.d.ts.map +0 -1
- package/lib/Common/Response.js +0 -42
- package/lib/Common/Response.js.map +0 -1
- package/lib/Common/index.d.ts +0 -20
- package/lib/Common/index.d.ts.map +0 -1
- package/lib/Common/index.js +0 -36
- package/lib/Common/index.js.map +0 -1
- package/lib/Encoder/Decoder.d.ts +0 -18
- package/lib/Encoder/Decoder.d.ts.map +0 -1
- package/lib/Encoder/Decoder.js +0 -136
- package/lib/Encoder/Decoder.js.map +0 -1
- package/lib/Encoder/Encoder.d.ts +0 -18
- package/lib/Encoder/Encoder.d.ts.map +0 -1
- package/lib/Encoder/Encoder.js +0 -35
- package/lib/Encoder/Encoder.js.map +0 -1
- package/lib/Encoder/Errors.d.ts +0 -17
- package/lib/Encoder/Errors.d.ts.map +0 -1
- package/lib/Encoder/Errors.js +0 -26
- package/lib/Encoder/Errors.js.map +0 -1
- package/lib/Errors.d.ts +0 -20
- package/lib/Errors.d.ts.map +0 -1
- package/lib/Errors.js +0 -40
- package/lib/Errors.js.map +0 -1
- package/lib/Server/Common/Gateway.d.ts +0 -26
- package/lib/Server/Common/Gateway.d.ts.map +0 -1
- package/lib/Server/Common/Gateway.js +0 -18
- package/lib/Server/Common/Gateway.js.map +0 -1
- package/lib/Server/Common/Request.d.ts +0 -21
- package/lib/Server/Common/Request.d.ts.map +0 -1
- package/lib/Server/Common/Request.js +0 -18
- package/lib/Server/Common/Request.js.map +0 -1
- package/lib/Server/Common/Router.d.ts +0 -41
- package/lib/Server/Common/Router.d.ts.map +0 -1
- package/lib/Server/Common/Router.js +0 -18
- package/lib/Server/Common/Router.js.map +0 -1
- package/lib/Server/Common/Server.d.ts +0 -57
- package/lib/Server/Common/Server.d.ts.map +0 -1
- package/lib/Server/Common/Server.js +0 -18
- package/lib/Server/Common/Server.js.map +0 -1
- package/lib/Server/Common/index.d.ts +0 -20
- package/lib/Server/Common/index.d.ts.map +0 -1
- package/lib/Server/Common/index.js +0 -36
- package/lib/Server/Common/index.js.map +0 -1
- package/lib/Server/Errors.d.ts +0 -25
- package/lib/Server/Errors.d.ts.map +0 -1
- package/lib/Server/Errors.js +0 -74
- package/lib/Server/Errors.js.map +0 -1
- package/lib/Server/Gateways/Http.d.ts +0 -18
- package/lib/Server/Gateways/Http.d.ts.map +0 -1
- package/lib/Server/Gateways/Http.js +0 -148
- package/lib/Server/Gateways/Http.js.map +0 -1
- package/lib/Server/Gateways/TCP.d.ts +0 -23
- package/lib/Server/Gateways/TCP.d.ts.map +0 -1
- package/lib/Server/Gateways/TCP.js +0 -146
- package/lib/Server/Gateways/TCP.js.map +0 -1
- package/lib/Server/Server.d.ts +0 -18
- package/lib/Server/Server.d.ts.map +0 -1
- package/lib/Server/Server.js +0 -200
- package/lib/Server/Server.js.map +0 -1
- package/lib/Server/SimpleRouter.d.ts +0 -41
- package/lib/Server/SimpleRouter.d.ts.map +0 -1
- package/lib/Server/SimpleRouter.js +0 -54
- package/lib/Server/SimpleRouter.js.map +0 -1
- package/lib/Server/index.d.ts +0 -22
- package/lib/Server/index.d.ts.map +0 -1
- package/lib/Server/index.js +0 -38
- package/lib/Server/index.js.map +0 -1
- package/src/lib/Client/BuiltInRIDGenerator.ts +0 -21
- package/src/lib/Client/Common.ts +0 -63
- package/src/lib/Client/Errors.ts +0 -87
- package/src/lib/Client/HttpClient.ts +0 -232
- package/src/lib/Client/HttpsClient.ts +0 -238
- package/src/lib/Client/TCPClient.ts +0 -420
- package/src/lib/Client/TLSClient.ts +0 -422
- package/src/lib/Client/index.ts +0 -23
- package/src/lib/Common/API.ts +0 -20
- package/src/lib/Common/Encoding.ts +0 -42
- package/src/lib/Common/Request.ts +0 -28
- package/src/lib/Common/Response.ts +0 -67
- package/src/lib/Common/index.ts +0 -20
- package/src/lib/Encoder/Decoder.ts +0 -206
- package/src/lib/Encoder/Encoder.ts +0 -41
- package/src/lib/Encoder/Errors.ts +0 -24
- package/src/lib/Errors.ts +0 -40
- package/src/lib/Server/Common/Gateway.ts +0 -37
- package/src/lib/Server/Common/Request.ts +0 -24
- package/src/lib/Server/Common/Router.ts +0 -52
- package/src/lib/Server/Common/Server.ts +0 -68
- package/src/lib/Server/Common/index.ts +0 -20
- package/src/lib/Server/Errors.ts +0 -80
- package/src/lib/Server/Gateways/Http.ts +0 -209
- package/src/lib/Server/Gateways/TCP.ts +0 -221
- package/src/lib/Server/Server.ts +0 -268
- package/src/lib/Server/SimpleRouter.ts +0 -95
- package/src/lib/Server/index.ts +0 -22
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023 Angus.Fenying <fenying@litert.org>
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import * as dEncV1 from './Protocol.v1.decls';
|
|
18
|
+
|
|
19
|
+
export class TvEncoderV1 {
|
|
20
|
+
|
|
21
|
+
public encodeApiRequest(
|
|
22
|
+
rid: string | number,
|
|
23
|
+
name: string,
|
|
24
|
+
args: unknown,
|
|
25
|
+
timeout: number,
|
|
26
|
+
): string {
|
|
27
|
+
|
|
28
|
+
return JSON.stringify({
|
|
29
|
+
ttl: timeout,
|
|
30
|
+
rid,
|
|
31
|
+
api: name,
|
|
32
|
+
args,
|
|
33
|
+
cst: Date.now(),
|
|
34
|
+
} satisfies dEncV1.IRequestPayloadV1);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public encodeApiOkResponse(
|
|
38
|
+
rid: string | number,
|
|
39
|
+
body: unknown,
|
|
40
|
+
recvAt: number
|
|
41
|
+
): string {
|
|
42
|
+
|
|
43
|
+
return JSON.stringify({
|
|
44
|
+
rid,
|
|
45
|
+
body,
|
|
46
|
+
sst: Date.now(),
|
|
47
|
+
srt: recvAt,
|
|
48
|
+
code: dEncV1.EResponseCode.OK,
|
|
49
|
+
} satisfies dEncV1.IResponsePayloadV1);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
public encodeApiErrorResponse(
|
|
53
|
+
rid: string | number,
|
|
54
|
+
errorCode: dEncV1.EResponseCode,
|
|
55
|
+
body: string,
|
|
56
|
+
recvAt: number
|
|
57
|
+
): string {
|
|
58
|
+
|
|
59
|
+
if (typeof rid === 'string') {
|
|
60
|
+
|
|
61
|
+
rid = JSON.stringify(rid);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return `{"rid":${rid},"body":${body},"sst":${Date.now()},"srt":${recvAt},"code":${errorCode}}`;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023 Angus.Fenying <fenying@litert.org>
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export enum EResponseCode {
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* API was called succeed
|
|
21
|
+
*/
|
|
22
|
+
OK,
|
|
23
|
+
/**
|
|
24
|
+
* The invoked API does not exist on the remote server.
|
|
25
|
+
*/
|
|
26
|
+
API_NOT_FOUND,
|
|
27
|
+
/**
|
|
28
|
+
* Some unexpected error happened.
|
|
29
|
+
*/
|
|
30
|
+
SYSTEM_ERROR,
|
|
31
|
+
/**
|
|
32
|
+
* Logical error happened inside the API handler.
|
|
33
|
+
*/
|
|
34
|
+
FAILURE,
|
|
35
|
+
/**
|
|
36
|
+
* The arguments inside the request is malformed.
|
|
37
|
+
*/
|
|
38
|
+
MALFORMED_ARGUMENTS
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface IRequestPayloadV1 {
|
|
42
|
+
|
|
43
|
+
ttl: number;
|
|
44
|
+
|
|
45
|
+
api: string;
|
|
46
|
+
|
|
47
|
+
args: unknown;
|
|
48
|
+
|
|
49
|
+
cst: number;
|
|
50
|
+
|
|
51
|
+
rid: string | number;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface IResponsePayloadV1 {
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* The time when server sent the response.
|
|
58
|
+
*/
|
|
59
|
+
sst: number;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* The time when server received the request.
|
|
63
|
+
*/
|
|
64
|
+
srt: number;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* The identity of the request.
|
|
68
|
+
*/
|
|
69
|
+
rid: string | number;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* The protocol status code of the response.
|
|
73
|
+
*/
|
|
74
|
+
code: number;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* The content of API response.
|
|
78
|
+
*/
|
|
79
|
+
body: unknown;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* The default port for HTTP.
|
|
84
|
+
*/
|
|
85
|
+
export const DEFAULT_INSECURE_PORT = 80;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* The default port for HTTPS.
|
|
89
|
+
*/
|
|
90
|
+
export const DEFAULT_SECURE_PORT = 443;
|
|
91
|
+
|
|
92
|
+
export const DEFAULT_BACKLOG = 511;
|
|
93
|
+
|
|
94
|
+
export const DEFAULT_HOSTNAME = 'localhost';
|
|
95
|
+
|
|
96
|
+
export const MAX_PACKET_SIZE = 64 * 1024 * 1024;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023 Angus.Fenying <fenying@litert.org>
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export * from './EncoderV1';
|
|
18
|
+
export * from './Protocol.v1.decls';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023 Angus.Fenying <fenying@litert.org>
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export enum ECommand {
|
|
18
|
+
API_CALL = 0x00,
|
|
19
|
+
PUSH_MESSAGE = 0x01,
|
|
20
|
+
BINARY_CHUNK = 0x02,
|
|
21
|
+
PING = 0xFE,
|
|
22
|
+
CLOSE = 0xFF
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export enum EPacketType {
|
|
26
|
+
REQUEST = 0x00,
|
|
27
|
+
SUCCESS_RESPONSE = 0x01,
|
|
28
|
+
ERROR_RESPONSE = 0x02,
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export const HEADER_SIZE = 8;
|
|
@@ -0,0 +1,404 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023 Angus.Fenying <fenying@litert.org>
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import * as CSv2 from './Constants.v2';
|
|
18
|
+
import * as CS from '../../Constants';
|
|
19
|
+
import { ProtocolError, TelevokeError, errors } from '../../Errors';
|
|
20
|
+
import type * as dEnc2 from './Encoding.v2.decl';
|
|
21
|
+
|
|
22
|
+
interface IDecodeContext {
|
|
23
|
+
|
|
24
|
+
chunks: Buffer[];
|
|
25
|
+
|
|
26
|
+
chIndex: number;
|
|
27
|
+
|
|
28
|
+
chOffset: number;
|
|
29
|
+
|
|
30
|
+
command: CSv2.ECommand;
|
|
31
|
+
|
|
32
|
+
type: CSv2.EPacketType;
|
|
33
|
+
|
|
34
|
+
seq: number;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const B8 = Buffer.allocUnsafe(8);
|
|
38
|
+
const B4 = Buffer.allocUnsafe(4);
|
|
39
|
+
const B2 = Buffer.allocUnsafe(2);
|
|
40
|
+
|
|
41
|
+
interface IPacketDecoder {
|
|
42
|
+
|
|
43
|
+
decode(ctx: IDecodeContext): dEnc2.ICommandPacket;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function readSmallBytes(bytes: number, buf: Buffer, ctx: IDecodeContext): Buffer {
|
|
47
|
+
|
|
48
|
+
let readBytes = 0;
|
|
49
|
+
|
|
50
|
+
while (readBytes < bytes) {
|
|
51
|
+
|
|
52
|
+
if (ctx.chIndex === ctx.chunks.length) {
|
|
53
|
+
|
|
54
|
+
throw new errors.incomplete_packet();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const c = ctx.chunks[ctx.chIndex];
|
|
58
|
+
const cLen = c.byteLength;
|
|
59
|
+
let cOff = ctx.chOffset;
|
|
60
|
+
|
|
61
|
+
do {
|
|
62
|
+
|
|
63
|
+
buf[readBytes++] = c[cOff++];
|
|
64
|
+
}
|
|
65
|
+
while (cOff < cLen && readBytes < bytes);
|
|
66
|
+
|
|
67
|
+
if (cOff === cLen) {
|
|
68
|
+
|
|
69
|
+
ctx.chIndex++;
|
|
70
|
+
ctx.chOffset = 0;
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
|
|
74
|
+
ctx.chOffset = cOff;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (readBytes === bytes) {
|
|
78
|
+
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return buf;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function readLargeBytes(bytes: number, ctx: IDecodeContext): Buffer[] {
|
|
87
|
+
|
|
88
|
+
let readBytes = 0;
|
|
89
|
+
const ret: Buffer[] = [];
|
|
90
|
+
|
|
91
|
+
while (readBytes < bytes) {
|
|
92
|
+
|
|
93
|
+
if (ctx.chIndex === ctx.chunks.length) {
|
|
94
|
+
|
|
95
|
+
throw new errors.incomplete_packet();
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const c = ctx.chunks[ctx.chIndex];
|
|
99
|
+
const bytes2Read = Math.min(bytes - readBytes, c.byteLength - ctx.chOffset);
|
|
100
|
+
|
|
101
|
+
ret.push(c.subarray(ctx.chOffset, ctx.chOffset + bytes2Read));
|
|
102
|
+
|
|
103
|
+
readBytes += bytes2Read;
|
|
104
|
+
ctx.chOffset += bytes2Read;
|
|
105
|
+
|
|
106
|
+
if (ctx.chOffset === c.byteLength) {
|
|
107
|
+
|
|
108
|
+
ctx.chIndex++;
|
|
109
|
+
ctx.chOffset = 0;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (readBytes === bytes) {
|
|
113
|
+
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return ret;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function readString(bytes: number, ctx: IDecodeContext): string {
|
|
122
|
+
|
|
123
|
+
const td = new TextDecoder('utf8');
|
|
124
|
+
|
|
125
|
+
let readBytes = 0;
|
|
126
|
+
let ret: string = '';
|
|
127
|
+
|
|
128
|
+
while (readBytes < bytes) {
|
|
129
|
+
|
|
130
|
+
if (ctx.chIndex === ctx.chunks.length) {
|
|
131
|
+
|
|
132
|
+
throw new errors.incomplete_packet();
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const c = ctx.chunks[ctx.chIndex];
|
|
136
|
+
const bytes2Read = Math.min(bytes - readBytes, c.byteLength - ctx.chOffset);
|
|
137
|
+
|
|
138
|
+
ret += td.decode(c.subarray(ctx.chOffset, ctx.chOffset + bytes2Read), { stream: true });
|
|
139
|
+
|
|
140
|
+
readBytes += bytes2Read;
|
|
141
|
+
ctx.chOffset += bytes2Read;
|
|
142
|
+
|
|
143
|
+
if (ctx.chOffset === c.byteLength) {
|
|
144
|
+
|
|
145
|
+
ctx.chIndex++;
|
|
146
|
+
ctx.chOffset = 0;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (readBytes === bytes) {
|
|
150
|
+
|
|
151
|
+
break;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
return ret;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function readVarString(ctx: IDecodeContext): string {
|
|
159
|
+
|
|
160
|
+
const len = readSmallBytes(2, B2, ctx).readUInt16LE(0);
|
|
161
|
+
|
|
162
|
+
return readString(len, ctx);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function readVarBuffer(ctx: IDecodeContext): Buffer[] {
|
|
166
|
+
|
|
167
|
+
const len = readSmallBytes(4, B4, ctx).readUInt32LE(0);
|
|
168
|
+
|
|
169
|
+
return readLargeBytes(len, ctx);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function readVarBuffer16(ctx: IDecodeContext): Buffer[] {
|
|
173
|
+
|
|
174
|
+
const len = readSmallBytes(2, B4, ctx).readUInt16LE(0);
|
|
175
|
+
|
|
176
|
+
return readLargeBytes(len, ctx);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
class TvErrorResponseDecoder implements IPacketDecoder {
|
|
180
|
+
|
|
181
|
+
public decode(ctx: IDecodeContext): dEnc2.ICommandPacket {
|
|
182
|
+
|
|
183
|
+
const len = readSmallBytes(2, B2, ctx).readUInt16LE(0);
|
|
184
|
+
|
|
185
|
+
const errorMsg = readString(len, ctx);
|
|
186
|
+
|
|
187
|
+
return {
|
|
188
|
+
'cmd': ctx.command,
|
|
189
|
+
'typ': CSv2.EPacketType.ERROR_RESPONSE,
|
|
190
|
+
'seq': ctx.seq,
|
|
191
|
+
'ct': errorMsg.startsWith(CS.PROTOCOL_ERROR_NAMESPACE) ?
|
|
192
|
+
new ProtocolError(errorMsg.slice(CS.PROTOCOL_ERROR_NAMESPACE.length + 1), null) :
|
|
193
|
+
new errors.app_error(errorMsg.slice(CS.APP_ERROR_NAMESPACE.length + 1), null),
|
|
194
|
+
} satisfies dEnc2.IErrorResponsePacket;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
class TvApiRequestDecoder implements IPacketDecoder {
|
|
199
|
+
|
|
200
|
+
public decode(ctx: IDecodeContext): dEnc2.ICommandPacket {
|
|
201
|
+
|
|
202
|
+
const name = readVarString(ctx);
|
|
203
|
+
|
|
204
|
+
return {
|
|
205
|
+
'cmd': CSv2.ECommand.API_CALL,
|
|
206
|
+
'typ': CSv2.EPacketType.REQUEST,
|
|
207
|
+
'seq': ctx.seq,
|
|
208
|
+
'ct': {
|
|
209
|
+
'name': name,
|
|
210
|
+
'body': readVarBuffer(ctx),
|
|
211
|
+
}
|
|
212
|
+
} satisfies dEnc2.IApiRequestPacket;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
class TvPingRequestDecoder implements IPacketDecoder {
|
|
217
|
+
|
|
218
|
+
public decode(ctx: IDecodeContext): dEnc2.ICommandPacket {
|
|
219
|
+
|
|
220
|
+
return {
|
|
221
|
+
'cmd': CSv2.ECommand.PING,
|
|
222
|
+
'typ': CSv2.EPacketType.REQUEST,
|
|
223
|
+
'seq': ctx.seq,
|
|
224
|
+
'ct': readVarBuffer16(ctx)
|
|
225
|
+
} satisfies dEnc2.IPingRequestPacket;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
class TvPushMessageRequestDecoder implements IPacketDecoder {
|
|
230
|
+
|
|
231
|
+
public decode(ctx: IDecodeContext): dEnc2.ICommandPacket {
|
|
232
|
+
|
|
233
|
+
return {
|
|
234
|
+
'cmd': CSv2.ECommand.PUSH_MESSAGE,
|
|
235
|
+
'typ': CSv2.EPacketType.REQUEST,
|
|
236
|
+
'seq': ctx.seq,
|
|
237
|
+
'ct': readVarBuffer16(ctx)
|
|
238
|
+
} satisfies dEnc2.IPushMessageRequestPacket;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
class TvBinaryChunkRequestDecoder implements IPacketDecoder {
|
|
243
|
+
|
|
244
|
+
public decode(ctx: IDecodeContext): dEnc2.ICommandPacket {
|
|
245
|
+
|
|
246
|
+
const streamId = readSmallBytes(4, B4, ctx).readUInt32LE(0);
|
|
247
|
+
return {
|
|
248
|
+
'cmd': CSv2.ECommand.BINARY_CHUNK,
|
|
249
|
+
'typ': CSv2.EPacketType.REQUEST,
|
|
250
|
+
'seq': ctx.seq,
|
|
251
|
+
'ct': {
|
|
252
|
+
'streamId': streamId,
|
|
253
|
+
'body': readVarBuffer(ctx),
|
|
254
|
+
}
|
|
255
|
+
} satisfies dEnc2.IBinaryChunkRequestPacket;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
class TvCloseRequestDecoder implements IPacketDecoder {
|
|
260
|
+
|
|
261
|
+
public decode(ctx: IDecodeContext): dEnc2.ICommandPacket {
|
|
262
|
+
|
|
263
|
+
return {
|
|
264
|
+
'cmd': CSv2.ECommand.CLOSE,
|
|
265
|
+
'typ': CSv2.EPacketType.REQUEST,
|
|
266
|
+
'seq': ctx.seq,
|
|
267
|
+
'ct': null
|
|
268
|
+
} satisfies dEnc2.ICloseRequestPacket;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
class TvVoidResponseDecoder implements IPacketDecoder {
|
|
273
|
+
|
|
274
|
+
public decode(ctx: IDecodeContext): dEnc2.ICommandPacket {
|
|
275
|
+
|
|
276
|
+
return {
|
|
277
|
+
'cmd': ctx.command,
|
|
278
|
+
'typ': CSv2.EPacketType.SUCCESS_RESPONSE,
|
|
279
|
+
'seq': ctx.seq,
|
|
280
|
+
'ct': null
|
|
281
|
+
} satisfies dEnc2.ISuccessResponsePacket;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
class TvApiResponseDecoder implements IPacketDecoder {
|
|
286
|
+
|
|
287
|
+
public decode(ctx: IDecodeContext): dEnc2.ICommandPacket {
|
|
288
|
+
|
|
289
|
+
return {
|
|
290
|
+
'cmd': CSv2.ECommand.API_CALL,
|
|
291
|
+
'typ': CSv2.EPacketType.SUCCESS_RESPONSE,
|
|
292
|
+
'seq': ctx.seq,
|
|
293
|
+
'ct': readVarBuffer(ctx)
|
|
294
|
+
} satisfies dEnc2.IApiResponsePacket;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
class TvPingResponseDecoder implements IPacketDecoder {
|
|
299
|
+
|
|
300
|
+
public decode(ctx: IDecodeContext): dEnc2.ICommandPacket {
|
|
301
|
+
|
|
302
|
+
return {
|
|
303
|
+
'cmd': CSv2.ECommand.PING,
|
|
304
|
+
'typ': CSv2.EPacketType.SUCCESS_RESPONSE,
|
|
305
|
+
'seq': ctx.seq,
|
|
306
|
+
'ct': readVarBuffer16(ctx)
|
|
307
|
+
} satisfies dEnc2.IPingResponsePacket;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
const packetDecoders: Record<number, IPacketDecoder> = {
|
|
312
|
+
|
|
313
|
+
[CSv2.EPacketType.ERROR_RESPONSE + 0x100 * CSv2.ECommand.API_CALL]: new TvErrorResponseDecoder(),
|
|
314
|
+
[CSv2.EPacketType.ERROR_RESPONSE + 0x100 * CSv2.ECommand.PING]: new TvErrorResponseDecoder(),
|
|
315
|
+
[CSv2.EPacketType.ERROR_RESPONSE + 0x100 * CSv2.ECommand.BINARY_CHUNK]: new TvErrorResponseDecoder(),
|
|
316
|
+
[CSv2.EPacketType.ERROR_RESPONSE + 0x100 * CSv2.ECommand.CLOSE]: new TvErrorResponseDecoder(),
|
|
317
|
+
[CSv2.EPacketType.ERROR_RESPONSE + 0x100 * CSv2.ECommand.PUSH_MESSAGE]: new TvErrorResponseDecoder(),
|
|
318
|
+
|
|
319
|
+
[CSv2.EPacketType.REQUEST + 0x100 * CSv2.ECommand.API_CALL]: new TvApiRequestDecoder(),
|
|
320
|
+
[CSv2.EPacketType.REQUEST + 0x100 * CSv2.ECommand.PING]: new TvPingRequestDecoder(),
|
|
321
|
+
[CSv2.EPacketType.REQUEST + 0x100 * CSv2.ECommand.PUSH_MESSAGE]: new TvPushMessageRequestDecoder(),
|
|
322
|
+
[CSv2.EPacketType.REQUEST + 0x100 * CSv2.ECommand.CLOSE]: new TvCloseRequestDecoder(),
|
|
323
|
+
[CSv2.EPacketType.REQUEST + 0x100 * CSv2.ECommand.BINARY_CHUNK]: new TvBinaryChunkRequestDecoder(),
|
|
324
|
+
|
|
325
|
+
[CSv2.EPacketType.SUCCESS_RESPONSE + 0x100 * CSv2.ECommand.PUSH_MESSAGE]: new TvVoidResponseDecoder(),
|
|
326
|
+
[CSv2.EPacketType.SUCCESS_RESPONSE + 0x100 * CSv2.ECommand.CLOSE]: new TvVoidResponseDecoder(),
|
|
327
|
+
[CSv2.EPacketType.SUCCESS_RESPONSE + 0x100 * CSv2.ECommand.BINARY_CHUNK]: new TvVoidResponseDecoder(),
|
|
328
|
+
[CSv2.EPacketType.SUCCESS_RESPONSE + 0x100 * CSv2.ECommand.API_CALL]: new TvApiResponseDecoder(),
|
|
329
|
+
[CSv2.EPacketType.SUCCESS_RESPONSE + 0x100 * CSv2.ECommand.PING]: new TvPingResponseDecoder(),
|
|
330
|
+
};
|
|
331
|
+
|
|
332
|
+
export class TvDecoderV2 {
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* Pass all chunks of a whole packet to this method, and it will return an array of decoded results.
|
|
336
|
+
*
|
|
337
|
+
* @throws {TelevokeError}
|
|
338
|
+
*/
|
|
339
|
+
public decode(packetChunks: Buffer[]): dEnc2.ICommandPacket {
|
|
340
|
+
|
|
341
|
+
const ctx = this._decodeHeader(packetChunks);
|
|
342
|
+
|
|
343
|
+
try {
|
|
344
|
+
|
|
345
|
+
return packetDecoders[ctx.command * 0x100 + ctx.type].decode(ctx);
|
|
346
|
+
}
|
|
347
|
+
catch (e) {
|
|
348
|
+
|
|
349
|
+
if (e instanceof TelevokeError) {
|
|
350
|
+
|
|
351
|
+
throw e;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
throw new errors.invalid_packet(null, e);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
private _decodeHeader(chunks: Buffer[]): IDecodeContext {
|
|
359
|
+
|
|
360
|
+
try {
|
|
361
|
+
|
|
362
|
+
const ctx: IDecodeContext = {
|
|
363
|
+
chunks,
|
|
364
|
+
chIndex: 0,
|
|
365
|
+
chOffset: 0,
|
|
366
|
+
command: 0,
|
|
367
|
+
type: 0,
|
|
368
|
+
seq: 0,
|
|
369
|
+
};
|
|
370
|
+
|
|
371
|
+
readSmallBytes(8, B8, ctx);
|
|
372
|
+
|
|
373
|
+
ctx.command = B8[0];
|
|
374
|
+
ctx.type = B8[1];
|
|
375
|
+
|
|
376
|
+
if (undefined === CSv2.EPacketType[ctx.type]) {
|
|
377
|
+
|
|
378
|
+
throw new errors.invalid_packet({
|
|
379
|
+
unknownPacketType: ctx.type,
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
if (undefined === CSv2.ECommand[ctx.command]) {
|
|
384
|
+
|
|
385
|
+
throw new errors.invalid_packet({
|
|
386
|
+
unknownCommand: ctx.command,
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
ctx.seq = B8.readUInt16LE(2) * 0x1_0000_0000 + B8.readUInt32LE(4);
|
|
391
|
+
|
|
392
|
+
return ctx;
|
|
393
|
+
}
|
|
394
|
+
catch (e) {
|
|
395
|
+
|
|
396
|
+
if (e instanceof TelevokeError) {
|
|
397
|
+
|
|
398
|
+
throw e;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
throw new errors.invalid_packet(null, e);
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
}
|