openportal 0.1.1 → 0.1.3

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 (182) hide show
  1. package/README.md +113 -0
  2. package/package.json +1 -1
  3. package/web/.next/static/{A7pW-dtFIbPCSkvE8uenX → Im7EdK1Q3oOmTznohTOr5}/_buildManifest.js +4 -9
  4. package/web/.next/static/chunks/{2e7bfb90c343ca96.js → 35cc9dbdc670c73c.js} +4 -4
  5. package/web/.next/static/chunks/4147ffc67a7b837c.css +1 -0
  6. package/web/.next/static/chunks/{21ab2574b84ad2d1.js → 52b90bc1740162c2.js} +2 -2
  7. package/web/.next/static/chunks/{9b265e2198b5525f.js → 8644d68bf325ff24.js} +3 -3
  8. package/web/.next/static/chunks/{03e1846335a31354.js → 9865709466b09f79.js} +3 -3
  9. package/web/.next/static/chunks/{c20ae04df8cc28be.js → 9ba9a5774c9421bd.js} +3 -3
  10. package/web/.next/static/chunks/{967a1e0002fe9ae6.js → b5caad256518cb33.js} +3 -3
  11. package/web/.next/static/chunks/{turbopack-27558c851386934e.js → turbopack-26af71e419c11487.js} +1 -1
  12. package/web/.next/static/chunks/{turbopack-f4c0881f9723f5a5.js → turbopack-4ad0df7330c00c8d.js} +1 -1
  13. package/web/.next/static/chunks/{turbopack-26688626142ac58f.js → turbopack-8e653f3ad3a8ed18.js} +1 -1
  14. package/web/.next/static/chunks/{turbopack-c40ec6674624f1d7.js → turbopack-d5098189d63fd7b8.js} +1 -1
  15. package/web/apps/web/.next/BUILD_ID +1 -1
  16. package/web/apps/web/.next/build-manifest.json +14 -24
  17. package/web/apps/web/.next/routes-manifest.json +0 -12
  18. package/web/apps/web/.next/server/chunks/[root-of-the-server]__f366ca98._.js +358 -0
  19. package/web/apps/web/.next/server/chunks/ssr/{[root-of-the-server]__dfeaf8cf._.js → [root-of-the-server]__1a54ba1e._.js} +3 -3
  20. package/web/apps/web/.next/server/middleware-build-manifest.js +12 -22
  21. package/web/apps/web/.next/server/next-font-manifest.js +1 -1
  22. package/web/apps/web/.next/server/next-font-manifest.json +0 -4
  23. package/web/apps/web/.next/server/pages/404.html +1 -1
  24. package/web/apps/web/.next/server/pages/500.html +1 -1
  25. package/web/apps/web/.next/server/pages/_app/build-manifest.json +3 -3
  26. package/web/apps/web/.next/server/pages/_app/client-build-manifest.json +1 -1
  27. package/web/apps/web/.next/server/pages/api/[[...slugs]].js +1 -2
  28. package/web/apps/web/.next/server/pages/api/[[...slugs]].js.nft.json +1 -1
  29. package/web/apps/web/.next/server/pages/index/build-manifest.json +3 -3
  30. package/web/apps/web/.next/server/pages/index/client-build-manifest.json +1 -1
  31. package/web/apps/web/.next/server/pages/index.html +1 -1
  32. package/web/apps/web/.next/server/pages/index.js.nft.json +1 -1
  33. package/web/apps/web/.next/server/pages/session/[id]/build-manifest.json +4 -4
  34. package/web/apps/web/.next/server/pages/session/[id]/client-build-manifest.json +1 -1
  35. package/web/apps/web/.next/server/pages/session/[id].html +1 -1
  36. package/web/apps/web/.next/server/pages/session/[id].js.nft.json +1 -1
  37. package/web/apps/web/.next/server/pages/settings/build-manifest.json +3 -3
  38. package/web/apps/web/.next/server/pages/settings/client-build-manifest.json +1 -1
  39. package/web/apps/web/.next/server/pages/settings.html +1 -1
  40. package/web/apps/web/.next/server/pages/settings.js.nft.json +1 -1
  41. package/web/apps/web/.next/server/pages-manifest.json +0 -2
  42. package/web/apps/web/package.json +1 -9
  43. package/web/.next/static/chunks/04d4692d75696297.css +0 -1
  44. package/web/.next/static/chunks/553710f60e2f2b11.js +0 -1
  45. package/web/.next/static/chunks/58acbbb4090e3362.js +0 -3
  46. package/web/.next/static/chunks/6ce1e2f08f961db5.js +0 -2
  47. package/web/.next/static/chunks/d316d63225992c76.js +0 -10
  48. package/web/.next/static/chunks/e0c97552ba7a9e3d.js +0 -1
  49. package/web/.next/static/chunks/fc9c4f2dabfb4e0e.css +0 -1
  50. package/web/.next/static/chunks/turbopack-1837909a677d116b.js +0 -3
  51. package/web/apps/web/.next/server/chunks/[root-of-the-server]__0f75905d._.js +0 -3
  52. package/web/apps/web/.next/server/chunks/[root-of-the-server]__89e85365._.js +0 -358
  53. package/web/apps/web/.next/server/chunks/[root-of-the-server]__ae1361d0._.js +0 -3
  54. package/web/apps/web/.next/server/pages/api/terminal/ws/pages-manifest.json +0 -3
  55. package/web/apps/web/.next/server/pages/api/terminal/ws.js +0 -5
  56. package/web/apps/web/.next/server/pages/api/terminal/ws.js.map +0 -5
  57. package/web/apps/web/.next/server/pages/api/terminal/ws.js.nft.json +0 -1
  58. package/web/apps/web/.next/server/pages/terminal/build-manifest.json +0 -20
  59. package/web/apps/web/.next/server/pages/terminal/client-build-manifest.json +0 -5
  60. package/web/apps/web/.next/server/pages/terminal/next-font-manifest.json +0 -11
  61. package/web/apps/web/.next/server/pages/terminal/pages-manifest.json +0 -3
  62. package/web/apps/web/.next/server/pages/terminal/react-loadable-manifest.json +0 -1
  63. package/web/apps/web/.next/server/pages/terminal.html +0 -1
  64. package/web/apps/web/.next/server/pages/terminal.js.map +0 -5
  65. package/web/apps/web/.next/server/pages/terminal.js.nft.json +0 -1
  66. package/web/node_modules/.bun/@socket.io+component-emitter@3.1.2/node_modules/@socket.io/component-emitter/lib/cjs/index.js +0 -176
  67. package/web/node_modules/.bun/@socket.io+component-emitter@3.1.2/node_modules/@socket.io/component-emitter/lib/cjs/package.json +0 -4
  68. package/web/node_modules/.bun/@socket.io+component-emitter@3.1.2/node_modules/@socket.io/component-emitter/package.json +0 -28
  69. package/web/node_modules/.bun/accepts@1.3.8/node_modules/accepts/index.js +0 -238
  70. package/web/node_modules/.bun/accepts@1.3.8/node_modules/accepts/package.json +0 -47
  71. package/web/node_modules/.bun/base64id@2.0.0/node_modules/base64id/lib/base64id.js +0 -103
  72. package/web/node_modules/.bun/base64id@2.0.0/node_modules/base64id/package.json +0 -13
  73. package/web/node_modules/.bun/cookie@0.7.2/node_modules/cookie/index.js +0 -335
  74. package/web/node_modules/.bun/cookie@0.7.2/node_modules/cookie/package.json +0 -44
  75. package/web/node_modules/.bun/cookie@1.1.1/node_modules/cookie/package.json +0 -47
  76. package/web/node_modules/.bun/cors@2.8.5/node_modules/cors/lib/index.js +0 -238
  77. package/web/node_modules/.bun/cors@2.8.5/node_modules/cors/package.json +0 -41
  78. package/web/node_modules/.bun/debug@4.3.7/node_modules/debug/package.json +0 -60
  79. package/web/node_modules/.bun/debug@4.3.7/node_modules/debug/src/browser.js +0 -271
  80. package/web/node_modules/.bun/debug@4.3.7/node_modules/debug/src/common.js +0 -274
  81. package/web/node_modules/.bun/debug@4.3.7/node_modules/debug/src/index.js +0 -10
  82. package/web/node_modules/.bun/debug@4.3.7/node_modules/debug/src/node.js +0 -263
  83. package/web/node_modules/.bun/engine.io-parser@5.2.3/node_modules/engine.io-parser/build/cjs/commons.js +0 -19
  84. package/web/node_modules/.bun/engine.io-parser@5.2.3/node_modules/engine.io-parser/build/cjs/decodePacket.js +0 -59
  85. package/web/node_modules/.bun/engine.io-parser@5.2.3/node_modules/engine.io-parser/build/cjs/encodePacket.js +0 -38
  86. package/web/node_modules/.bun/engine.io-parser@5.2.3/node_modules/engine.io-parser/build/cjs/index.js +0 -164
  87. package/web/node_modules/.bun/engine.io-parser@5.2.3/node_modules/engine.io-parser/build/cjs/package.json +0 -8
  88. package/web/node_modules/.bun/engine.io-parser@5.2.3/node_modules/engine.io-parser/package.json +0 -46
  89. package/web/node_modules/.bun/engine.io@6.6.4/node_modules/engine.io/build/engine.io.js +0 -54
  90. package/web/node_modules/.bun/engine.io@6.6.4/node_modules/engine.io/build/parser-v3/index.js +0 -424
  91. package/web/node_modules/.bun/engine.io@6.6.4/node_modules/engine.io/build/parser-v3/utf8.js +0 -187
  92. package/web/node_modules/.bun/engine.io@6.6.4/node_modules/engine.io/build/server.js +0 -786
  93. package/web/node_modules/.bun/engine.io@6.6.4/node_modules/engine.io/build/socket.js +0 -460
  94. package/web/node_modules/.bun/engine.io@6.6.4/node_modules/engine.io/build/transport.js +0 -117
  95. package/web/node_modules/.bun/engine.io@6.6.4/node_modules/engine.io/build/transports/index.js +0 -23
  96. package/web/node_modules/.bun/engine.io@6.6.4/node_modules/engine.io/build/transports/polling-jsonp.js +0 -41
  97. package/web/node_modules/.bun/engine.io@6.6.4/node_modules/engine.io/build/transports/polling.js +0 -332
  98. package/web/node_modules/.bun/engine.io@6.6.4/node_modules/engine.io/build/transports/websocket.js +0 -94
  99. package/web/node_modules/.bun/engine.io@6.6.4/node_modules/engine.io/build/transports/webtransport.js +0 -63
  100. package/web/node_modules/.bun/engine.io@6.6.4/node_modules/engine.io/build/transports-uws/index.js +0 -8
  101. package/web/node_modules/.bun/engine.io@6.6.4/node_modules/engine.io/build/transports-uws/polling.js +0 -364
  102. package/web/node_modules/.bun/engine.io@6.6.4/node_modules/engine.io/build/transports-uws/websocket.js +0 -73
  103. package/web/node_modules/.bun/engine.io@6.6.4/node_modules/engine.io/build/userver.js +0 -279
  104. package/web/node_modules/.bun/engine.io@6.6.4/node_modules/engine.io/package.json +0 -70
  105. package/web/node_modules/.bun/has-flag@4.0.0/node_modules/has-flag/index.js +0 -8
  106. package/web/node_modules/.bun/has-flag@4.0.0/node_modules/has-flag/package.json +0 -46
  107. package/web/node_modules/.bun/mime-db@1.52.0/node_modules/mime-db/db.json +0 -8519
  108. package/web/node_modules/.bun/mime-db@1.52.0/node_modules/mime-db/index.js +0 -12
  109. package/web/node_modules/.bun/mime-db@1.52.0/node_modules/mime-db/package.json +0 -60
  110. package/web/node_modules/.bun/mime-types@2.1.35/node_modules/mime-types/index.js +0 -188
  111. package/web/node_modules/.bun/mime-types@2.1.35/node_modules/mime-types/package.json +0 -44
  112. package/web/node_modules/.bun/ms@2.1.3/node_modules/ms/index.js +0 -162
  113. package/web/node_modules/.bun/ms@2.1.3/node_modules/ms/package.json +0 -38
  114. package/web/node_modules/.bun/negotiator@0.6.3/node_modules/negotiator/index.js +0 -82
  115. package/web/node_modules/.bun/negotiator@0.6.3/node_modules/negotiator/lib/charset.js +0 -169
  116. package/web/node_modules/.bun/negotiator@0.6.3/node_modules/negotiator/lib/encoding.js +0 -184
  117. package/web/node_modules/.bun/negotiator@0.6.3/node_modules/negotiator/lib/language.js +0 -179
  118. package/web/node_modules/.bun/negotiator@0.6.3/node_modules/negotiator/lib/mediaType.js +0 -294
  119. package/web/node_modules/.bun/negotiator@0.6.3/node_modules/negotiator/package.json +0 -42
  120. package/web/node_modules/.bun/object-assign@4.1.1/node_modules/object-assign/index.js +0 -90
  121. package/web/node_modules/.bun/object-assign@4.1.1/node_modules/object-assign/package.json +0 -42
  122. package/web/node_modules/.bun/socket.io-adapter@2.5.5/node_modules/socket.io-adapter/dist/cluster-adapter.js +0 -674
  123. package/web/node_modules/.bun/socket.io-adapter@2.5.5/node_modules/socket.io-adapter/dist/contrib/yeast.js +0 -55
  124. package/web/node_modules/.bun/socket.io-adapter@2.5.5/node_modules/socket.io-adapter/dist/in-memory-adapter.js +0 -394
  125. package/web/node_modules/.bun/socket.io-adapter@2.5.5/node_modules/socket.io-adapter/dist/index.js +0 -10
  126. package/web/node_modules/.bun/socket.io-adapter@2.5.5/node_modules/socket.io-adapter/package.json +0 -39
  127. package/web/node_modules/.bun/socket.io-parser@4.2.4/node_modules/socket.io-parser/build/cjs/binary.js +0 -88
  128. package/web/node_modules/.bun/socket.io-parser@4.2.4/node_modules/socket.io-parser/build/cjs/index.js +0 -321
  129. package/web/node_modules/.bun/socket.io-parser@4.2.4/node_modules/socket.io-parser/build/cjs/is-binary.js +0 -55
  130. package/web/node_modules/.bun/socket.io-parser@4.2.4/node_modules/socket.io-parser/build/cjs/package.json +0 -3
  131. package/web/node_modules/.bun/socket.io-parser@4.2.4/node_modules/socket.io-parser/package.json +0 -58
  132. package/web/node_modules/.bun/socket.io@4.8.1/node_modules/socket.io/client-dist/socket.io.esm.min.js +0 -7
  133. package/web/node_modules/.bun/socket.io@4.8.1/node_modules/socket.io/client-dist/socket.io.js +0 -4908
  134. package/web/node_modules/.bun/socket.io@4.8.1/node_modules/socket.io/client-dist/socket.io.min.js +0 -7
  135. package/web/node_modules/.bun/socket.io@4.8.1/node_modules/socket.io/client-dist/socket.io.msgpack.min.js +0 -7
  136. package/web/node_modules/.bun/socket.io@4.8.1/node_modules/socket.io/dist/broadcast-operator.js +0 -436
  137. package/web/node_modules/.bun/socket.io@4.8.1/node_modules/socket.io/dist/client.js +0 -268
  138. package/web/node_modules/.bun/socket.io@4.8.1/node_modules/socket.io/dist/index.js +0 -804
  139. package/web/node_modules/.bun/socket.io@4.8.1/node_modules/socket.io/dist/namespace.js +0 -581
  140. package/web/node_modules/.bun/socket.io@4.8.1/node_modules/socket.io/dist/parent-namespace.js +0 -88
  141. package/web/node_modules/.bun/socket.io@4.8.1/node_modules/socket.io/dist/socket-types.js +0 -11
  142. package/web/node_modules/.bun/socket.io@4.8.1/node_modules/socket.io/dist/socket.js +0 -977
  143. package/web/node_modules/.bun/socket.io@4.8.1/node_modules/socket.io/dist/typed-events.js +0 -81
  144. package/web/node_modules/.bun/socket.io@4.8.1/node_modules/socket.io/dist/uws.js +0 -136
  145. package/web/node_modules/.bun/socket.io@4.8.1/node_modules/socket.io/package.json +0 -85
  146. package/web/node_modules/.bun/socket.io@4.8.1/node_modules/socket.io/wrapper.mjs +0 -3
  147. package/web/node_modules/.bun/supports-color@7.2.0/node_modules/supports-color/index.js +0 -135
  148. package/web/node_modules/.bun/supports-color@7.2.0/node_modules/supports-color/package.json +0 -53
  149. package/web/node_modules/.bun/vary@1.1.2/node_modules/vary/index.js +0 -149
  150. package/web/node_modules/.bun/vary@1.1.2/node_modules/vary/package.json +0 -43
  151. package/web/node_modules/.bun/ws@8.17.1/node_modules/ws/index.js +0 -13
  152. package/web/node_modules/.bun/ws@8.17.1/node_modules/ws/lib/buffer-util.js +0 -131
  153. package/web/node_modules/.bun/ws@8.17.1/node_modules/ws/lib/constants.js +0 -12
  154. package/web/node_modules/.bun/ws@8.17.1/node_modules/ws/lib/event-target.js +0 -292
  155. package/web/node_modules/.bun/ws@8.17.1/node_modules/ws/lib/extension.js +0 -203
  156. package/web/node_modules/.bun/ws@8.17.1/node_modules/ws/lib/limiter.js +0 -55
  157. package/web/node_modules/.bun/ws@8.17.1/node_modules/ws/lib/permessage-deflate.js +0 -514
  158. package/web/node_modules/.bun/ws@8.17.1/node_modules/ws/lib/receiver.js +0 -704
  159. package/web/node_modules/.bun/ws@8.17.1/node_modules/ws/lib/sender.js +0 -497
  160. package/web/node_modules/.bun/ws@8.17.1/node_modules/ws/lib/stream.js +0 -159
  161. package/web/node_modules/.bun/ws@8.17.1/node_modules/ws/lib/subprotocol.js +0 -62
  162. package/web/node_modules/.bun/ws@8.17.1/node_modules/ws/lib/validation.js +0 -130
  163. package/web/node_modules/.bun/ws@8.17.1/node_modules/ws/lib/websocket-server.js +0 -540
  164. package/web/node_modules/.bun/ws@8.17.1/node_modules/ws/lib/websocket.js +0 -1338
  165. package/web/node_modules/.bun/ws@8.17.1/node_modules/ws/package.json +0 -69
  166. package/web/node_modules/.bun/ws@8.18.3/node_modules/ws/lib/buffer-util.js +0 -131
  167. package/web/node_modules/.bun/ws@8.18.3/node_modules/ws/lib/constants.js +0 -18
  168. package/web/node_modules/.bun/ws@8.18.3/node_modules/ws/lib/event-target.js +0 -292
  169. package/web/node_modules/.bun/ws@8.18.3/node_modules/ws/lib/extension.js +0 -203
  170. package/web/node_modules/.bun/ws@8.18.3/node_modules/ws/lib/limiter.js +0 -55
  171. package/web/node_modules/.bun/ws@8.18.3/node_modules/ws/lib/permessage-deflate.js +0 -528
  172. package/web/node_modules/.bun/ws@8.18.3/node_modules/ws/lib/receiver.js +0 -706
  173. package/web/node_modules/.bun/ws@8.18.3/node_modules/ws/lib/sender.js +0 -602
  174. package/web/node_modules/.bun/ws@8.18.3/node_modules/ws/lib/stream.js +0 -161
  175. package/web/node_modules/.bun/ws@8.18.3/node_modules/ws/lib/subprotocol.js +0 -62
  176. package/web/node_modules/.bun/ws@8.18.3/node_modules/ws/lib/validation.js +0 -152
  177. package/web/node_modules/.bun/ws@8.18.3/node_modules/ws/lib/websocket-server.js +0 -550
  178. package/web/node_modules/.bun/ws@8.18.3/node_modules/ws/lib/websocket.js +0 -1388
  179. package/web/node_modules/.bun/ws@8.18.3/node_modules/ws/package.json +0 -69
  180. package/web/node_modules/.bun/ws@8.18.3/node_modules/ws/wrapper.mjs +0 -8
  181. /package/web/.next/static/{A7pW-dtFIbPCSkvE8uenX → Im7EdK1Q3oOmTznohTOr5}/_clientMiddlewareManifest.json +0 -0
  182. /package/web/.next/static/{A7pW-dtFIbPCSkvE8uenX → Im7EdK1Q3oOmTznohTOr5}/_ssgManifest.js +0 -0
