zmdms-utils 0.0.81 → 0.0.83

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 (162) hide show
  1. package/dist/es/validate.js +168 -1
  2. package/dist/index.d.ts +0 -1
  3. package/dist/index.js +0 -1
  4. package/package.json +2 -6
  5. package/src/index.ts +0 -3
  6. package/src/validate.ts +198 -0
  7. package/dist/es/_virtual/FastBufferList.js +0 -7
  8. package/dist/es/_virtual/_commonjs-dynamic-modules.js +0 -5
  9. package/dist/es/_virtual/browser.js +0 -7
  10. package/dist/es/_virtual/browser2.js +0 -7
  11. package/dist/es/_virtual/debug.js +0 -7
  12. package/dist/es/_virtual/event.js +0 -7
  13. package/dist/es/_virtual/http-parser.js +0 -3
  14. package/dist/es/_virtual/iframe.js +0 -7
  15. package/dist/es/_virtual/index.js +0 -7
  16. package/dist/es/_virtual/index2.js +0 -7
  17. package/dist/es/_virtual/index3.js +0 -7
  18. package/dist/es/_virtual/index4.js +0 -7
  19. package/dist/es/_virtual/index5.js +0 -7
  20. package/dist/es/_virtual/index6.js +0 -7
  21. package/dist/es/_virtual/index7.js +0 -3
  22. package/dist/es/_virtual/index8.js +0 -7
  23. package/dist/es/_virtual/index9.js +0 -7
  24. package/dist/es/_virtual/inherits.js +0 -7
  25. package/dist/es/_virtual/inherits_browser.js +0 -7
  26. package/dist/es/_virtual/json3.js +0 -7
  27. package/dist/es/_virtual/node.js +0 -7
  28. package/dist/es/_virtual/node2.js +0 -7
  29. package/dist/es/_virtual/stomp-node.js +0 -3
  30. package/dist/es/_virtual/stomp.js +0 -3
  31. package/dist/es/_virtual/streams.js +0 -3
  32. package/dist/es/_virtual/utils.js +0 -3
  33. package/dist/es/node_modules/bufferutil/fallback.js +0 -43
  34. package/dist/es/node_modules/bufferutil/index.js +0 -21
  35. package/dist/es/node_modules/debug/src/browser.js +0 -192
  36. package/dist/es/node_modules/debug/src/common.js +0 -259
  37. package/dist/es/node_modules/debug/src/index.js +0 -25
  38. package/dist/es/node_modules/debug/src/node.js +0 -192
  39. package/dist/es/node_modules/eventsource/lib/eventsource.js +0 -493
  40. package/dist/es/node_modules/faye-websocket/lib/faye/eventsource.js +0 -150
  41. package/dist/es/node_modules/faye-websocket/lib/faye/websocket/api/event.js +0 -31
  42. package/dist/es/node_modules/faye-websocket/lib/faye/websocket/api/event_target.js +0 -41
  43. package/dist/es/node_modules/faye-websocket/lib/faye/websocket/api.js +0 -205
  44. package/dist/es/node_modules/faye-websocket/lib/faye/websocket/client.js +0 -107
  45. package/dist/es/node_modules/faye-websocket/lib/faye/websocket.js +0 -47
  46. package/dist/es/node_modules/has-flag/index.js +0 -17
  47. package/dist/es/node_modules/http-parser-js/http-parser.js +0 -471
  48. package/dist/es/node_modules/inherits/inherits.js +0 -14
  49. package/dist/es/node_modules/inherits/inherits_browser.js +0 -38
  50. package/dist/es/node_modules/is-typedarray/index.js +0 -51
  51. package/dist/es/node_modules/json3/lib/json3.js +0 -937
  52. package/dist/es/node_modules/ms/index.js +0 -172
  53. package/dist/es/node_modules/node-gyp-build/index.js +0 -21
  54. package/dist/es/node_modules/node-gyp-build/node-gyp-build.js +0 -222
  55. package/dist/es/node_modules/querystringify/index.js +0 -120
  56. package/dist/es/node_modules/requires-port/index.js +0 -38
  57. package/dist/es/node_modules/safe-buffer/index.js +0 -71
  58. package/dist/es/node_modules/supports-color/index.js +0 -143
  59. package/dist/es/node_modules/typedarray-to-buffer/index.js +0 -37
  60. package/dist/es/node_modules/url-parse/index.js +0 -594
  61. package/dist/es/node_modules/utf-8-validate/fallback.js +0 -71
  62. package/dist/es/node_modules/utf-8-validate/index.js +0 -21
  63. package/dist/es/node_modules/websocket/index.js +0 -15
  64. package/dist/es/node_modules/websocket/lib/Deprecation.js +0 -42
  65. package/dist/es/node_modules/websocket/lib/W3CWebSocket.js +0 -268
  66. package/dist/es/node_modules/websocket/lib/WebSocketClient.js +0 -380
  67. package/dist/es/node_modules/websocket/lib/WebSocketConnection.js +0 -914
  68. package/dist/es/node_modules/websocket/lib/WebSocketFrame.js +0 -293
  69. package/dist/es/node_modules/websocket/lib/WebSocketRequest.js +0 -543
  70. package/dist/es/node_modules/websocket/lib/WebSocketRouter.js +0 -172
  71. package/dist/es/node_modules/websocket/lib/WebSocketRouterRequest.js +0 -67
  72. package/dist/es/node_modules/websocket/lib/WebSocketServer.js +0 -272
  73. package/dist/es/node_modules/websocket/lib/utils.js +0 -80
  74. package/dist/es/node_modules/websocket/lib/version.js +0 -13
  75. package/dist/es/node_modules/websocket/lib/websocket.js +0 -31
  76. package/dist/es/node_modules/websocket/node_modules/debug/src/browser.js +0 -199
  77. package/dist/es/node_modules/websocket/node_modules/debug/src/debug.js +0 -215
  78. package/dist/es/node_modules/websocket/node_modules/debug/src/index.js +0 -25
  79. package/dist/es/node_modules/websocket/node_modules/debug/src/node.js +0 -266
  80. package/dist/es/node_modules/websocket/node_modules/ms/index.js +0 -162
  81. package/dist/es/node_modules/websocket/package.json.js +0 -77
  82. package/dist/es/node_modules/websocket/vendor/FastBufferList.js +0 -205
  83. package/dist/es/node_modules/websocket-driver/lib/websocket/driver/base.js +0 -202
  84. package/dist/es/node_modules/websocket-driver/lib/websocket/driver/client.js +0 -152
  85. package/dist/es/node_modules/websocket-driver/lib/websocket/driver/draft75.js +0 -128
  86. package/dist/es/node_modules/websocket-driver/lib/websocket/driver/draft76.js +0 -124
  87. package/dist/es/node_modules/websocket-driver/lib/websocket/driver/headers.js +0 -44
  88. package/dist/es/node_modules/websocket-driver/lib/websocket/driver/hybi/frame.js +0 -21
  89. package/dist/es/node_modules/websocket-driver/lib/websocket/driver/hybi/message.js +0 -37
  90. package/dist/es/node_modules/websocket-driver/lib/websocket/driver/hybi.js +0 -492
  91. package/dist/es/node_modules/websocket-driver/lib/websocket/driver/proxy.js +0 -108
  92. package/dist/es/node_modules/websocket-driver/lib/websocket/driver/server.js +0 -119
  93. package/dist/es/node_modules/websocket-driver/lib/websocket/driver/stream_reader.js +0 -72
  94. package/dist/es/node_modules/websocket-driver/lib/websocket/driver.js +0 -47
  95. package/dist/es/node_modules/websocket-driver/lib/websocket/http_parser.js +0 -140
  96. package/dist/es/node_modules/websocket-driver/lib/websocket/streams.js +0 -150
  97. package/dist/es/node_modules/websocket-extensions/lib/parser.js +0 -103
  98. package/dist/es/node_modules/websocket-extensions/lib/pipeline/cell.js +0 -56
  99. package/dist/es/node_modules/websocket-extensions/lib/pipeline/functor.js +0 -74
  100. package/dist/es/node_modules/websocket-extensions/lib/pipeline/index.js +0 -50
  101. package/dist/es/node_modules/websocket-extensions/lib/pipeline/pledge.js +0 -39
  102. package/dist/es/node_modules/websocket-extensions/lib/pipeline/ring_buffer.js +0 -66
  103. package/dist/es/node_modules/websocket-extensions/lib/websocket_extensions.js +0 -165
  104. package/dist/es/node_modules/yaeti/index.js +0 -17
  105. package/dist/es/node_modules/yaeti/lib/Event.js +0 -24
  106. package/dist/es/node_modules/yaeti/lib/EventTarget.js +0 -130
  107. package/dist/es/node_modules/zt-sockjs-client/lib/entry.js +0 -14
  108. package/dist/es/node_modules/zt-sockjs-client/lib/event/close.js +0 -21
  109. package/dist/es/node_modules/zt-sockjs-client/lib/event/event.js +0 -22
  110. package/dist/es/node_modules/zt-sockjs-client/lib/event/eventtarget.js +0 -62
  111. package/dist/es/node_modules/zt-sockjs-client/lib/event/trans-message.js +0 -19
  112. package/dist/es/node_modules/zt-sockjs-client/lib/facade.js +0 -40
  113. package/dist/es/node_modules/zt-sockjs-client/lib/iframe-bootstrap.js +0 -122
  114. package/dist/es/node_modules/zt-sockjs-client/lib/info-ajax.js +0 -57
  115. package/dist/es/node_modules/zt-sockjs-client/lib/info-iframe-receiver.js +0 -50
  116. package/dist/es/node_modules/zt-sockjs-client/lib/info-iframe.js +0 -81
  117. package/dist/es/node_modules/zt-sockjs-client/lib/info-receiver.js +0 -101
  118. package/dist/es/node_modules/zt-sockjs-client/lib/location.js +0 -12
  119. package/dist/es/node_modules/zt-sockjs-client/lib/main.js +0 -413
  120. package/dist/es/node_modules/zt-sockjs-client/lib/shims.js +0 -449
  121. package/dist/es/node_modules/zt-sockjs-client/lib/transport/driver/websocket.js +0 -5
  122. package/dist/es/node_modules/zt-sockjs-client/lib/transport/driver/xhr.js +0 -80
  123. package/dist/es/node_modules/zt-sockjs-client/lib/transport/eventsource.js +0 -34
  124. package/dist/es/node_modules/zt-sockjs-client/lib/transport/htmlfile.js +0 -31
  125. package/dist/es/node_modules/zt-sockjs-client/lib/transport/iframe.js +0 -154
  126. package/dist/es/node_modules/zt-sockjs-client/lib/transport/jsonp-polling.js +0 -41
  127. package/dist/es/node_modules/zt-sockjs-client/lib/transport/lib/ajax-based.js +0 -55
  128. package/dist/es/node_modules/zt-sockjs-client/lib/transport/lib/buffered-sender.js +0 -92
  129. package/dist/es/node_modules/zt-sockjs-client/lib/transport/lib/iframe-wrap.js +0 -39
  130. package/dist/es/node_modules/zt-sockjs-client/lib/transport/lib/polling.js +0 -65
  131. package/dist/es/node_modules/zt-sockjs-client/lib/transport/lib/sender-receiver.js +0 -52
  132. package/dist/es/node_modules/zt-sockjs-client/lib/transport/receiver/eventsource.js +0 -69
  133. package/dist/es/node_modules/zt-sockjs-client/lib/transport/receiver/htmlfile.js +0 -96
  134. package/dist/es/node_modules/zt-sockjs-client/lib/transport/receiver/jsonp.js +0 -193
  135. package/dist/es/node_modules/zt-sockjs-client/lib/transport/receiver/xhr.js +0 -75
  136. package/dist/es/node_modules/zt-sockjs-client/lib/transport/sender/jsonp.js +0 -104
  137. package/dist/es/node_modules/zt-sockjs-client/lib/transport/sender/xdr.js +0 -113
  138. package/dist/es/node_modules/zt-sockjs-client/lib/transport/sender/xhr-cors.js +0 -19
  139. package/dist/es/node_modules/zt-sockjs-client/lib/transport/sender/xhr-fake.js +0 -28
  140. package/dist/es/node_modules/zt-sockjs-client/lib/transport/sender/xhr-local.js +0 -21
  141. package/dist/es/node_modules/zt-sockjs-client/lib/transport/websocket.js +0 -108
  142. package/dist/es/node_modules/zt-sockjs-client/lib/transport/xdr-polling.js +0 -30
  143. package/dist/es/node_modules/zt-sockjs-client/lib/transport/xdr-streaming.js +0 -38
  144. package/dist/es/node_modules/zt-sockjs-client/lib/transport/xhr-polling.js +0 -40
  145. package/dist/es/node_modules/zt-sockjs-client/lib/transport/xhr-streaming.js +0 -50
  146. package/dist/es/node_modules/zt-sockjs-client/lib/transport-list.js +0 -28
  147. package/dist/es/node_modules/zt-sockjs-client/lib/utils/browser.js +0 -29
  148. package/dist/es/node_modules/zt-sockjs-client/lib/utils/escape.js +0 -53
  149. package/dist/es/node_modules/zt-sockjs-client/lib/utils/event.js +0 -78
  150. package/dist/es/node_modules/zt-sockjs-client/lib/utils/iframe.js +0 -205
  151. package/dist/es/node_modules/zt-sockjs-client/lib/utils/log.js +0 -20
  152. package/dist/es/node_modules/zt-sockjs-client/lib/utils/object.js +0 -24
  153. package/dist/es/node_modules/zt-sockjs-client/lib/utils/random.js +0 -30
  154. package/dist/es/node_modules/zt-sockjs-client/lib/utils/transport.js +0 -52
  155. package/dist/es/node_modules/zt-sockjs-client/lib/utils/url.js +0 -54
  156. package/dist/es/node_modules/zt-sockjs-client/lib/version.js +0 -11
  157. package/dist/es/node_modules/zt-stompjs/index.js +0 -23
  158. package/dist/es/node_modules/zt-stompjs/lib/stomp-node.js +0 -117
  159. package/dist/es/node_modules/zt-stompjs/lib/stomp.js +0 -536
  160. package/dist/es/stompClient.d.ts +0 -55
  161. package/dist/es/stompClient.js +0 -379
  162. package/src/stompClient.ts +0 -449
