@wabot-dev/framework 0.0.12 → 0.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/_virtual/XMLHttpRequest.js +7 -0
- package/dist/src/_virtual/_commonjsHelpers.js +32 -0
- package/dist/src/_virtual/base64id.js +3 -0
- package/dist/src/_virtual/binary.js +3 -0
- package/dist/src/_virtual/bom-handling.js +3 -0
- package/dist/src/_virtual/broadcast-operator.js +3 -0
- package/dist/src/_virtual/browser.js +3 -0
- package/dist/src/_virtual/browser2.js +3 -0
- package/dist/src/_virtual/browser3.js +3 -0
- package/dist/src/_virtual/browser4.js +3 -0
- package/dist/src/_virtual/browser5.js +3 -0
- package/dist/src/_virtual/buffer-util.js +3 -0
- package/dist/src/_virtual/buffer-util2.js +3 -0
- package/dist/src/_virtual/buffer-util3.js +3 -0
- package/dist/src/_virtual/charset.js +3 -0
- package/dist/src/_virtual/charset2.js +3 -0
- package/dist/src/_virtual/client.js +3 -0
- package/dist/src/_virtual/cluster-adapter.js +3 -0
- package/dist/src/_virtual/commons.js +3 -0
- package/dist/src/_virtual/dbcs-codec.js +3 -0
- package/dist/src/_virtual/decodePacket.js +3 -0
- package/dist/src/_virtual/encodePacket.js +3 -0
- package/dist/src/_virtual/encoding.js +3 -0
- package/dist/src/_virtual/encoding2.js +3 -0
- package/dist/src/_virtual/engine.io.js +3 -0
- package/dist/src/_virtual/in-memory-adapter.js +3 -0
- package/dist/src/_virtual/index.js +7 -0
- package/dist/src/_virtual/index10.js +3 -0
- package/dist/src/_virtual/index11.js +3 -0
- package/dist/src/_virtual/index12.js +3 -0
- package/dist/src/_virtual/index13.js +3 -0
- package/dist/src/_virtual/index14.js +3 -0
- package/dist/src/_virtual/index15.js +3 -0
- package/dist/src/_virtual/index16.js +3 -0
- package/dist/src/_virtual/index17.js +3 -0
- package/dist/src/_virtual/index18.js +3 -0
- package/dist/src/_virtual/index19.js +3 -0
- package/dist/src/_virtual/index2.js +7 -0
- package/dist/src/_virtual/index20.js +3 -0
- package/dist/src/_virtual/index21.js +3 -0
- package/dist/src/_virtual/index22.js +3 -0
- package/dist/src/_virtual/index23.js +3 -0
- package/dist/src/_virtual/index24.js +3 -0
- package/dist/src/_virtual/index25.js +3 -0
- package/dist/src/_virtual/index26.js +3 -0
- package/dist/src/_virtual/index27.js +3 -0
- package/dist/src/_virtual/index28.js +3 -0
- package/dist/src/_virtual/index29.js +3 -0
- package/dist/src/_virtual/index3.js +7 -0
- package/dist/src/_virtual/index30.js +3 -0
- package/dist/src/_virtual/index31.js +3 -0
- package/dist/src/_virtual/index32.js +3 -0
- package/dist/src/_virtual/index33.js +3 -0
- package/dist/src/_virtual/index4.js +3 -0
- package/dist/src/_virtual/index5.js +3 -0
- package/dist/src/_virtual/index6.js +3 -0
- package/dist/src/_virtual/index7.js +3 -0
- package/dist/src/_virtual/index8.js +6 -0
- package/dist/src/_virtual/index9.js +3 -0
- package/dist/src/_virtual/inherits.js +3 -0
- package/dist/src/_virtual/inherits_browser.js +3 -0
- package/dist/src/_virtual/is-binary.js +3 -0
- package/dist/src/_virtual/language.js +3 -0
- package/dist/src/_virtual/language2.js +3 -0
- package/dist/src/_virtual/mediaType.js +3 -0
- package/dist/src/_virtual/mediaType2.js +3 -0
- package/dist/src/_virtual/namespace.js +3 -0
- package/dist/src/_virtual/node.js +3 -0
- package/dist/src/_virtual/node2.js +3 -0
- package/dist/src/_virtual/node3.js +3 -0
- package/dist/src/_virtual/node4.js +3 -0
- package/dist/src/_virtual/node5.js +3 -0
- package/dist/src/_virtual/parent-namespace.js +3 -0
- package/dist/src/_virtual/polling-jsonp.js +3 -0
- package/dist/src/_virtual/polling.js +3 -0
- package/dist/src/_virtual/polling2.js +3 -0
- package/dist/src/_virtual/receiver.js +3 -0
- package/dist/src/_virtual/sbcs-codec.js +3 -0
- package/dist/src/_virtual/sender.js +3 -0
- package/dist/src/_virtual/server.js +3 -0
- package/dist/src/_virtual/socket-types.js +3 -0
- package/dist/src/_virtual/socket.js +3 -0
- package/dist/src/_virtual/socket2.js +3 -0
- package/dist/src/_virtual/stream.js +3 -0
- package/dist/src/_virtual/transport.js +3 -0
- package/dist/src/_virtual/typed-events.js +3 -0
- package/dist/src/_virtual/userver.js +3 -0
- package/dist/src/_virtual/utf16.js +3 -0
- package/dist/src/_virtual/utf32.js +3 -0
- package/dist/src/_virtual/utf7.js +3 -0
- package/dist/src/_virtual/uws.js +3 -0
- package/dist/src/_virtual/validation.js +3 -0
- package/dist/src/_virtual/validation2.js +3 -0
- package/dist/src/_virtual/validation3.js +3 -0
- package/dist/src/_virtual/websocket-server.js +3 -0
- package/dist/src/_virtual/websocket.js +7 -0
- package/dist/src/_virtual/websocket2.js +3 -0
- package/dist/src/_virtual/websocket3.js +3 -0
- package/dist/src/_virtual/webtransport.js +3 -0
- package/dist/src/_virtual/yeast.js +3 -0
- package/dist/src/channels/cmd/@cmd.js +2 -0
- package/dist/src/channels/cmd/CmdChannel.js +2 -0
- package/dist/src/channels/telegram/@telegram.js +2 -0
- package/dist/src/channels/telegram/TelegramChannel.js +2 -0
- package/dist/src/channels/whatsapp/@whatsapp.js +24 -0
- package/dist/src/channels/whatsapp/WhatsAppChannel.js +63 -0
- package/dist/src/channels/whatsapp/WhatsAppChannelConfig.js +8 -0
- package/dist/src/channels/whatsapp/WhatsAppConnection.js +61 -0
- package/dist/src/channels/whatsapp/WhatsAppDevConnection.js +61 -0
- package/dist/src/channels/whatsapp/WhatsAppProdConnection.js +36 -0
- package/dist/src/channels/whatsapp/whatsAppDevSocketContracts.js +9 -0
- package/dist/src/controller/express/Express.js +5 -0
- package/dist/src/controller/socket.io/SocketIO.js +5 -0
- package/dist/src/env/WabotEnv.js +21 -0
- package/dist/src/index.d.ts +168 -1
- package/dist/src/index.js +12 -0
- package/dist/src/logger/Logger.js +65 -0
- package/dist/src/node_modules/@socket.io/component-emitter/lib/esm/index.js +171 -0
- package/dist/src/node_modules/base64id/lib/base64id.js +117 -0
- package/dist/src/node_modules/body-parser/index.js +96 -0
- package/dist/src/node_modules/body-parser/lib/read.js +225 -0
- package/dist/src/node_modules/body-parser/lib/types/json.js +222 -0
- package/dist/src/node_modules/body-parser/lib/types/raw.js +90 -0
- package/dist/src/node_modules/body-parser/lib/types/text.js +95 -0
- package/dist/src/node_modules/body-parser/lib/types/urlencoded.js +194 -0
- package/dist/src/node_modules/body-parser/lib/utils.js +96 -0
- package/dist/src/node_modules/bytes/index.js +180 -0
- package/dist/src/node_modules/call-bind-apply-helpers/actualApply.js +24 -0
- package/dist/src/node_modules/call-bind-apply-helpers/functionApply.js +13 -0
- package/dist/src/node_modules/call-bind-apply-helpers/functionCall.js +13 -0
- package/dist/src/node_modules/call-bind-apply-helpers/index.js +29 -0
- package/dist/src/node_modules/call-bind-apply-helpers/reflectApply.js +13 -0
- package/dist/src/node_modules/call-bound/index.js +31 -0
- package/dist/src/node_modules/content-type/index.js +235 -0
- package/dist/src/node_modules/cookie/index.js +345 -0
- package/dist/src/node_modules/cors/lib/index.js +249 -0
- package/dist/src/node_modules/debug/src/browser.js +286 -0
- package/dist/src/node_modules/debug/src/common.js +303 -0
- package/dist/src/node_modules/debug/src/index.js +23 -0
- package/dist/src/node_modules/debug/src/node.js +279 -0
- package/dist/src/node_modules/depd/index.js +550 -0
- package/dist/src/node_modules/dunder-proto/get.js +42 -0
- package/dist/src/node_modules/ee-first/index.js +104 -0
- package/dist/src/node_modules/engine.io/build/engine.io.js +73 -0
- package/dist/src/node_modules/engine.io/build/parser-v3/index.js +429 -0
- package/dist/src/node_modules/engine.io/build/parser-v3/utf8.js +198 -0
- package/dist/src/node_modules/engine.io/build/server.js +808 -0
- package/dist/src/node_modules/engine.io/build/socket.js +469 -0
- package/dist/src/node_modules/engine.io/build/transport.js +131 -0
- package/dist/src/node_modules/engine.io/build/transports/index.js +37 -0
- package/dist/src/node_modules/engine.io/build/transports/polling-jsonp.js +53 -0
- package/dist/src/node_modules/engine.io/build/transports/polling.js +346 -0
- package/dist/src/node_modules/engine.io/build/transports/websocket.js +106 -0
- package/dist/src/node_modules/engine.io/build/transports/webtransport.js +76 -0
- package/dist/src/node_modules/engine.io/build/transports-uws/index.js +20 -0
- package/dist/src/node_modules/engine.io/build/transports-uws/polling.js +378 -0
- package/dist/src/node_modules/engine.io/build/transports-uws/websocket.js +85 -0
- package/dist/src/node_modules/engine.io/build/userver.js +292 -0
- package/dist/src/node_modules/engine.io/node_modules/accepts/index.js +250 -0
- package/dist/src/node_modules/engine.io/node_modules/debug/src/browser.js +285 -0
- package/dist/src/node_modules/engine.io/node_modules/debug/src/common.js +285 -0
- package/dist/src/node_modules/engine.io/node_modules/debug/src/index.js +23 -0
- package/dist/src/node_modules/engine.io/node_modules/debug/src/node.js +279 -0
- package/dist/src/node_modules/engine.io/node_modules/mime-db/db.json.js +10704 -0
- package/dist/src/node_modules/engine.io/node_modules/mime-db/index.js +24 -0
- package/dist/src/node_modules/engine.io/node_modules/mime-types/index.js +202 -0
- package/dist/src/node_modules/engine.io/node_modules/negotiator/index.js +96 -0
- package/dist/src/node_modules/engine.io/node_modules/negotiator/lib/charset.js +179 -0
- package/dist/src/node_modules/engine.io/node_modules/negotiator/lib/encoding.js +193 -0
- package/dist/src/node_modules/engine.io/node_modules/negotiator/lib/language.js +188 -0
- package/dist/src/node_modules/engine.io/node_modules/negotiator/lib/mediaType.js +304 -0
- package/dist/src/node_modules/engine.io/node_modules/ws/index.js +28 -0
- package/dist/src/node_modules/engine.io/node_modules/ws/lib/buffer-util.js +142 -0
- package/dist/src/node_modules/engine.io/node_modules/ws/lib/constants.js +21 -0
- package/dist/src/node_modules/engine.io/node_modules/ws/lib/event-target.js +303 -0
- package/dist/src/node_modules/engine.io/node_modules/ws/lib/extension.js +214 -0
- package/dist/src/node_modules/engine.io/node_modules/ws/lib/limiter.js +64 -0
- package/dist/src/node_modules/engine.io/node_modules/ws/lib/permessage-deflate.js +528 -0
- package/dist/src/node_modules/engine.io/node_modules/ws/lib/receiver.js +719 -0
- package/dist/src/node_modules/engine.io/node_modules/ws/lib/sender.js +513 -0
- package/dist/src/node_modules/engine.io/node_modules/ws/lib/stream.js +170 -0
- package/dist/src/node_modules/engine.io/node_modules/ws/lib/subprotocol.js +73 -0
- package/dist/src/node_modules/engine.io/node_modules/ws/lib/validation.js +141 -0
- package/dist/src/node_modules/engine.io/node_modules/ws/lib/websocket-server.js +559 -0
- package/dist/src/node_modules/engine.io/node_modules/ws/lib/websocket.js +1363 -0
- package/dist/src/node_modules/engine.io-client/build/esm/contrib/has-cors.js +13 -0
- package/dist/src/node_modules/engine.io-client/build/esm/contrib/parseqs.js +36 -0
- package/dist/src/node_modules/engine.io-client/build/esm/contrib/parseuri.js +66 -0
- package/dist/src/node_modules/engine.io-client/build/esm/globals.node.js +92 -0
- package/dist/src/node_modules/engine.io-client/build/esm/index.js +17 -0
- package/dist/src/node_modules/engine.io-client/build/esm/socket.js +728 -0
- package/dist/src/node_modules/engine.io-client/build/esm/transport.js +143 -0
- package/dist/src/node_modules/engine.io-client/build/esm/transports/index.js +11 -0
- package/dist/src/node_modules/engine.io-client/build/esm/transports/polling-xhr.js +256 -0
- package/dist/src/node_modules/engine.io-client/build/esm/transports/polling-xhr.node.js +21 -0
- package/dist/src/node_modules/engine.io-client/build/esm/transports/polling.js +146 -0
- package/dist/src/node_modules/engine.io-client/build/esm/transports/websocket.js +107 -0
- package/dist/src/node_modules/engine.io-client/build/esm/transports/websocket.node.js +48 -0
- package/dist/src/node_modules/engine.io-client/build/esm/transports/webtransport.js +83 -0
- package/dist/src/node_modules/engine.io-client/build/esm/util.js +62 -0
- package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/buffer-util.js +142 -0
- package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/constants.js +21 -0
- package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/event-target.js +303 -0
- package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/extension.js +214 -0
- package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/limiter.js +64 -0
- package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/permessage-deflate.js +528 -0
- package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/receiver.js +719 -0
- package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/sender.js +513 -0
- package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/stream.js +170 -0
- package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/subprotocol.js +73 -0
- package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/validation.js +141 -0
- package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/websocket-server.js +559 -0
- package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/websocket.js +1363 -0
- package/dist/src/node_modules/engine.io-parser/build/cjs/commons.js +29 -0
- package/dist/src/node_modules/engine.io-parser/build/cjs/decodePacket.js +70 -0
- package/dist/src/node_modules/engine.io-parser/build/cjs/encodePacket.js +51 -0
- package/dist/src/node_modules/engine.io-parser/build/cjs/index.js +179 -0
- package/dist/src/node_modules/engine.io-parser/build/esm/commons.js +15 -0
- package/dist/src/node_modules/engine.io-parser/build/esm/decodePacket.js +58 -0
- package/dist/src/node_modules/engine.io-parser/build/esm/encodePacket.js +36 -0
- package/dist/src/node_modules/engine.io-parser/build/esm/index.js +158 -0
- package/dist/src/node_modules/es-define-property/index.js +23 -0
- package/dist/src/node_modules/es-errors/eval.js +13 -0
- package/dist/src/node_modules/es-errors/index.js +13 -0
- package/dist/src/node_modules/es-errors/range.js +13 -0
- package/dist/src/node_modules/es-errors/ref.js +13 -0
- package/dist/src/node_modules/es-errors/syntax.js +13 -0
- package/dist/src/node_modules/es-errors/type.js +13 -0
- package/dist/src/node_modules/es-errors/uri.js +13 -0
- package/dist/src/node_modules/es-object-atoms/index.js +13 -0
- package/dist/src/node_modules/function-bind/implementation.js +93 -0
- package/dist/src/node_modules/function-bind/index.js +16 -0
- package/dist/src/node_modules/get-intrinsic/index.js +413 -0
- package/dist/src/node_modules/get-proto/Object.getPrototypeOf.js +17 -0
- package/dist/src/node_modules/get-proto/Reflect.getPrototypeOf.js +13 -0
- package/dist/src/node_modules/get-proto/index.js +40 -0
- package/dist/src/node_modules/gopd/gOPD.js +13 -0
- package/dist/src/node_modules/gopd/index.js +26 -0
- package/dist/src/node_modules/has-symbols/index.js +25 -0
- package/dist/src/node_modules/has-symbols/shams.js +54 -0
- package/dist/src/node_modules/hasown/index.js +19 -0
- package/dist/src/node_modules/http-errors/index.js +306 -0
- package/dist/src/node_modules/iconv-lite/encodings/dbcs-codec.js +598 -0
- package/dist/src/node_modules/iconv-lite/encodings/dbcs-data.js +206 -0
- package/dist/src/node_modules/iconv-lite/encodings/index.js +44 -0
- package/dist/src/node_modules/iconv-lite/encodings/internal.js +210 -0
- package/dist/src/node_modules/iconv-lite/encodings/sbcs-codec.js +83 -0
- package/dist/src/node_modules/iconv-lite/encodings/sbcs-data-generated.js +460 -0
- package/dist/src/node_modules/iconv-lite/encodings/sbcs-data.js +187 -0
- package/dist/src/node_modules/iconv-lite/encodings/tables/big5-added.json.js +506 -0
- package/dist/src/node_modules/iconv-lite/encodings/tables/cp936.json.js +2621 -0
- package/dist/src/node_modules/iconv-lite/encodings/tables/cp949.json.js +2380 -0
- package/dist/src/node_modules/iconv-lite/encodings/tables/cp950.json.js +729 -0
- package/dist/src/node_modules/iconv-lite/encodings/tables/eucjp.json.js +822 -0
- package/dist/src/node_modules/iconv-lite/encodings/tables/gb18030-ranges.json.js +424 -0
- package/dist/src/node_modules/iconv-lite/encodings/tables/gbk-added.json.js +264 -0
- package/dist/src/node_modules/iconv-lite/encodings/tables/shiftjis.json.js +548 -0
- package/dist/src/node_modules/iconv-lite/encodings/utf16.js +206 -0
- package/dist/src/node_modules/iconv-lite/encodings/utf32.js +329 -0
- package/dist/src/node_modules/iconv-lite/encodings/utf7.js +297 -0
- package/dist/src/node_modules/iconv-lite/lib/bom-handling.js +61 -0
- package/dist/src/node_modules/iconv-lite/lib/index.js +192 -0
- package/dist/src/node_modules/iconv-lite/lib/streams.js +120 -0
- package/dist/src/node_modules/inherits/inherits.js +21 -0
- package/dist/src/node_modules/inherits/inherits_browser.js +38 -0
- package/dist/src/node_modules/math-intrinsics/abs.js +13 -0
- package/dist/src/node_modules/math-intrinsics/floor.js +13 -0
- package/dist/src/node_modules/math-intrinsics/isNaN.js +15 -0
- package/dist/src/node_modules/math-intrinsics/max.js +13 -0
- package/dist/src/node_modules/math-intrinsics/min.js +13 -0
- package/dist/src/node_modules/math-intrinsics/pow.js +13 -0
- package/dist/src/node_modules/math-intrinsics/round.js +13 -0
- package/dist/src/node_modules/math-intrinsics/sign.js +22 -0
- package/dist/src/node_modules/media-typer/index.js +153 -0
- package/dist/src/node_modules/mime-db/db.json.js +11656 -0
- package/dist/src/node_modules/mime-db/index.js +24 -0
- package/dist/src/node_modules/mime-types/index.js +226 -0
- package/dist/src/node_modules/mime-types/mimeScore.js +62 -0
- package/dist/src/node_modules/ms/index.js +172 -0
- package/dist/src/node_modules/object-assign/index.js +99 -0
- package/dist/src/node_modules/object-inspect/index.js +557 -0
- package/dist/src/node_modules/object-inspect/util.inspect.js +13 -0
- package/dist/src/node_modules/on-finished/index.js +245 -0
- package/dist/src/node_modules/qs/lib/formats.js +32 -0
- package/dist/src/node_modules/qs/lib/index.js +24 -0
- package/dist/src/node_modules/qs/lib/parse.js +339 -0
- package/dist/src/node_modules/qs/lib/stringify.js +369 -0
- package/dist/src/node_modules/qs/lib/utils.js +279 -0
- package/dist/src/node_modules/raw-body/index.js +351 -0
- package/dist/src/node_modules/safer-buffer/safer.js +88 -0
- package/dist/src/node_modules/setprototypeof/index.js +26 -0
- package/dist/src/node_modules/side-channel/index.js +58 -0
- package/dist/src/node_modules/side-channel-list/index.js +125 -0
- package/dist/src/node_modules/side-channel-map/index.js +82 -0
- package/dist/src/node_modules/side-channel-weakmap/index.js +99 -0
- package/dist/src/node_modules/socket.io/dist/broadcast-operator.js +448 -0
- package/dist/src/node_modules/socket.io/dist/client.js +281 -0
- package/dist/src/node_modules/socket.io/dist/index.js +837 -0
- package/dist/src/node_modules/socket.io/dist/namespace.js +597 -0
- package/dist/src/node_modules/socket.io/dist/parent-namespace.js +101 -0
- package/dist/src/node_modules/socket.io/dist/socket-types.js +21 -0
- package/dist/src/node_modules/socket.io/dist/socket.js +993 -0
- package/dist/src/node_modules/socket.io/dist/typed-events.js +92 -0
- package/dist/src/node_modules/socket.io/dist/uws.js +149 -0
- package/dist/src/node_modules/socket.io/node_modules/accepts/index.js +250 -0
- package/dist/src/node_modules/socket.io/node_modules/debug/src/browser.js +285 -0
- package/dist/src/node_modules/socket.io/node_modules/debug/src/common.js +285 -0
- package/dist/src/node_modules/socket.io/node_modules/debug/src/index.js +23 -0
- package/dist/src/node_modules/socket.io/node_modules/debug/src/node.js +279 -0
- package/dist/src/node_modules/socket.io/node_modules/mime-db/db.json.js +10704 -0
- package/dist/src/node_modules/socket.io/node_modules/mime-db/index.js +24 -0
- package/dist/src/node_modules/socket.io/node_modules/mime-types/index.js +202 -0
- package/dist/src/node_modules/socket.io/node_modules/negotiator/index.js +96 -0
- package/dist/src/node_modules/socket.io/node_modules/negotiator/lib/charset.js +179 -0
- package/dist/src/node_modules/socket.io/node_modules/negotiator/lib/encoding.js +193 -0
- package/dist/src/node_modules/socket.io/node_modules/negotiator/lib/language.js +188 -0
- package/dist/src/node_modules/socket.io/node_modules/negotiator/lib/mediaType.js +304 -0
- package/dist/src/node_modules/socket.io/package.json.js +5 -0
- package/dist/src/node_modules/socket.io/wrapper.js +5 -0
- package/dist/src/node_modules/socket.io-adapter/dist/cluster-adapter.js +689 -0
- package/dist/src/node_modules/socket.io-adapter/dist/contrib/yeast.js +64 -0
- package/dist/src/node_modules/socket.io-adapter/dist/in-memory-adapter.js +407 -0
- package/dist/src/node_modules/socket.io-adapter/dist/index.js +24 -0
- package/dist/src/node_modules/socket.io-adapter/node_modules/debug/src/browser.js +285 -0
- package/dist/src/node_modules/socket.io-adapter/node_modules/debug/src/common.js +285 -0
- package/dist/src/node_modules/socket.io-adapter/node_modules/debug/src/index.js +23 -0
- package/dist/src/node_modules/socket.io-adapter/node_modules/debug/src/node.js +279 -0
- package/dist/src/node_modules/socket.io-adapter/node_modules/ws/index.js +28 -0
- package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/buffer-util.js +142 -0
- package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/constants.js +21 -0
- package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/event-target.js +303 -0
- package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/extension.js +214 -0
- package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/limiter.js +64 -0
- package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/permessage-deflate.js +528 -0
- package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/receiver.js +719 -0
- package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/sender.js +513 -0
- package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/stream.js +170 -0
- package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/subprotocol.js +73 -0
- package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/validation.js +141 -0
- package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/websocket-server.js +559 -0
- package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/websocket.js +1363 -0
- package/dist/src/node_modules/socket.io-client/build/esm/contrib/backo2.js +68 -0
- package/dist/src/node_modules/socket.io-client/build/esm/index.js +50 -0
- package/dist/src/node_modules/socket.io-client/build/esm/manager.js +373 -0
- package/dist/src/node_modules/socket.io-client/build/esm/on.js +8 -0
- package/dist/src/node_modules/socket.io-client/build/esm/socket.js +884 -0
- package/dist/src/node_modules/socket.io-client/build/esm/url.js +63 -0
- package/dist/src/node_modules/socket.io-parser/build/cjs/binary.js +99 -0
- package/dist/src/node_modules/socket.io-parser/build/cjs/index.js +337 -0
- package/dist/src/node_modules/socket.io-parser/build/cjs/is-binary.js +65 -0
- package/dist/src/node_modules/socket.io-parser/build/esm/binary.js +86 -0
- package/dist/src/node_modules/socket.io-parser/build/esm/index.js +314 -0
- package/dist/src/node_modules/socket.io-parser/build/esm/is-binary.js +52 -0
- package/dist/src/node_modules/socket.io-parser/node_modules/debug/src/browser.js +285 -0
- package/dist/src/node_modules/socket.io-parser/node_modules/debug/src/common.js +285 -0
- package/dist/src/node_modules/socket.io-parser/node_modules/debug/src/index.js +23 -0
- package/dist/src/node_modules/socket.io-parser/node_modules/debug/src/node.js +279 -0
- package/dist/src/node_modules/statuses/codes.json.js +67 -0
- package/dist/src/node_modules/statuses/index.js +157 -0
- package/dist/src/node_modules/toidentifier/index.js +41 -0
- package/dist/src/node_modules/type-is/index.js +263 -0
- package/dist/src/node_modules/unpipe/index.js +78 -0
- package/dist/src/node_modules/vary/index.js +159 -0
- package/dist/src/node_modules/xmlhttprequest-ssl/lib/XMLHttpRequest.js +702 -0
- package/dist/src/server/runChannel.js +8 -8
- package/dist/src/server/runServer.js +41 -2
- package/package.json +7 -3
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
import { __exports as cookie } from '../../_virtual/index30.js';
|
|
2
|
+
|
|
3
|
+
/*!
|
|
4
|
+
* cookie
|
|
5
|
+
* Copyright(c) 2012-2014 Roman Shtylman
|
|
6
|
+
* Copyright(c) 2015 Douglas Christopher Wilson
|
|
7
|
+
* MIT Licensed
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
var hasRequiredCookie;
|
|
11
|
+
|
|
12
|
+
function requireCookie () {
|
|
13
|
+
if (hasRequiredCookie) return cookie;
|
|
14
|
+
hasRequiredCookie = 1;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Module exports.
|
|
18
|
+
* @public
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
cookie.parse = parse;
|
|
22
|
+
cookie.serialize = serialize;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Module variables.
|
|
26
|
+
* @private
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
var __toString = Object.prototype.toString;
|
|
30
|
+
var __hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* RegExp to match cookie-name in RFC 6265 sec 4.1.1
|
|
34
|
+
* This refers out to the obsoleted definition of token in RFC 2616 sec 2.2
|
|
35
|
+
* which has been replaced by the token definition in RFC 7230 appendix B.
|
|
36
|
+
*
|
|
37
|
+
* cookie-name = token
|
|
38
|
+
* token = 1*tchar
|
|
39
|
+
* tchar = "!" / "#" / "$" / "%" / "&" / "'" /
|
|
40
|
+
* "*" / "+" / "-" / "." / "^" / "_" /
|
|
41
|
+
* "`" / "|" / "~" / DIGIT / ALPHA
|
|
42
|
+
*/
|
|
43
|
+
|
|
44
|
+
var cookieNameRegExp = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* RegExp to match cookie-value in RFC 6265 sec 4.1.1
|
|
48
|
+
*
|
|
49
|
+
* cookie-value = *cookie-octet / ( DQUOTE *cookie-octet DQUOTE )
|
|
50
|
+
* cookie-octet = %x21 / %x23-2B / %x2D-3A / %x3C-5B / %x5D-7E
|
|
51
|
+
* ; US-ASCII characters excluding CTLs,
|
|
52
|
+
* ; whitespace DQUOTE, comma, semicolon,
|
|
53
|
+
* ; and backslash
|
|
54
|
+
*/
|
|
55
|
+
|
|
56
|
+
var cookieValueRegExp = /^("?)[\u0021\u0023-\u002B\u002D-\u003A\u003C-\u005B\u005D-\u007E]*\1$/;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* RegExp to match domain-value in RFC 6265 sec 4.1.1
|
|
60
|
+
*
|
|
61
|
+
* domain-value = <subdomain>
|
|
62
|
+
* ; defined in [RFC1034], Section 3.5, as
|
|
63
|
+
* ; enhanced by [RFC1123], Section 2.1
|
|
64
|
+
* <subdomain> = <label> | <subdomain> "." <label>
|
|
65
|
+
* <label> = <let-dig> [ [ <ldh-str> ] <let-dig> ]
|
|
66
|
+
* Labels must be 63 characters or less.
|
|
67
|
+
* 'let-dig' not 'letter' in the first char, per RFC1123
|
|
68
|
+
* <ldh-str> = <let-dig-hyp> | <let-dig-hyp> <ldh-str>
|
|
69
|
+
* <let-dig-hyp> = <let-dig> | "-"
|
|
70
|
+
* <let-dig> = <letter> | <digit>
|
|
71
|
+
* <letter> = any one of the 52 alphabetic characters A through Z in
|
|
72
|
+
* upper case and a through z in lower case
|
|
73
|
+
* <digit> = any one of the ten digits 0 through 9
|
|
74
|
+
*
|
|
75
|
+
* Keep support for leading dot: https://github.com/jshttp/cookie/issues/173
|
|
76
|
+
*
|
|
77
|
+
* > (Note that a leading %x2E ("."), if present, is ignored even though that
|
|
78
|
+
* character is not permitted, but a trailing %x2E ("."), if present, will
|
|
79
|
+
* cause the user agent to ignore the attribute.)
|
|
80
|
+
*/
|
|
81
|
+
|
|
82
|
+
var domainValueRegExp = /^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* RegExp to match path-value in RFC 6265 sec 4.1.1
|
|
86
|
+
*
|
|
87
|
+
* path-value = <any CHAR except CTLs or ";">
|
|
88
|
+
* CHAR = %x01-7F
|
|
89
|
+
* ; defined in RFC 5234 appendix B.1
|
|
90
|
+
*/
|
|
91
|
+
|
|
92
|
+
var pathValueRegExp = /^[\u0020-\u003A\u003D-\u007E]*$/;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Parse a cookie header.
|
|
96
|
+
*
|
|
97
|
+
* Parse the given cookie header string into an object
|
|
98
|
+
* The object has the various cookies as keys(names) => values
|
|
99
|
+
*
|
|
100
|
+
* @param {string} str
|
|
101
|
+
* @param {object} [opt]
|
|
102
|
+
* @return {object}
|
|
103
|
+
* @public
|
|
104
|
+
*/
|
|
105
|
+
|
|
106
|
+
function parse(str, opt) {
|
|
107
|
+
if (typeof str !== 'string') {
|
|
108
|
+
throw new TypeError('argument str must be a string');
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
var obj = {};
|
|
112
|
+
var len = str.length;
|
|
113
|
+
// RFC 6265 sec 4.1.1, RFC 2616 2.2 defines a cookie name consists of one char minimum, plus '='.
|
|
114
|
+
if (len < 2) return obj;
|
|
115
|
+
|
|
116
|
+
var dec = (opt && opt.decode) || decode;
|
|
117
|
+
var index = 0;
|
|
118
|
+
var eqIdx = 0;
|
|
119
|
+
var endIdx = 0;
|
|
120
|
+
|
|
121
|
+
do {
|
|
122
|
+
eqIdx = str.indexOf('=', index);
|
|
123
|
+
if (eqIdx === -1) break; // No more cookie pairs.
|
|
124
|
+
|
|
125
|
+
endIdx = str.indexOf(';', index);
|
|
126
|
+
|
|
127
|
+
if (endIdx === -1) {
|
|
128
|
+
endIdx = len;
|
|
129
|
+
} else if (eqIdx > endIdx) {
|
|
130
|
+
// backtrack on prior semicolon
|
|
131
|
+
index = str.lastIndexOf(';', eqIdx - 1) + 1;
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
var keyStartIdx = startIndex(str, index, eqIdx);
|
|
136
|
+
var keyEndIdx = endIndex(str, eqIdx, keyStartIdx);
|
|
137
|
+
var key = str.slice(keyStartIdx, keyEndIdx);
|
|
138
|
+
|
|
139
|
+
// only assign once
|
|
140
|
+
if (!__hasOwnProperty.call(obj, key)) {
|
|
141
|
+
var valStartIdx = startIndex(str, eqIdx + 1, endIdx);
|
|
142
|
+
var valEndIdx = endIndex(str, endIdx, valStartIdx);
|
|
143
|
+
|
|
144
|
+
if (str.charCodeAt(valStartIdx) === 0x22 /* " */ && str.charCodeAt(valEndIdx - 1) === 0x22 /* " */) {
|
|
145
|
+
valStartIdx++;
|
|
146
|
+
valEndIdx--;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
var val = str.slice(valStartIdx, valEndIdx);
|
|
150
|
+
obj[key] = tryDecode(val, dec);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
index = endIdx + 1;
|
|
154
|
+
} while (index < len);
|
|
155
|
+
|
|
156
|
+
return obj;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function startIndex(str, index, max) {
|
|
160
|
+
do {
|
|
161
|
+
var code = str.charCodeAt(index);
|
|
162
|
+
if (code !== 0x20 /* */ && code !== 0x09 /* \t */) return index;
|
|
163
|
+
} while (++index < max);
|
|
164
|
+
return max;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function endIndex(str, index, min) {
|
|
168
|
+
while (index > min) {
|
|
169
|
+
var code = str.charCodeAt(--index);
|
|
170
|
+
if (code !== 0x20 /* */ && code !== 0x09 /* \t */) return index + 1;
|
|
171
|
+
}
|
|
172
|
+
return min;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Serialize data into a cookie header.
|
|
177
|
+
*
|
|
178
|
+
* Serialize a name value pair into a cookie string suitable for
|
|
179
|
+
* http headers. An optional options object specifies cookie parameters.
|
|
180
|
+
*
|
|
181
|
+
* serialize('foo', 'bar', { httpOnly: true })
|
|
182
|
+
* => "foo=bar; httpOnly"
|
|
183
|
+
*
|
|
184
|
+
* @param {string} name
|
|
185
|
+
* @param {string} val
|
|
186
|
+
* @param {object} [opt]
|
|
187
|
+
* @return {string}
|
|
188
|
+
* @public
|
|
189
|
+
*/
|
|
190
|
+
|
|
191
|
+
function serialize(name, val, opt) {
|
|
192
|
+
var enc = (opt && opt.encode) || encodeURIComponent;
|
|
193
|
+
|
|
194
|
+
if (typeof enc !== 'function') {
|
|
195
|
+
throw new TypeError('option encode is invalid');
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
if (!cookieNameRegExp.test(name)) {
|
|
199
|
+
throw new TypeError('argument name is invalid');
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
var value = enc(val);
|
|
203
|
+
|
|
204
|
+
if (!cookieValueRegExp.test(value)) {
|
|
205
|
+
throw new TypeError('argument val is invalid');
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
var str = name + '=' + value;
|
|
209
|
+
if (!opt) return str;
|
|
210
|
+
|
|
211
|
+
if (null != opt.maxAge) {
|
|
212
|
+
var maxAge = Math.floor(opt.maxAge);
|
|
213
|
+
|
|
214
|
+
if (!isFinite(maxAge)) {
|
|
215
|
+
throw new TypeError('option maxAge is invalid')
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
str += '; Max-Age=' + maxAge;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
if (opt.domain) {
|
|
222
|
+
if (!domainValueRegExp.test(opt.domain)) {
|
|
223
|
+
throw new TypeError('option domain is invalid');
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
str += '; Domain=' + opt.domain;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
if (opt.path) {
|
|
230
|
+
if (!pathValueRegExp.test(opt.path)) {
|
|
231
|
+
throw new TypeError('option path is invalid');
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
str += '; Path=' + opt.path;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
if (opt.expires) {
|
|
238
|
+
var expires = opt.expires;
|
|
239
|
+
|
|
240
|
+
if (!isDate(expires) || isNaN(expires.valueOf())) {
|
|
241
|
+
throw new TypeError('option expires is invalid');
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
str += '; Expires=' + expires.toUTCString();
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
if (opt.httpOnly) {
|
|
248
|
+
str += '; HttpOnly';
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
if (opt.secure) {
|
|
252
|
+
str += '; Secure';
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
if (opt.partitioned) {
|
|
256
|
+
str += '; Partitioned';
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
if (opt.priority) {
|
|
260
|
+
var priority = typeof opt.priority === 'string'
|
|
261
|
+
? opt.priority.toLowerCase() : opt.priority;
|
|
262
|
+
|
|
263
|
+
switch (priority) {
|
|
264
|
+
case 'low':
|
|
265
|
+
str += '; Priority=Low';
|
|
266
|
+
break
|
|
267
|
+
case 'medium':
|
|
268
|
+
str += '; Priority=Medium';
|
|
269
|
+
break
|
|
270
|
+
case 'high':
|
|
271
|
+
str += '; Priority=High';
|
|
272
|
+
break
|
|
273
|
+
default:
|
|
274
|
+
throw new TypeError('option priority is invalid')
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
if (opt.sameSite) {
|
|
279
|
+
var sameSite = typeof opt.sameSite === 'string'
|
|
280
|
+
? opt.sameSite.toLowerCase() : opt.sameSite;
|
|
281
|
+
|
|
282
|
+
switch (sameSite) {
|
|
283
|
+
case true:
|
|
284
|
+
str += '; SameSite=Strict';
|
|
285
|
+
break;
|
|
286
|
+
case 'lax':
|
|
287
|
+
str += '; SameSite=Lax';
|
|
288
|
+
break;
|
|
289
|
+
case 'strict':
|
|
290
|
+
str += '; SameSite=Strict';
|
|
291
|
+
break;
|
|
292
|
+
case 'none':
|
|
293
|
+
str += '; SameSite=None';
|
|
294
|
+
break;
|
|
295
|
+
default:
|
|
296
|
+
throw new TypeError('option sameSite is invalid');
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
return str;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* URL-decode string value. Optimized to skip native call when no %.
|
|
305
|
+
*
|
|
306
|
+
* @param {string} str
|
|
307
|
+
* @returns {string}
|
|
308
|
+
*/
|
|
309
|
+
|
|
310
|
+
function decode (str) {
|
|
311
|
+
return str.indexOf('%') !== -1
|
|
312
|
+
? decodeURIComponent(str)
|
|
313
|
+
: str
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Determine if value is a Date.
|
|
318
|
+
*
|
|
319
|
+
* @param {*} val
|
|
320
|
+
* @private
|
|
321
|
+
*/
|
|
322
|
+
|
|
323
|
+
function isDate (val) {
|
|
324
|
+
return __toString.call(val) === '[object Date]';
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* Try decoding a string using a decoding function.
|
|
329
|
+
*
|
|
330
|
+
* @param {string} str
|
|
331
|
+
* @param {function} decode
|
|
332
|
+
* @private
|
|
333
|
+
*/
|
|
334
|
+
|
|
335
|
+
function tryDecode(str, decode) {
|
|
336
|
+
try {
|
|
337
|
+
return decode(str);
|
|
338
|
+
} catch (e) {
|
|
339
|
+
return str;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
return cookie;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
export { requireCookie as __require };
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import { __module as lib } from '../../../_virtual/index13.js';
|
|
2
|
+
import { __require as requireObjectAssign } from '../../object-assign/index.js';
|
|
3
|
+
import { __require as requireVary } from '../../vary/index.js';
|
|
4
|
+
|
|
5
|
+
var hasRequiredLib;
|
|
6
|
+
|
|
7
|
+
function requireLib () {
|
|
8
|
+
if (hasRequiredLib) return lib.exports;
|
|
9
|
+
hasRequiredLib = 1;
|
|
10
|
+
(function () {
|
|
11
|
+
|
|
12
|
+
var assign = requireObjectAssign();
|
|
13
|
+
var vary = requireVary();
|
|
14
|
+
|
|
15
|
+
var defaults = {
|
|
16
|
+
origin: '*',
|
|
17
|
+
methods: 'GET,HEAD,PUT,PATCH,POST,DELETE',
|
|
18
|
+
preflightContinue: false,
|
|
19
|
+
optionsSuccessStatus: 204
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
function isString(s) {
|
|
23
|
+
return typeof s === 'string' || s instanceof String;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function isOriginAllowed(origin, allowedOrigin) {
|
|
27
|
+
if (Array.isArray(allowedOrigin)) {
|
|
28
|
+
for (var i = 0; i < allowedOrigin.length; ++i) {
|
|
29
|
+
if (isOriginAllowed(origin, allowedOrigin[i])) {
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return false;
|
|
34
|
+
} else if (isString(allowedOrigin)) {
|
|
35
|
+
return origin === allowedOrigin;
|
|
36
|
+
} else if (allowedOrigin instanceof RegExp) {
|
|
37
|
+
return allowedOrigin.test(origin);
|
|
38
|
+
} else {
|
|
39
|
+
return !!allowedOrigin;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function configureOrigin(options, req) {
|
|
44
|
+
var requestOrigin = req.headers.origin,
|
|
45
|
+
headers = [],
|
|
46
|
+
isAllowed;
|
|
47
|
+
|
|
48
|
+
if (!options.origin || options.origin === '*') {
|
|
49
|
+
// allow any origin
|
|
50
|
+
headers.push([{
|
|
51
|
+
key: 'Access-Control-Allow-Origin',
|
|
52
|
+
value: '*'
|
|
53
|
+
}]);
|
|
54
|
+
} else if (isString(options.origin)) {
|
|
55
|
+
// fixed origin
|
|
56
|
+
headers.push([{
|
|
57
|
+
key: 'Access-Control-Allow-Origin',
|
|
58
|
+
value: options.origin
|
|
59
|
+
}]);
|
|
60
|
+
headers.push([{
|
|
61
|
+
key: 'Vary',
|
|
62
|
+
value: 'Origin'
|
|
63
|
+
}]);
|
|
64
|
+
} else {
|
|
65
|
+
isAllowed = isOriginAllowed(requestOrigin, options.origin);
|
|
66
|
+
// reflect origin
|
|
67
|
+
headers.push([{
|
|
68
|
+
key: 'Access-Control-Allow-Origin',
|
|
69
|
+
value: isAllowed ? requestOrigin : false
|
|
70
|
+
}]);
|
|
71
|
+
headers.push([{
|
|
72
|
+
key: 'Vary',
|
|
73
|
+
value: 'Origin'
|
|
74
|
+
}]);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return headers;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function configureMethods(options) {
|
|
81
|
+
var methods = options.methods;
|
|
82
|
+
if (methods.join) {
|
|
83
|
+
methods = options.methods.join(','); // .methods is an array, so turn it into a string
|
|
84
|
+
}
|
|
85
|
+
return {
|
|
86
|
+
key: 'Access-Control-Allow-Methods',
|
|
87
|
+
value: methods
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function configureCredentials(options) {
|
|
92
|
+
if (options.credentials === true) {
|
|
93
|
+
return {
|
|
94
|
+
key: 'Access-Control-Allow-Credentials',
|
|
95
|
+
value: 'true'
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function configureAllowedHeaders(options, req) {
|
|
102
|
+
var allowedHeaders = options.allowedHeaders || options.headers;
|
|
103
|
+
var headers = [];
|
|
104
|
+
|
|
105
|
+
if (!allowedHeaders) {
|
|
106
|
+
allowedHeaders = req.headers['access-control-request-headers']; // .headers wasn't specified, so reflect the request headers
|
|
107
|
+
headers.push([{
|
|
108
|
+
key: 'Vary',
|
|
109
|
+
value: 'Access-Control-Request-Headers'
|
|
110
|
+
}]);
|
|
111
|
+
} else if (allowedHeaders.join) {
|
|
112
|
+
allowedHeaders = allowedHeaders.join(','); // .headers is an array, so turn it into a string
|
|
113
|
+
}
|
|
114
|
+
if (allowedHeaders && allowedHeaders.length) {
|
|
115
|
+
headers.push([{
|
|
116
|
+
key: 'Access-Control-Allow-Headers',
|
|
117
|
+
value: allowedHeaders
|
|
118
|
+
}]);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return headers;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function configureExposedHeaders(options) {
|
|
125
|
+
var headers = options.exposedHeaders;
|
|
126
|
+
if (!headers) {
|
|
127
|
+
return null;
|
|
128
|
+
} else if (headers.join) {
|
|
129
|
+
headers = headers.join(','); // .headers is an array, so turn it into a string
|
|
130
|
+
}
|
|
131
|
+
if (headers && headers.length) {
|
|
132
|
+
return {
|
|
133
|
+
key: 'Access-Control-Expose-Headers',
|
|
134
|
+
value: headers
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function configureMaxAge(options) {
|
|
141
|
+
var maxAge = (typeof options.maxAge === 'number' || options.maxAge) && options.maxAge.toString();
|
|
142
|
+
if (maxAge && maxAge.length) {
|
|
143
|
+
return {
|
|
144
|
+
key: 'Access-Control-Max-Age',
|
|
145
|
+
value: maxAge
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function applyHeaders(headers, res) {
|
|
152
|
+
for (var i = 0, n = headers.length; i < n; i++) {
|
|
153
|
+
var header = headers[i];
|
|
154
|
+
if (header) {
|
|
155
|
+
if (Array.isArray(header)) {
|
|
156
|
+
applyHeaders(header, res);
|
|
157
|
+
} else if (header.key === 'Vary' && header.value) {
|
|
158
|
+
vary(res, header.value);
|
|
159
|
+
} else if (header.value) {
|
|
160
|
+
res.setHeader(header.key, header.value);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function cors(options, req, res, next) {
|
|
167
|
+
var headers = [],
|
|
168
|
+
method = req.method && req.method.toUpperCase && req.method.toUpperCase();
|
|
169
|
+
|
|
170
|
+
if (method === 'OPTIONS') {
|
|
171
|
+
// preflight
|
|
172
|
+
headers.push(configureOrigin(options, req));
|
|
173
|
+
headers.push(configureCredentials(options));
|
|
174
|
+
headers.push(configureMethods(options));
|
|
175
|
+
headers.push(configureAllowedHeaders(options, req));
|
|
176
|
+
headers.push(configureMaxAge(options));
|
|
177
|
+
headers.push(configureExposedHeaders(options));
|
|
178
|
+
applyHeaders(headers, res);
|
|
179
|
+
|
|
180
|
+
if (options.preflightContinue) {
|
|
181
|
+
next();
|
|
182
|
+
} else {
|
|
183
|
+
// Safari (and potentially other browsers) need content-length 0,
|
|
184
|
+
// for 204 or they just hang waiting for a body
|
|
185
|
+
res.statusCode = options.optionsSuccessStatus;
|
|
186
|
+
res.setHeader('Content-Length', '0');
|
|
187
|
+
res.end();
|
|
188
|
+
}
|
|
189
|
+
} else {
|
|
190
|
+
// actual response
|
|
191
|
+
headers.push(configureOrigin(options, req));
|
|
192
|
+
headers.push(configureCredentials(options));
|
|
193
|
+
headers.push(configureExposedHeaders(options));
|
|
194
|
+
applyHeaders(headers, res);
|
|
195
|
+
next();
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
function middlewareWrapper(o) {
|
|
200
|
+
// if options are static (either via defaults or custom options passed in), wrap in a function
|
|
201
|
+
var optionsCallback = null;
|
|
202
|
+
if (typeof o === 'function') {
|
|
203
|
+
optionsCallback = o;
|
|
204
|
+
} else {
|
|
205
|
+
optionsCallback = function (req, cb) {
|
|
206
|
+
cb(null, o);
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
return function corsMiddleware(req, res, next) {
|
|
211
|
+
optionsCallback(req, function (err, options) {
|
|
212
|
+
if (err) {
|
|
213
|
+
next(err);
|
|
214
|
+
} else {
|
|
215
|
+
var corsOptions = assign({}, defaults, options);
|
|
216
|
+
var originCallback = null;
|
|
217
|
+
if (corsOptions.origin && typeof corsOptions.origin === 'function') {
|
|
218
|
+
originCallback = corsOptions.origin;
|
|
219
|
+
} else if (corsOptions.origin) {
|
|
220
|
+
originCallback = function (origin, cb) {
|
|
221
|
+
cb(null, corsOptions.origin);
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
if (originCallback) {
|
|
226
|
+
originCallback(req.headers.origin, function (err2, origin) {
|
|
227
|
+
if (err2 || !origin) {
|
|
228
|
+
next(err2);
|
|
229
|
+
} else {
|
|
230
|
+
corsOptions.origin = origin;
|
|
231
|
+
cors(corsOptions, req, res, next);
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
} else {
|
|
235
|
+
next();
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// can pass either an options hash, an options delegate, or nothing
|
|
243
|
+
lib.exports = middlewareWrapper;
|
|
244
|
+
|
|
245
|
+
}());
|
|
246
|
+
return lib.exports;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export { requireLib as __require };
|