@@ -1,130 +0,0 @@
1
- 'use strict';
2
-
3
- const { isUtf8 } = require('buffer');
4
-
5
- //
6
- // Allowed token characters:
7
- //
8
- // '!', '#', '$', '%', '&', ''', '*', '+', '-',
9
- // '.', 0-9, A-Z, '^', '_', '`', a-z, '|', '~'
10
- //
11
- // tokenChars[32] === 0 // ' '
12
- // tokenChars[33] === 1 // '!'
13
- // tokenChars[34] === 0 // '"'
14
- // ...
15
- //
16
- // prettier-ignore
17
- const tokenChars = [
18
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0 - 15
19
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 16 - 31
20
- 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, // 32 - 47
21
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, // 48 - 63
22
- 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 64 - 79
23
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, // 80 - 95
24
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 96 - 111
25
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0 // 112 - 127
26
- ];
27
-
28
- /**
29
- * Checks if a status code is allowed in a close frame.
30
- *
31
- * @param {Number} code The status code
32
- * @return {Boolean} `true` if the status code is valid, else `false`
33
- * @public
34
- */
35
- function isValidStatusCode(code) {
36
- return (
37
- (code >= 1000 &&
38
- code <= 1014 &&
39
- code !== 1004 &&
40
- code !== 1005 &&
41
- code !== 1006) ||
42
- (code >= 3000 && code <= 4999)
43
- );
44
- }
45
-
46
- /**
47
- * Checks if a given buffer contains only correct UTF-8.
48
- * Ported from https://www.cl.cam.ac.uk/%7Emgk25/ucs/utf8_check.c by
49
- * Markus Kuhn.
50
- *
51
- * @param {Buffer} buf The buffer to check
52
- * @return {Boolean} `true` if `buf` contains only correct UTF-8, else `false`
53
- * @public
54
- */
55
- function _isValidUTF8(buf) {
56
- const len = buf.length;
57
- let i = 0;
58
-
59
- while (i < len) {
60
- if ((buf[i] & 0x80) === 0) {
61
- // 0xxxxxxx
62
- i++;
63
- } else if ((buf[i] & 0xe0) === 0xc0) {
64
- // 110xxxxx 10xxxxxx
65
- if (
66
- i + 1 === len ||
67
- (buf[i + 1] & 0xc0) !== 0x80 ||
68
- (buf[i] & 0xfe) === 0xc0 // Overlong
69
- ) {
70
- return false;
71
- }
72
-
73
- i += 2;
74
- } else if ((buf[i] & 0xf0) === 0xe0) {
75
- // 1110xxxx 10xxxxxx 10xxxxxx
76
- if (
77
- i + 2 >= len ||
78
- (buf[i + 1] & 0xc0) !== 0x80 ||
79
- (buf[i + 2] & 0xc0) !== 0x80 ||
80
- (buf[i] === 0xe0 && (buf[i + 1] & 0xe0) === 0x80) || // Overlong
81
- (buf[i] === 0xed && (buf[i + 1] & 0xe0) === 0xa0) // Surrogate (U+D800 - U+DFFF)
82
- ) {
83
- return false;
84
- }
85
-
86
- i += 3;
87
- } else if ((buf[i] & 0xf8) === 0xf0) {
88
- // 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
89
- if (
90
- i + 3 >= len ||
91
- (buf[i + 1] & 0xc0) !== 0x80 ||
92
- (buf[i + 2] & 0xc0) !== 0x80 ||
93
- (buf[i + 3] & 0xc0) !== 0x80 ||
94
- (buf[i] === 0xf0 && (buf[i + 1] & 0xf0) === 0x80) || // Overlong
95
- (buf[i] === 0xf4 && buf[i + 1] > 0x8f) ||
96
- buf[i] > 0xf4 // > U+10FFFF
97
- ) {
98
- return false;
99
- }
100
-
101
- i += 4;
102
- } else {
103
- return false;
104
- }
105
- }
106
-
107
- return true;
108
- }
109
-
110
- module.exports = {
111
- isValidStatusCode,
112
- isValidUTF8: _isValidUTF8,
113
- tokenChars
114
- };
115
-
116
- if (isUtf8) {
117
- module.exports.isValidUTF8 = function (buf) {
118
- return buf.length < 24 ? _isValidUTF8(buf) : isUtf8(buf);
119
- };
120
- } /* istanbul ignore else */ else if (!process.env.WS_NO_UTF_8_VALIDATE) {
121
- try {
122
- const isValidUTF8 = require('utf-8-validate');
123
-
124
- module.exports.isValidUTF8 = function (buf) {
125
- return buf.length < 32 ? _isValidUTF8(buf) : isValidUTF8(buf);
126
- };
127
- } catch (e) {
128
- // Continue regardless of the error.
129
- }
130
- }
@@ -1,540 +0,0 @@
1
- /* eslint no-unused-vars: ["error", { "varsIgnorePattern": "^Duplex$", "caughtErrors": "none" }] */
2
-
3
- 'use strict';
4
-
5
- const EventEmitter = require('events');
6
- const http = require('http');
7
- const { Duplex } = require('stream');
8
- const { createHash } = require('crypto');
9
-
10
- const extension = require('./extension');
11
- const PerMessageDeflate = require('./permessage-deflate');
12
- const subprotocol = require('./subprotocol');
13
- const WebSocket = require('./websocket');
14
- const { GUID, kWebSocket } = require('./constants');
15
-
16
- const keyRegex = /^[+/0-9A-Za-z]{22}==$/;
17
-
18
- const RUNNING = 0;
19
- const CLOSING = 1;
20
- const CLOSED = 2;
21
-
22
- /**
23
- * Class representing a WebSocket server.
24
- *
25
- * @extends EventEmitter
26
- */
27
- class WebSocketServer extends EventEmitter {
28
- /**
29
- * Create a `WebSocketServer` instance.
30
- *
31
- * @param {Object} options Configuration options
32
- * @param {Boolean} [options.allowSynchronousEvents=true] Specifies whether
33
- * any of the `'message'`, `'ping'`, and `'pong'` events can be emitted
34
- * multiple times in the same tick
35
- * @param {Boolean} [options.autoPong=true] Specifies whether or not to
36
- * automatically send a pong in response to a ping
37
- * @param {Number} [options.backlog=511] The maximum length of the queue of
38
- * pending connections
39
- * @param {Boolean} [options.clientTracking=true] Specifies whether or not to
40
- * track clients
41
- * @param {Function} [options.handleProtocols] A hook to handle protocols
42
- * @param {String} [options.host] The hostname where to bind the server
43
- * @param {Number} [options.maxPayload=104857600] The maximum allowed message
44
- * size
45
- * @param {Boolean} [options.noServer=false] Enable no server mode
46
- * @param {String} [options.path] Accept only connections matching this path
47
- * @param {(Boolean|Object)} [options.perMessageDeflate=false] Enable/disable
48
- * permessage-deflate
49
- * @param {Number} [options.port] The port where to bind the server
50
- * @param {(http.Server|https.Server)} [options.server] A pre-created HTTP/S
51
- * server to use
52
- * @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or
53
- * not to skip UTF-8 validation for text and close messages
54
- * @param {Function} [options.verifyClient] A hook to reject connections
55
- * @param {Function} [options.WebSocket=WebSocket] Specifies the `WebSocket`
56
- * class to use. It must be the `WebSocket` class or class that extends it
57
- * @param {Function} [callback] A listener for the `listening` event
58
- */
59
- constructor(options, callback) {
60
- super();
61
-
62
- options = {
63
- allowSynchronousEvents: true,
64
- autoPong: true,
65
- maxPayload: 100 * 1024 * 1024,
66
- skipUTF8Validation: false,
67
- perMessageDeflate: false,
68
- handleProtocols: null,
69
- clientTracking: true,
70
- verifyClient: null,
71
- noServer: false,
72
- backlog: null, // use default (511 as implemented in net.js)
73
- server: null,
74
- host: null,
75
- path: null,
76
- port: null,
77
- WebSocket,
78
- ...options
79
- };
80
-
81
- if (
82
- (options.port == null && !options.server && !options.noServer) ||
83
- (options.port != null && (options.server || options.noServer)) ||
84
- (options.server && options.noServer)
85
- ) {
86
- throw new TypeError(
87
- 'One and only one of the "port", "server", or "noServer" options ' +
88
- 'must be specified'
89
- );
90
- }
91
-
92
- if (options.port != null) {
93
- this._server = http.createServer((req, res) => {
94
- const body = http.STATUS_CODES[426];
95
-
96
- res.writeHead(426, {
97
- 'Content-Length': body.length,
98
- 'Content-Type': 'text/plain'
99
- });
100
- res.end(body);
101
- });
102
- this._server.listen(
103
- options.port,
104
- options.host,
105
- options.backlog,
106
- callback
107
- );
108
- } else if (options.server) {
109
- this._server = options.server;
110
- }
111
-
112
- if (this._server) {
113
- const emitConnection = this.emit.bind(this, 'connection');
114
-
115
- this._removeListeners = addListeners(this._server, {
116
- listening: this.emit.bind(this, 'listening'),
117
- error: this.emit.bind(this, 'error'),
118
- upgrade: (req, socket, head) => {
119
- this.handleUpgrade(req, socket, head, emitConnection);
120
- }
121
- });
122
- }
123
-
124
- if (options.perMessageDeflate === true) options.perMessageDeflate = {};
125
- if (options.clientTracking) {
126
- this.clients = new Set();
127
- this._shouldEmitClose = false;
128
- }
129
-
130
- this.options = options;
131
- this._state = RUNNING;
132
- }
133
-
134
- /**
135
- * Returns the bound address, the address family name, and port of the server
136
- * as reported by the operating system if listening on an IP socket.
137
- * If the server is listening on a pipe or UNIX domain socket, the name is
138
- * returned as a string.
139
- *
140
- * @return {(Object|String|null)} The address of the server
141
- * @public
142
- */
143
- address() {
144
- if (this.options.noServer) {
145
- throw new Error('The server is operating in "noServer" mode');
146
- }
147
-
148
- if (!this._server) return null;
149
- return this._server.address();
150
- }
151
-
152
- /**
153
- * Stop the server from accepting new connections and emit the `'close'` event
154
- * when all existing connections are closed.
155
- *
156
- * @param {Function} [cb] A one-time listener for the `'close'` event
157
- * @public
158
- */
159
- close(cb) {
160
- if (this._state === CLOSED) {
161
- if (cb) {
162
- this.once('close', () => {
163
- cb(new Error('The server is not running'));
164
- });
165
- }
166
-
167
- process.nextTick(emitClose, this);
168
- return;
169
- }
170
-
171
- if (cb) this.once('close', cb);
172
-
173
- if (this._state === CLOSING) return;
174
- this._state = CLOSING;
175
-
176
- if (this.options.noServer || this.options.server) {
177
- if (this._server) {
178
- this._removeListeners();
179
- this._removeListeners = this._server = null;
180
- }
181
-
182
- if (this.clients) {
183
- if (!this.clients.size) {
184
- process.nextTick(emitClose, this);
185
- } else {
186
- this._shouldEmitClose = true;
187
- }
188
- } else {
189
- process.nextTick(emitClose, this);
190
- }
191
- } else {
192
- const server = this._server;
193
-
194
- this._removeListeners();
195
- this._removeListeners = this._server = null;
196
-
197
- //
198
- // The HTTP/S server was created internally. Close it, and rely on its
199
- // `'close'` event.
200
- //
201
- server.close(() => {
202
- emitClose(this);
203
- });
204
- }
205
- }
206
-
207
- /**
208
- * See if a given request should be handled by this server instance.
209
- *
210
- * @param {http.IncomingMessage} req Request object to inspect
211
- * @return {Boolean} `true` if the request is valid, else `false`
212
- * @public
213
- */
214
- shouldHandle(req) {
215
- if (this.options.path) {
216
- const index = req.url.indexOf('?');
217
- const pathname = index !== -1 ? req.url.slice(0, index) : req.url;
218
-
219
- if (pathname !== this.options.path) return false;
220
- }
221
-
222
- return true;
223
- }
224
-
225
- /**
226
- * Handle a HTTP Upgrade request.
227
- *
228
- * @param {http.IncomingMessage} req The request object
229
- * @param {Duplex} socket The network socket between the server and client
230
- * @param {Buffer} head The first packet of the upgraded stream
231
- * @param {Function} cb Callback
232
- * @public
233
- */
234
- handleUpgrade(req, socket, head, cb) {
235
- socket.on('error', socketOnError);
236
-
237
- const key = req.headers['sec-websocket-key'];
238
- const upgrade = req.headers.upgrade;
239
- const version = +req.headers['sec-websocket-version'];
240
-
241
- if (req.method !== 'GET') {
242
- const message = 'Invalid HTTP method';
243
- abortHandshakeOrEmitwsClientError(this, req, socket, 405, message);
244
- return;
245
- }
246
-
247
- if (upgrade === undefined || upgrade.toLowerCase() !== 'websocket') {
248
- const message = 'Invalid Upgrade header';
249
- abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
250
- return;
251
- }
252
-
253
- if (key === undefined || !keyRegex.test(key)) {
254
- const message = 'Missing or invalid Sec-WebSocket-Key header';
255
- abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
256
- return;
257
- }
258
-
259
- if (version !== 8 && version !== 13) {
260
- const message = 'Missing or invalid Sec-WebSocket-Version header';
261
- abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
262
- return;
263
- }
264
-
265
- if (!this.shouldHandle(req)) {
266
- abortHandshake(socket, 400);
267
- return;
268
- }
269
-
270
- const secWebSocketProtocol = req.headers['sec-websocket-protocol'];
271
- let protocols = new Set();
272
-
273
- if (secWebSocketProtocol !== undefined) {
274
- try {
275
- protocols = subprotocol.parse(secWebSocketProtocol);
276
- } catch (err) {
277
- const message = 'Invalid Sec-WebSocket-Protocol header';
278
- abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
279
- return;
280
- }
281
- }
282
-
283
- const secWebSocketExtensions = req.headers['sec-websocket-extensions'];
284
- const extensions = {};
285
-
286
- if (
287
- this.options.perMessageDeflate &&
288
- secWebSocketExtensions !== undefined
289
- ) {
290
- const perMessageDeflate = new PerMessageDeflate(
291
- this.options.perMessageDeflate,
292
- true,
293
- this.options.maxPayload
294
- );
295
-
296
- try {
297
- const offers = extension.parse(secWebSocketExtensions);
298
-
299
- if (offers[PerMessageDeflate.extensionName]) {
300
- perMessageDeflate.accept(offers[PerMessageDeflate.extensionName]);
301
- extensions[PerMessageDeflate.extensionName] = perMessageDeflate;
302
- }
303
- } catch (err) {
304
- const message =
305
- 'Invalid or unacceptable Sec-WebSocket-Extensions header';
306
- abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
307
- return;
308
- }
309
- }
310
-
311
- //
312
- // Optionally call external client verification handler.
313
- //
314
- if (this.options.verifyClient) {
315
- const info = {
316
- origin:
317
- req.headers[`${version === 8 ? 'sec-websocket-origin' : 'origin'}`],
318
- secure: !!(req.socket.authorized || req.socket.encrypted),
319
- req
320
- };
321
-
322
- if (this.options.verifyClient.length === 2) {
323
- this.options.verifyClient(info, (verified, code, message, headers) => {
324
- if (!verified) {
325
- return abortHandshake(socket, code || 401, message, headers);
326
- }
327
-
328
- this.completeUpgrade(
329
- extensions,
330
- key,
331
- protocols,
332
- req,
333
- socket,
334
- head,
335
- cb
336
- );
337
- });
338
- return;
339
- }
340
-
341
- if (!this.options.verifyClient(info)) return abortHandshake(socket, 401);
342
- }
343
-
344
- this.completeUpgrade(extensions, key, protocols, req, socket, head, cb);
345
- }
346
-
347
- /**
348
- * Upgrade the connection to WebSocket.
349
- *
350
- * @param {Object} extensions The accepted extensions
351
- * @param {String} key The value of the `Sec-WebSocket-Key` header
352
- * @param {Set} protocols The subprotocols
353
- * @param {http.IncomingMessage} req The request object
354
- * @param {Duplex} socket The network socket between the server and client
355
- * @param {Buffer} head The first packet of the upgraded stream
356
- * @param {Function} cb Callback
357
- * @throws {Error} If called more than once with the same socket
358
- * @private
359
- */
360
- completeUpgrade(extensions, key, protocols, req, socket, head, cb) {
361
- //
362
- // Destroy the socket if the client has already sent a FIN packet.
363
- //
364
- if (!socket.readable || !socket.writable) return socket.destroy();
365
-
366
- if (socket[kWebSocket]) {
367
- throw new Error(
368
- 'server.handleUpgrade() was called more than once with the same ' +
369
- 'socket, possibly due to a misconfiguration'
370
- );
371
- }
372
-
373
- if (this._state > RUNNING) return abortHandshake(socket, 503);
374
-
375
- const digest = createHash('sha1')
376
- .update(key + GUID)
377
- .digest('base64');
378
-
379
- const headers = [
380
- 'HTTP/1.1 101 Switching Protocols',
381
- 'Upgrade: websocket',
382
- 'Connection: Upgrade',
383
- `Sec-WebSocket-Accept: ${digest}`
384
- ];
385
-
386
- const ws = new this.options.WebSocket(null, undefined, this.options);
387
-
388
- if (protocols.size) {
389
- //
390
- // Optionally call external protocol selection handler.
391
- //
392
- const protocol = this.options.handleProtocols
393
- ? this.options.handleProtocols(protocols, req)
394
- : protocols.values().next().value;
395
-
396
- if (protocol) {
397
- headers.push(`Sec-WebSocket-Protocol: ${protocol}`);
398
- ws._protocol = protocol;
399
- }
400
- }
401
-
402
- if (extensions[PerMessageDeflate.extensionName]) {
403
- const params = extensions[PerMessageDeflate.extensionName].params;
404
- const value = extension.format({
405
- [PerMessageDeflate.extensionName]: [params]
406
- });
407
- headers.push(`Sec-WebSocket-Extensions: ${value}`);
408
- ws._extensions = extensions;
409
- }
410
-
411
- //
412
- // Allow external modification/inspection of handshake headers.
413
- //
414
- this.emit('headers', headers, req);
415
-
416
- socket.write(headers.concat('\r\n').join('\r\n'));
417
- socket.removeListener('error', socketOnError);
418
-
419
- ws.setSocket(socket, head, {
420
- allowSynchronousEvents: this.options.allowSynchronousEvents,
421
- maxPayload: this.options.maxPayload,
422
- skipUTF8Validation: this.options.skipUTF8Validation
423
- });
424
-
425
- if (this.clients) {
426
- this.clients.add(ws);
427
- ws.on('close', () => {
428
- this.clients.delete(ws);
429
-
430
- if (this._shouldEmitClose && !this.clients.size) {
431
- process.nextTick(emitClose, this);
432
- }
433
- });
434
- }
435
-
436
- cb(ws, req);
437
- }
438
- }
439
-
440
- module.exports = WebSocketServer;
441
-
442
- /**
443
- * Add event listeners on an `EventEmitter` using a map of <event, listener>
444
- * pairs.
445
- *
446
- * @param {EventEmitter} server The event emitter
447
- * @param {Object.<String, Function>} map The listeners to add
448
- * @return {Function} A function that will remove the added listeners when
449
- * called
450
- * @private
451
- */
452
- function addListeners(server, map) {
453
- for (const event of Object.keys(map)) server.on(event, map[event]);
454
-
455
- return function removeListeners() {
456
- for (const event of Object.keys(map)) {
457
- server.removeListener(event, map[event]);
458
- }
459
- };
460
- }
461
-
462
- /**
463
- * Emit a `'close'` event on an `EventEmitter`.
464
- *
465
- * @param {EventEmitter} server The event emitter
466
- * @private
467
- */
468
- function emitClose(server) {
469
- server._state = CLOSED;
470
- server.emit('close');
471
- }
472
-
473
- /**
474
- * Handle socket errors.
475
- *
476
- * @private
477
- */
478
- function socketOnError() {
479
- this.destroy();
480
- }
481
-
482
- /**
483
- * Close the connection when preconditions are not fulfilled.
484
- *
485
- * @param {Duplex} socket The socket of the upgrade request
486
- * @param {Number} code The HTTP response status code
487
- * @param {String} [message] The HTTP response body
488
- * @param {Object} [headers] Additional HTTP response headers
489
- * @private
490
- */
491
- function abortHandshake(socket, code, message, headers) {
492
- //
493
- // The socket is writable unless the user destroyed or ended it before calling
494
- // `server.handleUpgrade()` or in the `verifyClient` function, which is a user
495
- // error. Handling this does not make much sense as the worst that can happen
496
- // is that some of the data written by the user might be discarded due to the
497
- // call to `socket.end()` below, which triggers an `'error'` event that in
498
- // turn causes the socket to be destroyed.
499
- //
500
- message = message || http.STATUS_CODES[code];
501
- headers = {
502
- Connection: 'close',
503
- 'Content-Type': 'text/html',
504
- 'Content-Length': Buffer.byteLength(message),
505
- ...headers
506
- };
507
-
508
- socket.once('finish', socket.destroy);
509
-
510
- socket.end(
511
- `HTTP/1.1 ${code} ${http.STATUS_CODES[code]}\r\n` +
512
- Object.keys(headers)
513
- .map((h) => `${h}: ${headers[h]}`)
514
- .join('\r\n') +
515
- '\r\n\r\n' +
516
- message
517
- );
518
- }
519
-
520
- /**
521
- * Emit a `'wsClientError'` event on a `WebSocketServer` if there is at least
522
- * one listener for it, otherwise call `abortHandshake()`.
523
- *
524
- * @param {WebSocketServer} server The WebSocket server
525
- * @param {http.IncomingMessage} req The request object
526
- * @param {Duplex} socket The socket of the upgrade request
527
- * @param {Number} code The HTTP response status code
528
- * @param {String} message The HTTP response body
529
- * @private
530
- */
531
- function abortHandshakeOrEmitwsClientError(server, req, socket, code, message) {
532
- if (server.listenerCount('wsClientError')) {
533
- const err = new Error(message);
534
- Error.captureStackTrace(err, abortHandshakeOrEmitwsClientError);
535
-
536
- server.emit('wsClientError', err, socket, req);
537
- } else {
538
- abortHandshake(socket, code, message);
539
- }
540
- }