@@ -1,172 +0,0 @@
1
- import { __require as requireUtils } from './utils.js';
2
- import require$$1$1 from 'util';
3
- import require$$1 from 'events';
4
- import { __require as requireWebSocketRouterRequest } from './WebSocketRouterRequest.js';
5
-
6
- /************************************************************************
7
- * Copyright 2010-2015 Brian McKelvey.
8
- *
9
- * Licensed under the Apache License, Version 2.0 (the "License");
10
- * you may not use this file except in compliance with the License.
11
- * You may obtain a copy of the License at
12
- *
13
- * http://www.apache.org/licenses/LICENSE-2.0
14
- *
15
- * Unless required by applicable law or agreed to in writing, software
16
- * distributed under the License is distributed on an "AS IS" BASIS,
17
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
- * See the License for the specific language governing permissions and
19
- * limitations under the License.
20
- ***********************************************************************/
21
-
22
- var WebSocketRouter_1;
23
- var hasRequiredWebSocketRouter;
24
-
25
- function requireWebSocketRouter () {
26
- if (hasRequiredWebSocketRouter) return WebSocketRouter_1;
27
- hasRequiredWebSocketRouter = 1;
28
- var extend = requireUtils().extend;
29
- var util = require$$1$1;
30
- var EventEmitter = require$$1.EventEmitter;
31
- var WebSocketRouterRequest = requireWebSocketRouterRequest();
32
-
33
- function WebSocketRouter(config) {
34
- // Superclass Constructor
35
- EventEmitter.call(this);
36
-
37
- this.config = {
38
- // The WebSocketServer instance to attach to.
39
- server: null
40
- };
41
- if (config) {
42
- extend(this.config, config);
43
- }
44
- this.handlers = [];
45
-
46
- this._requestHandler = this.handleRequest.bind(this);
47
- if (this.config.server) {
48
- this.attachServer(this.config.server);
49
- }
50
- }
51
-
52
- util.inherits(WebSocketRouter, EventEmitter);
53
-
54
- WebSocketRouter.prototype.attachServer = function(server) {
55
- if (server) {
56
- this.server = server;
57
- this.server.on('request', this._requestHandler);
58
- }
59
- else {
60
- throw new Error('You must specify a WebSocketServer instance to attach to.');
61
- }
62
- };
63
-
64
- WebSocketRouter.prototype.detachServer = function() {
65
- if (this.server) {
66
- this.server.removeListener('request', this._requestHandler);
67
- this.server = null;
68
- }
69
- else {
70
- throw new Error('Cannot detach from server: not attached.');
71
- }
72
- };
73
-
74
- WebSocketRouter.prototype.mount = function(path, protocol, callback) {
75
- if (!path) {
76
- throw new Error('You must specify a path for this handler.');
77
- }
78
- if (!protocol) {
79
- protocol = '____no_protocol____';
80
- }
81
- if (!callback) {
82
- throw new Error('You must specify a callback for this handler.');
83
- }
84
-
85
- path = this.pathToRegExp(path);
86
- if (!(path instanceof RegExp)) {
87
- throw new Error('Path must be specified as either a string or a RegExp.');
88
- }
89
- var pathString = path.toString();
90
-
91
- // normalize protocol to lower-case
92
- protocol = protocol.toLocaleLowerCase();
93
-
94
- if (this.findHandlerIndex(pathString, protocol) !== -1) {
95
- throw new Error('You may only mount one handler per path/protocol combination.');
96
- }
97
-
98
- this.handlers.push({
99
- 'path': path,
100
- 'pathString': pathString,
101
- 'protocol': protocol,
102
- 'callback': callback
103
- });
104
- };
105
- WebSocketRouter.prototype.unmount = function(path, protocol) {
106
- var index = this.findHandlerIndex(this.pathToRegExp(path).toString(), protocol);
107
- if (index !== -1) {
108
- this.handlers.splice(index, 1);
109
- }
110
- else {
111
- throw new Error('Unable to find a route matching the specified path and protocol.');
112
- }
113
- };
114
-
115
- WebSocketRouter.prototype.findHandlerIndex = function(pathString, protocol) {
116
- protocol = protocol.toLocaleLowerCase();
117
- for (var i=0, len=this.handlers.length; i < len; i++) {
118
- var handler = this.handlers[i];
119
- if (handler.pathString === pathString && handler.protocol === protocol) {
120
- return i;
121
- }
122
- }
123
- return -1;
124
- };
125
-
126
- WebSocketRouter.prototype.pathToRegExp = function(path) {
127
- if (typeof(path) === 'string') {
128
- if (path === '*') {
129
- path = /^.*$/;
130
- }
131
- else {
132
- path = path.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
133
- path = new RegExp('^' + path + '$');
134
- }
135
- }
136
- return path;
137
- };
138
-
139
- WebSocketRouter.prototype.handleRequest = function(request) {
140
- var requestedProtocols = request.requestedProtocols;
141
- if (requestedProtocols.length === 0) {
142
- requestedProtocols = ['____no_protocol____'];
143
- }
144
-
145
- // Find a handler with the first requested protocol first
146
- for (var i=0; i < requestedProtocols.length; i++) {
147
- var requestedProtocol = requestedProtocols[i].toLocaleLowerCase();
148
-
149
- // find the first handler that can process this request
150
- for (var j=0, len=this.handlers.length; j < len; j++) {
151
- var handler = this.handlers[j];
152
- if (handler.path.test(request.resourceURL.pathname)) {
153
- if (requestedProtocol === handler.protocol ||
154
- handler.protocol === '*')
155
- {
156
- var routerRequest = new WebSocketRouterRequest(request, requestedProtocol);
157
- handler.callback(routerRequest);
158
- return;
159
- }
160
- }
161
- }
162
- }
163
-
164
- // If we get here we were unable to find a suitable handler.
165
- request.reject(404, 'No handler is available for the given request.');
166
- };
167
-
168
- WebSocketRouter_1 = WebSocketRouter;
169
- return WebSocketRouter_1;
170
- }
171
-
172
- export { requireWebSocketRouter as __require };
@@ -1,67 +0,0 @@
1
- import require$$1$1 from 'util';
2
- import require$$1 from 'events';
3
-
4
- /************************************************************************
5
- * Copyright 2010-2015 Brian McKelvey.
6
- *
7
- * Licensed under the Apache License, Version 2.0 (the "License");
8
- * you may not use this file except in compliance with the License.
9
- * You may obtain a copy of the License at
10
- *
11
- * http://www.apache.org/licenses/LICENSE-2.0
12
- *
13
- * Unless required by applicable law or agreed to in writing, software
14
- * distributed under the License is distributed on an "AS IS" BASIS,
15
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- * See the License for the specific language governing permissions and
17
- * limitations under the License.
18
- ***********************************************************************/
19
-
20
- var WebSocketRouterRequest_1;
21
- var hasRequiredWebSocketRouterRequest;
22
-
23
- function requireWebSocketRouterRequest () {
24
- if (hasRequiredWebSocketRouterRequest) return WebSocketRouterRequest_1;
25
- hasRequiredWebSocketRouterRequest = 1;
26
- var util = require$$1$1;
27
- var EventEmitter = require$$1.EventEmitter;
28
-
29
- function WebSocketRouterRequest(webSocketRequest, resolvedProtocol) {
30
- // Superclass Constructor
31
- EventEmitter.call(this);
32
-
33
- this.webSocketRequest = webSocketRequest;
34
- if (resolvedProtocol === '____no_protocol____') {
35
- this.protocol = null;
36
- }
37
- else {
38
- this.protocol = resolvedProtocol;
39
- }
40
- this.origin = webSocketRequest.origin;
41
- this.resource = webSocketRequest.resource;
42
- this.resourceURL = webSocketRequest.resourceURL;
43
- this.httpRequest = webSocketRequest.httpRequest;
44
- this.remoteAddress = webSocketRequest.remoteAddress;
45
- this.webSocketVersion = webSocketRequest.webSocketVersion;
46
- this.requestedExtensions = webSocketRequest.requestedExtensions;
47
- this.cookies = webSocketRequest.cookies;
48
- }
49
-
50
- util.inherits(WebSocketRouterRequest, EventEmitter);
51
-
52
- WebSocketRouterRequest.prototype.accept = function(origin, cookies) {
53
- var connection = this.webSocketRequest.accept(this.protocol, origin, cookies);
54
- this.emit('requestAccepted', connection);
55
- return connection;
56
- };
57
-
58
- WebSocketRouterRequest.prototype.reject = function(status, reason, extraHeaders) {
59
- this.webSocketRequest.reject(status, reason, extraHeaders);
60
- this.emit('requestRejected', this);
61
- };
62
-
63
- WebSocketRouterRequest_1 = WebSocketRouterRequest;
64
- return WebSocketRouterRequest_1;
65
- }
66
-
67
- export { requireWebSocketRouterRequest as __require };
@@ -1,272 +0,0 @@
1
- import { __require as requireUtils } from './utils.js';
2
- import require$$1$1 from 'util';
3
- import { __require as requireSrc } from '../node_modules/debug/src/index.js';
4
- import require$$1 from 'events';
5
- import { __require as requireWebSocketRequest } from './WebSocketRequest.js';
6
-
7
- /************************************************************************
8
- * Copyright 2010-2015 Brian McKelvey.
9
- *
10
- * Licensed under the Apache License, Version 2.0 (the "License");
11
- * you may not use this file except in compliance with the License.
12
- * You may obtain a copy of the License at
13
- *
14
- * http://www.apache.org/licenses/LICENSE-2.0
15
- *
16
- * Unless required by applicable law or agreed to in writing, software
17
- * distributed under the License is distributed on an "AS IS" BASIS,
18
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
- * See the License for the specific language governing permissions and
20
- * limitations under the License.
21
- ***********************************************************************/
22
-
23
- var WebSocketServer_1;
24
- var hasRequiredWebSocketServer;
25
-
26
- function requireWebSocketServer () {
27
- if (hasRequiredWebSocketServer) return WebSocketServer_1;
28
- hasRequiredWebSocketServer = 1;
29
- var extend = requireUtils().extend;
30
- var utils = requireUtils();
31
- var util = require$$1$1;
32
- var debug = requireSrc()('websocket:server');
33
- var EventEmitter = require$$1.EventEmitter;
34
- var WebSocketRequest = requireWebSocketRequest();
35
-
36
- var WebSocketServer = function WebSocketServer(config) {
37
- // Superclass Constructor
38
- EventEmitter.call(this);
39
-
40
- this._handlers = {
41
- upgrade: this.handleUpgrade.bind(this),
42
- requestAccepted: this.handleRequestAccepted.bind(this),
43
- requestResolved: this.handleRequestResolved.bind(this)
44
- };
45
- this.connections = [];
46
- this.pendingRequests = [];
47
- if (config) {
48
- this.mount(config);
49
- }
50
- };
51
-
52
- util.inherits(WebSocketServer, EventEmitter);
53
-
54
- WebSocketServer.prototype.mount = function(config) {
55
- this.config = {
56
- // The http server instance to attach to. Required.
57
- httpServer: null,
58
-
59
- // 64KiB max frame size.
60
- maxReceivedFrameSize: 0x10000,
61
-
62
- // 1MiB max message size, only applicable if
63
- // assembleFragments is true
64
- maxReceivedMessageSize: 0x100000,
65
-
66
- // Outgoing messages larger than fragmentationThreshold will be
67
- // split into multiple fragments.
68
- fragmentOutgoingMessages: true,
69
-
70
- // Outgoing frames are fragmented if they exceed this threshold.
71
- // Default is 16KiB
72
- fragmentationThreshold: 0x4000,
73
-
74
- // If true, the server will automatically send a ping to all
75
- // clients every 'keepaliveInterval' milliseconds. The timer is
76
- // reset on any received data from the client.
77
- keepalive: true,
78
-
79
- // The interval to send keepalive pings to connected clients if the
80
- // connection is idle. Any received data will reset the counter.
81
- keepaliveInterval: 20000,
82
-
83
- // If true, the server will consider any connection that has not
84
- // received any data within the amount of time specified by
85
- // 'keepaliveGracePeriod' after a keepalive ping has been sent to
86
- // be dead, and will drop the connection.
87
- // Ignored if keepalive is false.
88
- dropConnectionOnKeepaliveTimeout: true,
89
-
90
- // The amount of time to wait after sending a keepalive ping before
91
- // closing the connection if the connected peer does not respond.
92
- // Ignored if keepalive is false.
93
- keepaliveGracePeriod: 10000,
94
-
95
- // Whether to use native TCP keep-alive instead of WebSockets ping
96
- // and pong packets. Native TCP keep-alive sends smaller packets
97
- // on the wire and so uses bandwidth more efficiently. This may
98
- // be more important when talking to mobile devices.
99
- // If this value is set to true, then these values will be ignored:
100
- // keepaliveGracePeriod
101
- // dropConnectionOnKeepaliveTimeout
102
- useNativeKeepalive: false,
103
-
104
- // If true, fragmented messages will be automatically assembled
105
- // and the full message will be emitted via a 'message' event.
106
- // If false, each frame will be emitted via a 'frame' event and
107
- // the application will be responsible for aggregating multiple
108
- // fragmented frames. Single-frame messages will emit a 'message'
109
- // event in addition to the 'frame' event.
110
- // Most users will want to leave this set to 'true'
111
- assembleFragments: true,
112
-
113
- // If this is true, websocket connections will be accepted
114
- // regardless of the path and protocol specified by the client.
115
- // The protocol accepted will be the first that was requested
116
- // by the client. Clients from any origin will be accepted.
117
- // This should only be used in the simplest of cases. You should
118
- // probably leave this set to 'false' and inspect the request
119
- // object to make sure it's acceptable before accepting it.
120
- autoAcceptConnections: false,
121
-
122
- // Whether or not the X-Forwarded-For header should be respected.
123
- // It's important to set this to 'true' when accepting connections
124
- // from untrusted clients, as a malicious client could spoof its
125
- // IP address by simply setting this header. It's meant to be added
126
- // by a trusted proxy or other intermediary within your own
127
- // infrastructure.
128
- // See: http://en.wikipedia.org/wiki/X-Forwarded-For
129
- ignoreXForwardedFor: false,
130
-
131
- // If this is true, 'cookie' headers are parsed and exposed as WebSocketRequest.cookies
132
- parseCookies: true,
133
-
134
- // If this is true, 'sec-websocket-extensions' headers are parsed and exposed as WebSocketRequest.requestedExtensions
135
- parseExtensions: true,
136
-
137
- // The Nagle Algorithm makes more efficient use of network resources
138
- // by introducing a small delay before sending small packets so that
139
- // multiple messages can be batched together before going onto the
140
- // wire. This however comes at the cost of latency, so the default
141
- // is to disable it. If you don't need low latency and are streaming
142
- // lots of small messages, you can change this to 'false'
143
- disableNagleAlgorithm: true,
144
-
145
- // The number of milliseconds to wait after sending a close frame
146
- // for an acknowledgement to come back before giving up and just
147
- // closing the socket.
148
- closeTimeout: 5000
149
- };
150
- extend(this.config, config);
151
-
152
- if (this.config.httpServer) {
153
- if (!Array.isArray(this.config.httpServer)) {
154
- this.config.httpServer = [this.config.httpServer];
155
- }
156
- var upgradeHandler = this._handlers.upgrade;
157
- this.config.httpServer.forEach(function(httpServer) {
158
- httpServer.on('upgrade', upgradeHandler);
159
- });
160
- }
161
- else {
162
- throw new Error('You must specify an httpServer on which to mount the WebSocket server.');
163
- }
164
- };
165
-
166
- WebSocketServer.prototype.unmount = function() {
167
- var upgradeHandler = this._handlers.upgrade;
168
- this.config.httpServer.forEach(function(httpServer) {
169
- httpServer.removeListener('upgrade', upgradeHandler);
170
- });
171
- };
172
-
173
- WebSocketServer.prototype.closeAllConnections = function() {
174
- this.connections.forEach(function(connection) {
175
- connection.close();
176
- });
177
- this.pendingRequests.forEach(function(request) {
178
- process.nextTick(function() {
179
- request.reject(503); // HTTP 503 Service Unavailable
180
- });
181
- });
182
- };
183
-
184
- WebSocketServer.prototype.broadcast = function(data) {
185
- if (Buffer.isBuffer(data)) {
186
- this.broadcastBytes(data);
187
- }
188
- else if (typeof(data.toString) === 'function') {
189
- this.broadcastUTF(data);
190
- }
191
- };
192
-
193
- WebSocketServer.prototype.broadcastUTF = function(utfData) {
194
- this.connections.forEach(function(connection) {
195
- connection.sendUTF(utfData);
196
- });
197
- };
198
-
199
- WebSocketServer.prototype.broadcastBytes = function(binaryData) {
200
- this.connections.forEach(function(connection) {
201
- connection.sendBytes(binaryData);
202
- });
203
- };
204
-
205
- WebSocketServer.prototype.shutDown = function() {
206
- this.unmount();
207
- this.closeAllConnections();
208
- };
209
-
210
- WebSocketServer.prototype.handleUpgrade = function(request, socket) {
211
- var self = this;
212
- var wsRequest = new WebSocketRequest(socket, request, this.config);
213
- try {
214
- wsRequest.readHandshake();
215
- }
216
- catch(e) {
217
- wsRequest.reject(
218
- e.httpCode ? e.httpCode : 400,
219
- e.message,
220
- e.headers
221
- );
222
- debug('Invalid handshake: %s', e.message);
223
- this.emit('upgradeError', e);
224
- return;
225
- }
226
-
227
- this.pendingRequests.push(wsRequest);
228
-
229
- wsRequest.once('requestAccepted', this._handlers.requestAccepted);
230
- wsRequest.once('requestResolved', this._handlers.requestResolved);
231
- socket.once('close', function () {
232
- self._handlers.requestResolved(wsRequest);
233
- });
234
-
235
- if (!this.config.autoAcceptConnections && utils.eventEmitterListenerCount(this, 'request') > 0) {
236
- this.emit('request', wsRequest);
237
- }
238
- else if (this.config.autoAcceptConnections) {
239
- wsRequest.accept(wsRequest.requestedProtocols[0], wsRequest.origin);
240
- }
241
- else {
242
- wsRequest.reject(404, 'No handler is configured to accept the connection.');
243
- }
244
- };
245
-
246
- WebSocketServer.prototype.handleRequestAccepted = function(connection) {
247
- var self = this;
248
- connection.once('close', function(closeReason, description) {
249
- self.handleConnectionClose(connection, closeReason, description);
250
- });
251
- this.connections.push(connection);
252
- this.emit('connect', connection);
253
- };
254
-
255
- WebSocketServer.prototype.handleConnectionClose = function(connection, closeReason, description) {
256
- var index = this.connections.indexOf(connection);
257
- if (index !== -1) {
258
- this.connections.splice(index, 1);
259
- }
260
- this.emit('close', connection, closeReason, description);
261
- };
262
-
263
- WebSocketServer.prototype.handleRequestResolved = function(request) {
264
- var index = this.pendingRequests.indexOf(request);
265
- if (index !== -1) { this.pendingRequests.splice(index, 1); }
266
- };
267
-
268
- WebSocketServer_1 = WebSocketServer;
269
- return WebSocketServer_1;
270
- }
271
-
272
- export { requireWebSocketServer as __require };
@@ -1,80 +0,0 @@
1
- import { commonjsGlobal } from '../../../_virtual/_commonjsHelpers.js';
2
- import { __exports as utils } from '../../../_virtual/utils.js';
3
- import require$$1 from 'events';
4
- import { __require as requireSrc } from '../node_modules/debug/src/index.js';
5
-
6
- var hasRequiredUtils;
7
-
8
- function requireUtils () {
9
- if (hasRequiredUtils) return utils;
10
- hasRequiredUtils = 1;
11
- var noop = utils.noop = function(){};
12
-
13
- utils.extend = function extend(dest, source) {
14
- for (var prop in source) {
15
- dest[prop] = source[prop];
16
- }
17
- };
18
-
19
- utils.eventEmitterListenerCount =
20
- require$$1.EventEmitter.listenerCount ||
21
- function(emitter, type) { return emitter.listeners(type).length; };
22
-
23
- utils.bufferAllocUnsafe = Buffer.allocUnsafe ?
24
- Buffer.allocUnsafe :
25
- function oldBufferAllocUnsafe(size) { return new Buffer(size); };
26
-
27
- utils.bufferFromString = Buffer.from ?
28
- Buffer.from :
29
- function oldBufferFromString(string, encoding) {
30
- return new Buffer(string, encoding);
31
- };
32
-
33
- utils.BufferingLogger = function createBufferingLogger(identifier, uniqueID) {
34
- var logFunction = requireSrc()(identifier);
35
- if (logFunction.enabled) {
36
- var logger = new BufferingLogger(identifier, uniqueID, logFunction);
37
- var debug = logger.log.bind(logger);
38
- debug.printOutput = logger.printOutput.bind(logger);
39
- debug.enabled = logFunction.enabled;
40
- return debug;
41
- }
42
- logFunction.printOutput = noop;
43
- return logFunction;
44
- };
45
-
46
- function BufferingLogger(identifier, uniqueID, logFunction) {
47
- this.logFunction = logFunction;
48
- this.identifier = identifier;
49
- this.uniqueID = uniqueID;
50
- this.buffer = [];
51
- }
52
-
53
- BufferingLogger.prototype.log = function() {
54
- this.buffer.push([ new Date(), Array.prototype.slice.call(arguments) ]);
55
- return this;
56
- };
57
-
58
- BufferingLogger.prototype.clear = function() {
59
- this.buffer = [];
60
- return this;
61
- };
62
-
63
- BufferingLogger.prototype.printOutput = function(logFunction) {
64
- if (!logFunction) { logFunction = this.logFunction; }
65
- var uniqueID = this.uniqueID;
66
- this.buffer.forEach(function(entry) {
67
- var date = entry[0].toLocaleString();
68
- var args = entry[1].slice();
69
- var formatString = args[0];
70
- if (formatString !== (void 0) && formatString !== null) {
71
- formatString = '%s - %s - ' + formatString.toString();
72
- args.splice(0, 1, formatString, date, uniqueID);
73
- logFunction.apply(commonjsGlobal, args);
74
- }
75
- });
76
- };
77
- return utils;
78
- }
79
-
80
- export { requireUtils as __require };
@@ -1,13 +0,0 @@
1
- import require$$0 from '../package.json.js';
2
-
3
- var version;
4
- var hasRequiredVersion;
5
-
6
- function requireVersion () {
7
- if (hasRequiredVersion) return version;
8
- hasRequiredVersion = 1;
9
- version = require$$0.version;
10
- return version;
11
- }
12
-
13
- export { requireVersion as __require };
@@ -1,31 +0,0 @@
1
- import { __require as requireWebSocketServer } from './WebSocketServer.js';
2
- import { __require as requireWebSocketClient } from './WebSocketClient.js';
3
- import { __require as requireWebSocketRouter } from './WebSocketRouter.js';
4
- import { __require as requireWebSocketFrame } from './WebSocketFrame.js';
5
- import { __require as requireWebSocketRequest } from './WebSocketRequest.js';
6
- import { __require as requireWebSocketConnection } from './WebSocketConnection.js';
7
- import { __require as requireW3CWebSocket } from './W3CWebSocket.js';
8
- import { __require as requireDeprecation } from './Deprecation.js';
9
- import { __require as requireVersion } from './version.js';
10
-
11
- var websocket;
12
- var hasRequiredWebsocket;
13
-
14
- function requireWebsocket () {
15
- if (hasRequiredWebsocket) return websocket;
16
- hasRequiredWebsocket = 1;
17
- websocket = {
18
- 'server' : requireWebSocketServer(),
19
- 'client' : requireWebSocketClient(),
20
- 'router' : requireWebSocketRouter(),
21
- 'frame' : requireWebSocketFrame(),
22
- 'request' : requireWebSocketRequest(),
23
- 'connection' : requireWebSocketConnection(),
24
- 'w3cwebsocket' : requireW3CWebSocket(),
25
- 'deprecation' : requireDeprecation(),
26
- 'version' : requireVersion()
27
- };
28
- return websocket;
29
- }
30
-
31
- export { requireWebsocket as __require };