@desplega.ai/agent-swarm 2.14.0 → 2.14.2
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/acp-adapter-q1vz4hh2.js +17 -0
- package/dist/{acp-targets-23exz4z4.js → acp-targets-d44eerh4.js} +10 -10
- package/dist/{actions-zcr25x27.js → actions-z4k4bvss.js} +28 -28
- package/dist/{agent-fs-provision-7fa9e12e.js → agent-fs-provision-aan1cgpx.js} +4 -4
- package/dist/{amp-adapter-s7ytmv6b.js → amp-adapter-wac3py0p.js} +3 -3
- package/dist/{anthropic-messages-vdd1zmha.js → anthropic-messages-njt2r5m4.js} +28 -27
- package/dist/{app-5d3sz1hy.js → app-wax6qz5e.js} +10 -10
- package/dist/{approval-notifications-7qgkzkzx.js → approval-notifications-6fvkhnma.js} +11 -11
- package/dist/{assistant-p2yvhc3j.js → assistant-e8fe08zx.js} +29 -29
- package/dist/{azure-openai-responses-jeaas6x0.js → azure-openai-responses-6ewf9rwp.js} +6 -6
- package/dist/{boot-args-schema-ry6cb0p7.js → boot-args-schema-rv97cmnt.js} +1 -1
- package/dist/{boot-reembed-c9643ms3.js → boot-reembed-bcn7frk9.js} +1 -1
- package/dist/{boot-reembed-2hkm3vz2.js → boot-reembed-xakrdy6y.js} +1 -1
- package/dist/{boot-scrub-sweep-3ycxr51t.js → boot-scrub-sweep-20t8akhf.js} +2 -2
- package/dist/{boot-seeds-2hzvvzg0.js → boot-seeds-48rr6r29.js} +4 -4
- package/dist/{boxd-9py3x0jb.js → boxd-tjpxwecx.js} +3 -3
- package/dist/{claude-adapter-dnkww93e.js → claude-adapter-0wzwntrj.js} +12 -13
- package/dist/{claude-managed-adapter-yk0cr5x6.js → claude-managed-adapter-4xcgt46w.js} +4 -4
- package/dist/{claude-managed-setup-4byxpp47.js → claude-managed-setup-91cyktw7.js} +7 -7
- package/dist/{claude-sdk-session-4wf3dbvs.js → claude-sdk-session-ngj4dce5.js} +11144 -12464
- package/dist/{cli-gcyws2bp.js → cli-021hrewp.js} +2 -2
- package/dist/{cli-wvgg7r4j.js → cli-08gfvs58.js} +2 -2
- package/dist/{cli-2zjxake1.js → cli-0kyjrbaa.js} +4 -4
- package/dist/{cli-rp1n2xpd.js → cli-0nvqg1hb.js} +1 -1
- package/dist/{cli-vxmmttmt.js → cli-0nz04gqv.js} +50 -50
- package/dist/{cli-vr4eyq6p.js → cli-0rrft7s3.js} +538 -410
- package/dist/{cli-mw1tmn3x.js → cli-1d9q7qrn.js} +7 -7
- package/dist/{cli-84xn7bgz.js → cli-1t5vhrpv.js} +1 -1
- package/dist/{cli-hzhv7yac.js → cli-1zbj28py.js} +1 -1
- package/dist/{cli-z8t4485r.js → cli-2ja7eadd.js} +2 -2
- package/dist/{cli-r04ve9xw.js → cli-2r62jy9s.js} +1 -1
- package/dist/{cli-9fwznq4p.js → cli-3ffzr65w.js} +7 -7
- package/dist/{cli-2ckwgs7q.js → cli-3kdgm393.js} +5 -5
- package/dist/{cli-jwnac23b.js → cli-3vc518cw.js} +1 -1
- package/dist/{cli-6p8p2e6r.js → cli-5188hq0a.js} +1286 -31
- package/dist/{cli-zcghfsdg.js → cli-53gt8wfv.js} +1 -1
- package/dist/{cli-930zbczq.js → cli-5njmmmer.js} +3 -3
- package/dist/{cli-dw9rtjm3.js → cli-5rw7nt99.js} +3061 -727
- package/dist/{cli-6c61yjwy.js → cli-5xx353cy.js} +7554 -1534
- package/dist/{cli-2ap1the6.js → cli-65k149j5.js} +2 -2
- package/dist/{cli-v41kn3cd.js → cli-6prwz0zn.js} +4427 -5566
- package/dist/{cli-yd7e590v.js → cli-6zpn5hmp.js} +12 -12
- package/dist/{cli-ty3gha1p.js → cli-7b9bwrfg.js} +2 -2
- package/dist/{cli-2414h5r9.js → cli-7dpdq7yh.js} +11428 -1914
- package/dist/{cli-r9d2tya0.js → cli-7qkbab03.js} +5 -5
- package/dist/{cli-7ca8hczj.js → cli-7svwhw1a.js} +1 -1
- package/dist/cli-7wwewkf4.js +37 -0
- package/dist/{cli-ejnhs815.js → cli-83hynhes.js} +17 -13
- package/dist/{cli-rs1rzwp4.js → cli-8crn0510.js} +1 -1
- package/dist/{cli-f2rwt43y.js → cli-8ee7xt75.js} +13 -13
- package/dist/{cli-9j47sgzy.js → cli-8ef94zm2.js} +2 -2
- package/dist/{cli-9fvk9mv8.js → cli-8gr1bg9t.js} +1 -1
- package/dist/{cli-b0m3bg0f.js → cli-9j1qcs0b.js} +1 -1
- package/dist/{cli-ad00h1st.js → cli-9mvfvggt.js} +7 -7
- package/dist/{cli-xh5fpmg8.js → cli-9txap41q.js} +101 -18
- package/dist/{cli-24wervhz.js → cli-aktk3qt6.js} +3 -3
- package/dist/{cli-6ajyhxh7.js → cli-an8bpy60.js} +2 -2
- package/dist/{cli-meydjstb.js → cli-azptj8xe.js} +5591 -69
- package/dist/cli-c0rt16vk.js +15 -0
- package/dist/{cli-w4bvtxet.js → cli-c6vhcknq.js} +7 -7
- package/dist/{cli-2savn6mm.js → cli-cczffwak.js} +7 -7
- package/dist/{cli-ze1ndjs4.js → cli-cgmka83w.js} +3 -3
- package/dist/{cli-kc7vd07m.js → cli-d13qgcct.js} +3699 -1733
- package/dist/{cli-k3facve0.js → cli-d5nvy1jy.js} +1 -1
- package/dist/{cli-edxfzgah.js → cli-dev6f0px.js} +4 -4
- package/dist/{cli-0e914dp9.js → cli-dzhht0vq.js} +3 -3
- package/dist/{cli-m0ea8ggd.js → cli-e13kbyq0.js} +2 -2
- package/dist/{cli-73rmgm45.js → cli-e2k0ej0d.js} +2 -2
- package/dist/cli-ek8b88kv.js +9740 -0
- package/dist/{cli-0k7ppk9k.js → cli-ertcjw6z.js} +281 -46
- package/dist/{cli-qrwjk4xy.js → cli-f3ta4e67.js} +5 -5
- package/dist/{cli-1nfabrt4.js → cli-f4xv7s0t.js} +7 -7
- package/dist/{cli-phe2vcw5.js → cli-fdam1t9b.js} +171 -104
- package/dist/{cli-gc6b94tj.js → cli-fe8he9cy.js} +2 -2
- package/dist/{cli-spfz393q.js → cli-feh37wgs.js} +598 -219
- package/dist/{cli-ebqx630g.js → cli-fjzjtqna.js} +35 -18
- package/dist/{cli-37p61fcg.js → cli-fs9t2m2k.js} +18 -20
- package/dist/{cli-7w1fs01q.js → cli-g03x26q6.js} +2 -2
- package/dist/{cli-879txsac.js → cli-gnkzh8ed.js} +4 -4
- package/dist/{cli-v4z5v3jd.js → cli-gy0r7gb8.js} +514 -337
- package/dist/{cli-s4pccby1.js → cli-h0edykd1.js} +1 -1
- package/dist/{cli-pq0kv31y.js → cli-h364asjc.js} +9 -9
- package/dist/{cli-69szn7w7.js → cli-h3xcfp4c.js} +93 -54
- package/dist/{cli-jcnc5ret.js → cli-h8k5801a.js} +73 -27
- package/dist/{cli-6yy4fepf.js → cli-h96yp7xv.js} +4 -4
- package/dist/{cli-q5n3deaf.js → cli-hab0bvrh.js} +1 -1
- package/dist/{cli-g6a696c0.js → cli-j3wqt73b.js} +4 -4
- package/dist/{cli-wym6rxgt.js → cli-jfgaz10x.js} +10 -15
- package/dist/{cli-shyhb4t5.js → cli-jrhvywah.js} +53 -52
- package/dist/{cli-qkbevqer.js → cli-jrxt5j0n.js} +3 -3
- package/dist/{cli-7b7rxz22.js → cli-jw7n9pct.js} +5 -2
- package/dist/{cli-8vbxjzk0.js → cli-k9kfck3s.js} +3 -3
- package/dist/{cli-yjb3cddd.js → cli-kkwq5b12.js} +1 -1
- package/dist/{cli-39t9d248.js → cli-kz8rar0g.js} +1 -1
- package/dist/{cli-rzbsh6bw.js → cli-n15fhd43.js} +1 -1
- package/dist/{cli-1jx0srjt.js → cli-nc842kc9.js} +1921 -80
- package/dist/{cli-9j1t3kf6.js → cli-nmj4phcg.js} +2 -2
- package/dist/{cli-t9pzz2eq.js → cli-ntmjzyte.js} +4 -1
- package/dist/{cli-adzmmcvf.js → cli-praaw1wh.js} +2 -2
- package/dist/{cli-f9g96z28.js → cli-q44p4869.js} +11 -11
- package/dist/{cli-fww016hh.js → cli-q58qt9dw.js} +1711 -7287
- package/dist/{cli-njvpngc6.js → cli-qqz5z36e.js} +3 -3
- package/dist/{cli-096aftq6.js → cli-r7rpy2xz.js} +7 -7
- package/dist/cli-rcqgr0hs.js +30 -0
- package/dist/{cli-ph95yejc.js → cli-rjc464jg.js} +2 -2
- package/dist/{cli-md4tn21h.js → cli-rw3m83j4.js} +40 -26
- package/dist/cli-rwcj6wt3.js +1291 -0
- package/dist/{cli-srq69pn1.js → cli-ryn4y478.js} +1 -1
- package/dist/{cli-jgq9xptq.js → cli-s48k2rzx.js} +4 -4
- package/dist/{cli-cbg0j1yt.js → cli-s90wcbk9.js} +3 -3
- package/dist/{cli-2ayk9gn8.js → cli-svcy72s5.js} +2 -2
- package/dist/{cli-4dyzzkfb.js → cli-swtwbg85.js} +944 -170
- package/dist/{cli-mv8ft7b0.js → cli-t1bqpzgz.js} +3 -3
- package/dist/{cli-tc165vrb.js → cli-t5jbjq61.js} +4 -3
- package/dist/{cli-enavhq6r.js → cli-tbrjvrrg.js} +1 -1
- package/dist/{cli-mz7ycqn8.js → cli-td2h8zej.js} +6 -6
- package/dist/{cli-9t7syepg.js → cli-ttatvwn6.js} +1 -1
- package/dist/{cli-ayxxkk3p.js → cli-txxcf9s1.js} +8 -8
- package/dist/{cli-q4z9s6zs.js → cli-v7az4d1g.js} +2 -2
- package/dist/cli-vqt44168.js +14 -0
- package/dist/{cli-q457ga28.js → cli-vs9h3vw2.js} +14 -14
- package/dist/{cli-snxhtehz.js → cli-w2fg8kjc.js} +7 -8
- package/dist/{cli-wd7b5hgc.js → cli-w81s97bn.js} +1 -1
- package/dist/{cli-bqfx72e6.js → cli-wkzrknpt.js} +1 -1
- package/dist/{cli-cg1q8ymp.js → cli-wqpvfq2m.js} +1 -1
- package/dist/{cli-kg63yp1r.js → cli-wz7qj1jy.js} +19 -19
- package/dist/{cli-3wsabyt0.js → cli-x5t54ytt.js} +2 -2
- package/dist/{cli-r495stwd.js → cli-xd6ntv7x.js} +2 -2
- package/dist/{cli-wvbaq052.js → cli-xphbv66z.js} +10 -3
- package/dist/{cli-a49frv85.js → cli-xxgqn93n.js} +3753 -1186
- package/dist/{cli-91amj3md.js → cli-z209g721.js} +111 -87
- package/dist/{cli-3mhdmcd4.js → cli-z5andw8k.js} +1 -1
- package/dist/{cli-7g5qj2ca.js → cli-zcb64xzv.js} +1 -1
- package/dist/{cli-0h6m6z5g.js → cli-zr2sc5tr.js} +1 -1
- package/dist/{cli-krk8y8c7.js → cli-zrm0610v.js} +1833 -518
- package/dist/cli.js +73 -73
- package/dist/{cloudflare-workers-ai-system-one-w3m0fbf8.js → cloudflare-workers-ai-system-one-kb0tq22h.js} +2 -2
- package/dist/{codex-adapter-eq61radw.js → codex-adapter-0c1ynrmt.js} +9 -9
- package/dist/{codex-hook-8nmepvz6.js → codex-hook-w5nmtrn2.js} +2 -2
- package/dist/{codex-login-vbd9707w.js → codex-login-67qarfcg.js} +1 -1
- package/dist/{codex-session-runner-rfx355h4.js → codex-session-runner-z4t9z7yy.js} +10 -10
- package/dist/{commands-d1z0sx62.js → commands-h0jxqdhk.js} +3 -3
- package/dist/{controller-9hz6d8x3.js → controller-4ygy66hv.js} +4 -4
- package/dist/{controllers-connect-tz07d2xr.js → controllers-connect-ynbvv8pv.js} +28 -28
- package/dist/core-mj9fzrcm.js +41 -0
- package/dist/{cursor-adapter-ef22ze3j.js → cursor-adapter-9e4d6658.js} +2 -2
- package/dist/{db-gd81d68c.js → db-bg0hxjq1.js} +3 -3
- package/dist/{db-vrckks6q.js → db-q12gmpns.js} +2 -2
- package/dist/{devin-adapter-kdt6a2bh.js → devin-adapter-tn1twrha.js} +1 -1
- package/dist/{devtools-qxfgbsqz.js → devtools-t8my9az6.js} +1 -1
- package/dist/{dispatcher-76as8w2t.js → dispatcher-v5dbfscq.js} +24 -24
- package/dist/{docker-51ta7jsh.js → docker-6007r2fj.js} +2 -2
- package/dist/{dsh-adapter-ypfvcdyz.js → dsh-adapter-z3fneea1.js} +2 -2
- package/dist/{e2b-05kn3kpq.js → e2b-k3kb8b52.js} +4 -4
- package/dist/{e2b-dm9r8hpy.js → e2b-p269awh6.js} +5 -5
- package/dist/{easter-egg-3d-sg21j15g.js → easter-egg-3d-y49v5z90.js} +1 -1
- package/dist/{embedding-space-zsdw37bb.js → embedding-space-mjt5ksq0.js} +5 -5
- package/dist/{embeddings-p4e3e1m6.js → embeddings-td9hgnc5.js} +1 -1
- package/dist/emscripten-module-Q67P5WYC-3sde6cre.js +2458 -0
- package/dist/{event-bus-tvf2grf4.js → event-bus-pawddp92.js} +1 -1
- package/dist/{execute-nztd0af0.js → execute-z8nc8bba.js} +1 -1
- package/dist/{external-channel-717yzn4d.js → external-channel-pjenc2ag.js} +2 -2
- package/dist/ffi-cbfmmtqk.js +85 -0
- package/dist/fx-adapter-pjeztp0n.js +20 -0
- package/dist/getMachineId-bsd-hjs2tbdp.js +36 -0
- package/dist/getMachineId-darwin-kzbvr8s3.js +40 -0
- package/dist/getMachineId-linux-embmcq2c.js +26 -0
- package/dist/getMachineId-unsupported-jvznc6d4.js +20 -0
- package/dist/getMachineId-win-qr8z0b13.js +36 -0
- package/dist/{google-generative-ai-sw77egmr.js → google-generative-ai-tf3w7557.js} +11 -16
- package/dist/{google-vertex-rrw93g8h.js → google-vertex-9pj87bd8.js} +15 -17
- package/dist/grok-adapter-davbhx8t.js +20 -0
- package/dist/handlers-rf130hnp.js +39 -0
- package/dist/heartbeat-9hmvqxk0.js +49 -0
- package/dist/hook-0b1jqs2t.js +21 -0
- package/dist/{hook-ctz0xmp3.js → hook-1n0sjv8p.js} +10 -11
- package/dist/{http-zregegrx.js → http-vykejyjx.js} +432 -170
- package/dist/{index-7dgxveck.js → index-07d66kdm.js} +3 -3
- package/dist/index-0hgjxqz8.js +10584 -0
- package/dist/{index-rz8ve510.js → index-0nt39qwy.js} +2 -2
- package/dist/{index-ym9fgxad.js → index-2xbxq71g.js} +2 -2
- package/dist/{index-42jq9yy3.js → index-3j8hffkb.js} +12327 -7450
- package/dist/index-8w09aggw.js +43 -0
- package/dist/{index-5kx15d19.js → index-b3wy4jzs.js} +1 -1
- package/dist/{index-kzdqn3dd.js → index-dt9vr7tb.js} +3143 -760
- package/dist/{index-maddg9ys.js → index-ezfas4jj.js} +5858 -15337
- package/dist/index-g2jntx15.js +38 -0
- package/dist/{index-x9qf8dg7.js → index-j6sqtb83.js} +105 -75
- package/dist/{index-m6g8q65g.js → index-na0tczq0.js} +9268 -10220
- package/dist/{index-whysn1wf.js → index-p9dkwhwe.js} +1 -1
- package/dist/{index-126v2d0t.js → index-pe2etczf.js} +6 -2918
- package/dist/{index-mtnbhe12.js → index-q60mhcpd.js} +23631 -19921
- package/dist/index-qffex5k4.js +41 -0
- package/dist/index-qrp11tp9.js +4 -0
- package/dist/{index-kdmkfjt7.js → index-ryyrg0d8.js} +3426 -2333
- package/dist/{index-t17p395x.js → index-sf06w57a.js} +13 -13
- package/dist/{index-evay0xyk.js → index-vybnwd5v.js} +1 -1
- package/dist/{index-fdym6ryb.js → index-wsf1f5pe.js} +28 -28
- package/dist/{k8s-ejkk0aw7.js → k8s-mr1r12th.js} +2 -2
- package/dist/{keepalive-zdqay870.js → keepalive-86z0tzzf.js} +4 -4
- package/dist/lead-edmwagkn.js +81 -0
- package/dist/{llama-cpp-classify-yvb8vh7w.js → llama-cpp-classify-wd7htn1x.js} +2 -2
- package/dist/{maintenance-t5ndg11m.js → maintenance-19h6tfwz.js} +1 -1
- package/dist/{mistral-conversations-w4bncwbt.js → mistral-conversations-txjmc64f.js} +7 -7
- package/dist/module-ES6BEMUI-44w9s1dx.js +1210 -0
- package/dist/{multipart-parser-xevcstye.js → multipart-parser-xqbgwrav.js} +1 -1
- package/dist/{node-0as4n1ef.js → node-q4628t0b.js} +1 -1
- package/dist/{oauth-refresh-sweep-y9zyd7t6.js → oauth-refresh-sweep-6nmyrv32.js} +3 -3
- package/dist/{object-webhooks-mkca91s0.js → object-webhooks-2kynmdf8.js} +7 -7
- package/dist/{onboard-ss995244.js → onboard-zbpm96mn.js} +7 -7
- package/dist/{openai-codex-responses-70g39cgz.js → openai-codex-responses-6ckhys6r.js} +35 -29
- package/dist/{openai-completions-cv3hp4h5.js → openai-completions-c9dsq9jh.js} +15 -15
- package/dist/{openai-decisions-fyq1p9f9.js → openai-decisions-9vzvv10c.js} +2 -2
- package/dist/{openai-responses-trsvnks6.js → openai-responses-bhfmt9sa.js} +6 -6
- package/dist/{opencode-adapter-mwpz0278.js → opencode-adapter-fyqcbdra.js} +8 -8
- package/dist/{openrouter-images-0jj12a2q.js → openrouter-images-hkk5p580.js} +3 -3
- package/dist/otel-impl-txa20w1h.js +11178 -0
- package/dist/{pending-2sxh1t6j.js → pending-4rxawq8y.js} +25 -25
- package/dist/{pi-messages-zk3g4esn.js → pi-messages-py3f96p7.js} +5 -5
- package/dist/{pi-mono-adapter-sfb7zy43.js → pi-mono-adapter-rnsed1xa.js} +24 -27
- package/dist/{pricing-refresh-h79bg4cf.js → pricing-refresh-4314hwtw.js} +2 -2
- package/dist/{rbac-roles-ckq0czp4.js → rbac-roles-fztcm8ky.js} +2 -2
- package/dist/{rbac-roles-jg2e260w.js → rbac-roles-msqt7a3k.js} +3 -3
- package/dist/{render-v2-ymbshmn0.js → render-v2-w49wtecg.js} +10 -10
- package/dist/{resume-jdhnt4jk.js → resume-gwgtp4m3.js} +13 -13
- package/dist/{runtime-y28jhhnf.js → runtime-kkebz8yq.js} +1 -1
- package/dist/{session-access-k4ta5hvp.js → session-access-kjb19m2w.js} +5 -5
- package/dist/{session-source-backfill-528j4s8j.js → session-source-backfill-805p4wqr.js} +3 -3
- package/dist/{setup-d6pj82fr.js → setup-q8y168c8.js} +3 -3
- package/dist/thread-buffer-yqbffd0t.js +40 -0
- package/dist/{token-util-pjgekqxr.js → token-util-hnzceyn9.js} +1 -1
- package/dist/{token-pgr2w4s3.js → token-xnc02n6w.js} +21 -14
- package/dist/{tree-visibility-kjxv3nxk.js → tree-visibility-qj323994.js} +2 -2
- package/dist/{typesafe-system-one-qkvkgrcz.js → typesafe-system-one-avrdb4zm.js} +2 -2
- package/dist/{user-merge-jobs-rabbncf6.js → user-merge-jobs-qfp40f2s.js} +3 -3
- package/dist/{virtual-modules-22k51txd.js → virtual-modules-nzxegw0a.js} +7 -7
- package/dist/{work-objects-xtjbar3r.js → work-objects-hs089w60.js} +26 -26
- package/dist/{worker-follow-up-fg48vk6d.js → worker-follow-up-zwgg20sr.js} +24 -24
- package/dist/worker-kg4g7rnx.js +81 -0
- package/dist/{x-vfsqypht.js → x-k29vmskt.js} +2 -2
- package/openapi.json +59 -3
- package/package.json +53 -52
- package/plugin/commands/create-pr.md +5 -2
- package/plugin/pi-skills/create-pr/SKILL.md +5 -2
- package/src/apps/sync.ts +7 -2
- package/src/be/db/model-profiles.ts +103 -12
- package/src/be/db/tasks/read.ts +5 -0
- package/src/be/db/workflow-runs.ts +12 -8
- package/src/be/db.ts +18 -5
- package/src/be/migrations/367_workflow_run_principal.sql +5 -0
- package/src/be/model-group-resolution.ts +134 -0
- package/src/be/model-tier-resolution.ts +120 -17
- package/src/be/model-validation.ts +9 -1
- package/src/be/runtime-pools/routing.ts +22 -8
- package/src/be/scripts/extract-schema.ts +7 -0
- package/src/be/swarm-config-guard.ts +20 -7
- package/src/be/task-auto-title-listener.ts +2 -2
- package/src/commands/onboard/agent-fs-version.ts +1 -1
- package/src/extensions/contract-types.generated.ts +1 -1
- package/src/extensions/post-bridge.ts +27 -28
- package/src/http/active-sessions.ts +7 -0
- package/src/http/agents.ts +7 -0
- package/src/http/api-keys.ts +7 -0
- package/src/http/approval-requests.ts +4 -0
- package/src/http/budgets.ts +2 -0
- package/src/http/codex-oauth-keep-warm.ts +6 -2
- package/src/http/config.ts +1 -0
- package/src/http/context.ts +4 -0
- package/src/http/db-query.ts +11 -2
- package/src/http/events.ts +2 -0
- package/src/http/fs.ts +1 -0
- package/src/http/integrations.ts +4 -0
- package/src/http/mcp-bridge.ts +1 -0
- package/src/http/memory.ts +3 -0
- package/src/http/metrics.ts +16 -0
- package/src/http/oauth-locks.ts +8 -0
- package/src/http/operator-actor.ts +3 -8
- package/src/http/page-proxy.ts +16 -0
- package/src/http/pages.ts +9 -0
- package/src/http/poll.ts +21 -1
- package/src/http/pricing.ts +2 -0
- package/src/http/prompt-templates.ts +34 -0
- package/src/http/repos.ts +3 -1
- package/src/http/schedules.ts +33 -3
- package/src/http/script-runs.ts +24 -0
- package/src/http/scripts.ts +1 -0
- package/src/http/session-data.ts +2 -0
- package/src/http/status.ts +1 -0
- package/src/http/tasks.ts +28 -1
- package/src/http/trackers/jira.ts +2 -0
- package/src/http/trackers/linear.ts +4 -0
- package/src/http/users.ts +18 -0
- package/src/http/webhooks.ts +12 -0
- package/src/http/workflow-events.ts +26 -6
- package/src/http/workflows.ts +40 -0
- package/src/http/x.ts +4 -0
- package/src/linear/app.ts +3 -2
- package/src/linear/client.ts +5 -1
- package/src/linear/host.ts +40 -0
- package/src/linear/oauth.ts +3 -2
- package/src/linear/sync.ts +4 -3
- package/src/otel-impl.ts +8 -5
- package/src/prompts/base-prompt.ts +10 -6
- package/src/prompts/session-templates.ts +3 -3
- package/src/providers/acp-targets.ts +1 -1
- package/src/providers/amp-adapter.ts +11 -9
- package/src/providers/cursor-adapter.ts +1 -1
- package/src/rbac/legacy-policy.ts +2 -0
- package/src/rbac/permissions.ts +5 -0
- package/src/realtime/browser.generated.txt +1 -1
- package/src/scheduler/schedule-task.ts +1 -0
- package/src/scripts-runtime/quickjs-compat.ts +44 -10
- package/src/scripts-runtime/types/swarm-extension.d.ts +2 -0
- package/src/slack/config.ts +4 -0
- package/src/slack/render-v2.ts +52 -24
- package/src/slack/responses.ts +2 -1
- package/src/slack/reviewed-deliverables.ts +251 -0
- package/src/tasks/follow-up-gate.ts +142 -38
- package/src/tasks/worker-follow-up.ts +126 -37
- package/src/tests/amp-adapter.test.ts +57 -9
- package/src/tests/base-prompt.test.ts +36 -2
- package/src/tests/check-pr-body.test.ts +408 -93
- package/src/tests/compose-dev-object-store.test.ts +13 -0
- package/src/tests/compose-example-object-store.test.ts +67 -0
- package/src/tests/db-query.test.ts +8 -4
- package/src/tests/db-retention-defaults.test.ts +28 -3
- package/src/tests/e2b-dispatch.test.ts +7 -1
- package/src/tests/entrypoint-repo-autoclone-args.test.ts +10 -0
- package/src/tests/follow-up-gate-shadow.test.ts +268 -10
- package/src/tests/linear-outbound-sync.test.ts +59 -25
- package/src/tests/operator-actor-keyless.test.ts +103 -0
- package/src/tests/otel-event-loop-and-logs.test.ts +1 -1
- package/src/tests/profile-tier-alias.test.ts +9 -3
- package/src/tests/quickjs-compat.test.ts +40 -4
- package/src/tests/rbac-route-verbs-e2e.test.ts +142 -0
- package/src/tests/runner-repo-clone-args.test.ts +15 -6
- package/src/tests/script-connections.test.ts +2 -0
- package/src/tests/slack-render-v2.test.ts +52 -8
- package/src/tests/workflow-definition-pinning.test.ts +2 -0
- package/src/tests/workflow-hitl-routing.test.ts +67 -5
- package/src/tests/workflow-replay.test.ts +13 -1
- package/src/tests/workflow-system-one-extraction.test.ts +21 -0
- package/src/tests/workflow-wait-filter.test.ts +7 -7
- package/src/tests/worktree-reaper.test.ts +15 -4
- package/src/tests/x402-client.test.ts +82 -0
- package/src/tools/memory-rate.ts +2 -2
- package/src/tools/prompt-templates/delete.ts +22 -1
- package/src/tools/prompt-templates/set.ts +15 -1
- package/src/tools/schedules/create-schedule.ts +20 -3
- package/src/tools/schedules/patch-schedule.ts +30 -4
- package/src/tools/schedules/update-schedule.ts +30 -4
- package/src/tools/send-task.ts +17 -3
- package/src/tools/slack-post.ts +7 -2
- package/src/tools/slack-reply.ts +6 -2
- package/src/tools/task-action.ts +16 -3
- package/src/tools/utils.ts +1 -1
- package/src/types.ts +10 -0
- package/src/utils/amp-models.ts +20 -4
- package/src/utils/constants.ts +5 -4
- package/src/utils/secret-scrubber.ts +6 -4
- package/src/utils/task-citations.ts +11 -0
- package/src/workflows/engine.ts +41 -8
- package/src/workflows/executors/agent-task.ts +13 -2
- package/src/workflows/executors/code-match.ts +11 -31
- package/src/workflows/executors/script.ts +13 -0
- package/src/workflows/executors/sub-workflow.ts +5 -7
- package/src/workflows/executors/swarm-script.ts +4 -5
- package/src/workflows/executors/system-one-extraction.ts +9 -6
- package/src/workflows/executors/wait.ts +1 -1
- package/src/workflows/foreach-driver.ts +5 -1
- package/src/workflows/model-validation.ts +13 -1
- package/src/workflows/predicate-sandbox.ts +171 -0
- package/src/workflows/resume.ts +21 -4
- package/src/workflows/retry-poller.ts +1 -1
- package/src/workflows/run-principal.ts +51 -0
- package/src/workflows/wait-filter.ts +14 -192
- package/src/x402/client.ts +38 -17
- package/templates/skills/code-quality/content.md +1 -1
- package/templates/skills/heartbeat-runbook/content.md +1 -0
- package/templates/skills/pages/content.md +36 -12
- package/templates/skills/slack-interaction/content.md +4 -0
- package/templates/skills/swarm-docs/content.md +47 -41
- package/templates/skills/swarm-scripts/SKILL.md +1 -1
- package/templates/skills/swarm-scripts/content.md +1 -1
- package/dist/acp-adapter-99n6z9ky.js +0 -17
- package/dist/cli-5ss6qqt9.js +0 -45
- package/dist/cli-dzzh58sy.js +0 -6996
- package/dist/cli-e8trbfx1.js +0 -15
- package/dist/cli-j9ccfveb.js +0 -1849
- package/dist/cli-mna6pmfx.js +0 -1485
- package/dist/cli-r8ddn0hf.js +0 -25583
- package/dist/core-dynsv289.js +0 -41
- package/dist/fx-adapter-9k0hptnz.js +0 -20
- package/dist/getMachineId-bsd-637a7rbk.js +0 -36
- package/dist/getMachineId-darwin-9vytrcnn.js +0 -36
- package/dist/getMachineId-linux-mkzsvyyz.js +0 -29
- package/dist/getMachineId-unsupported-4cfs2n11.js +0 -19
- package/dist/getMachineId-win-154s3qma.js +0 -38
- package/dist/grok-adapter-skdj2pce.js +0 -20
- package/dist/handlers-5btjqkz6.js +0 -39
- package/dist/heartbeat-vfb1gy84.js +0 -49
- package/dist/hook-eh52p7yd.js +0 -22
- package/dist/index-7w8p6em0.js +0 -41
- package/dist/index-t56y945n.js +0 -4
- package/dist/index-vfemrwwk.js +0 -10002
- package/dist/index-vz4semsx.js +0 -38
- package/dist/index-y3s0xp2v.js +0 -43
- package/dist/lead-6cscw8a5.js +0 -82
- package/dist/otel-impl-6n6vva3x.js +0 -28205
- package/dist/thread-buffer-9w6x5zec.js +0 -40
- package/dist/worker-g4aj93dt.js +0 -82
|
@@ -21,10 +21,13 @@ import {
|
|
|
21
21
|
convertEmojiPlaceholders2,
|
|
22
22
|
cardChildToFallbackText2,
|
|
23
23
|
init_dist8
|
|
24
|
-
} from "./cli-
|
|
24
|
+
} from "./cli-0rrft7s3.js";
|
|
25
25
|
import {
|
|
26
26
|
require_fast_deep_equal
|
|
27
27
|
} from "./cli-bhp11egn.js";
|
|
28
|
+
import {
|
|
29
|
+
require_ws
|
|
30
|
+
} from "./cli-7wwewkf4.js";
|
|
28
31
|
import {
|
|
29
32
|
replaceBareMentions,
|
|
30
33
|
extractCard,
|
|
@@ -35,7 +38,7 @@ import {
|
|
|
35
38
|
renderGfmTable,
|
|
36
39
|
downloadAttachment,
|
|
37
40
|
init_dist7
|
|
38
|
-
} from "./cli-
|
|
41
|
+
} from "./cli-9j1qcs0b.js";
|
|
39
42
|
import {
|
|
40
43
|
__toESM,
|
|
41
44
|
__commonJS,
|
|
@@ -169,7 +172,7 @@ var require_dist = __commonJS(function(exports2, module2) {
|
|
|
169
172
|
var version = "1.2.0";
|
|
170
173
|
});
|
|
171
174
|
|
|
172
|
-
// node_modules/
|
|
175
|
+
// node_modules/tslib/tslib.js
|
|
173
176
|
var require_tslib = __commonJS(function(exports2, module2) {
|
|
174
177
|
var __extends;
|
|
175
178
|
var __assign;
|
|
@@ -65992,2921 +65995,6 @@ var require_dist9 = __commonJS(function(exports2, module2) {
|
|
|
65992
65995
|
var version = "2.1.1";
|
|
65993
65996
|
});
|
|
65994
65997
|
|
|
65995
|
-
// node_modules/@discordjs/ws/node_modules/ws/lib/constants.js
|
|
65996
|
-
var require_constants11 = __commonJS(function(exports2, module2) {
|
|
65997
|
-
var BINARY_TYPES = ["nodebuffer", "arraybuffer", "fragments"];
|
|
65998
|
-
var hasBlob = typeof Blob !== "undefined";
|
|
65999
|
-
if (hasBlob)
|
|
66000
|
-
BINARY_TYPES.push("blob");
|
|
66001
|
-
module2.exports = {
|
|
66002
|
-
BINARY_TYPES,
|
|
66003
|
-
CLOSE_TIMEOUT: 30000,
|
|
66004
|
-
EMPTY_BUFFER: Buffer.alloc(0),
|
|
66005
|
-
GUID: "258EAFA5-E914-47DA-95CA-C5AB0DC85B11",
|
|
66006
|
-
hasBlob,
|
|
66007
|
-
kForOnEventAttribute: Symbol("kIsForOnEventAttribute"),
|
|
66008
|
-
kListener: Symbol("kListener"),
|
|
66009
|
-
kStatusCode: Symbol("status-code"),
|
|
66010
|
-
kWebSocket: Symbol("websocket"),
|
|
66011
|
-
NOOP: () => {}
|
|
66012
|
-
};
|
|
66013
|
-
});
|
|
66014
|
-
|
|
66015
|
-
// node_modules/@discordjs/ws/node_modules/ws/lib/buffer-util.js
|
|
66016
|
-
var require_buffer_util = __commonJS(function(exports2, module2) {
|
|
66017
|
-
var { EMPTY_BUFFER } = require_constants11();
|
|
66018
|
-
var FastBuffer = Buffer[Symbol.species];
|
|
66019
|
-
function concat(list, totalLength) {
|
|
66020
|
-
if (list.length === 0)
|
|
66021
|
-
return EMPTY_BUFFER;
|
|
66022
|
-
if (list.length === 1)
|
|
66023
|
-
return list[0];
|
|
66024
|
-
const target = Buffer.allocUnsafe(totalLength);
|
|
66025
|
-
let offset = 0;
|
|
66026
|
-
for (let i = 0;i < list.length; i++) {
|
|
66027
|
-
const buf = list[i];
|
|
66028
|
-
target.set(buf, offset);
|
|
66029
|
-
offset += buf.length;
|
|
66030
|
-
}
|
|
66031
|
-
if (offset < totalLength) {
|
|
66032
|
-
return new FastBuffer(target.buffer, target.byteOffset, offset);
|
|
66033
|
-
}
|
|
66034
|
-
return target;
|
|
66035
|
-
}
|
|
66036
|
-
function _mask(source, mask, output, offset, length) {
|
|
66037
|
-
for (let i = 0;i < length; i++) {
|
|
66038
|
-
output[offset + i] = source[i] ^ mask[i & 3];
|
|
66039
|
-
}
|
|
66040
|
-
}
|
|
66041
|
-
function _unmask(buffer, mask) {
|
|
66042
|
-
for (let i = 0;i < buffer.length; i++) {
|
|
66043
|
-
buffer[i] ^= mask[i & 3];
|
|
66044
|
-
}
|
|
66045
|
-
}
|
|
66046
|
-
function toArrayBuffer(buf) {
|
|
66047
|
-
if (buf.length === buf.buffer.byteLength) {
|
|
66048
|
-
return buf.buffer;
|
|
66049
|
-
}
|
|
66050
|
-
return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.length);
|
|
66051
|
-
}
|
|
66052
|
-
function toBuffer(data) {
|
|
66053
|
-
toBuffer.readOnly = true;
|
|
66054
|
-
if (Buffer.isBuffer(data))
|
|
66055
|
-
return data;
|
|
66056
|
-
let buf;
|
|
66057
|
-
if (data instanceof ArrayBuffer) {
|
|
66058
|
-
buf = new FastBuffer(data);
|
|
66059
|
-
} else if (ArrayBuffer.isView(data)) {
|
|
66060
|
-
buf = new FastBuffer(data.buffer, data.byteOffset, data.byteLength);
|
|
66061
|
-
} else {
|
|
66062
|
-
buf = Buffer.from(data);
|
|
66063
|
-
toBuffer.readOnly = false;
|
|
66064
|
-
}
|
|
66065
|
-
return buf;
|
|
66066
|
-
}
|
|
66067
|
-
module2.exports = {
|
|
66068
|
-
concat,
|
|
66069
|
-
mask: _mask,
|
|
66070
|
-
toArrayBuffer,
|
|
66071
|
-
toBuffer,
|
|
66072
|
-
unmask: _unmask
|
|
66073
|
-
};
|
|
66074
|
-
if (!process.env.WS_NO_BUFFER_UTIL) {
|
|
66075
|
-
try {
|
|
66076
|
-
const bufferUtil = (()=>{throw new Error("Cannot require module "+"bufferutil");})();
|
|
66077
|
-
module2.exports.mask = function(source, mask2, output, offset, length) {
|
|
66078
|
-
if (length < 48)
|
|
66079
|
-
_mask(source, mask2, output, offset, length);
|
|
66080
|
-
else
|
|
66081
|
-
bufferUtil.mask(source, mask2, output, offset, length);
|
|
66082
|
-
};
|
|
66083
|
-
module2.exports.unmask = function(buffer, mask) {
|
|
66084
|
-
if (buffer.length < 32)
|
|
66085
|
-
_unmask(buffer, mask);
|
|
66086
|
-
else
|
|
66087
|
-
bufferUtil.unmask(buffer, mask);
|
|
66088
|
-
};
|
|
66089
|
-
} catch (e) {}
|
|
66090
|
-
}
|
|
66091
|
-
});
|
|
66092
|
-
|
|
66093
|
-
// node_modules/@discordjs/ws/node_modules/ws/lib/limiter.js
|
|
66094
|
-
var require_limiter = __commonJS(function(exports2, module2) {
|
|
66095
|
-
var kDone = Symbol("kDone");
|
|
66096
|
-
var kRun = Symbol("kRun");
|
|
66097
|
-
|
|
66098
|
-
class Limiter {
|
|
66099
|
-
constructor(concurrency) {
|
|
66100
|
-
this[kDone] = () => {
|
|
66101
|
-
this.pending--;
|
|
66102
|
-
this[kRun]();
|
|
66103
|
-
};
|
|
66104
|
-
this.concurrency = concurrency || Infinity;
|
|
66105
|
-
this.jobs = [];
|
|
66106
|
-
this.pending = 0;
|
|
66107
|
-
}
|
|
66108
|
-
add(job) {
|
|
66109
|
-
this.jobs.push(job);
|
|
66110
|
-
this[kRun]();
|
|
66111
|
-
}
|
|
66112
|
-
[kRun]() {
|
|
66113
|
-
if (this.pending === this.concurrency)
|
|
66114
|
-
return;
|
|
66115
|
-
if (this.jobs.length) {
|
|
66116
|
-
const job = this.jobs.shift();
|
|
66117
|
-
this.pending++;
|
|
66118
|
-
job(this[kDone]);
|
|
66119
|
-
}
|
|
66120
|
-
}
|
|
66121
|
-
}
|
|
66122
|
-
module2.exports = Limiter;
|
|
66123
|
-
});
|
|
66124
|
-
|
|
66125
|
-
// node_modules/@discordjs/ws/node_modules/ws/lib/permessage-deflate.js
|
|
66126
|
-
var require_permessage_deflate3 = __commonJS(function(exports2, module2) {
|
|
66127
|
-
var zlib = __require("zlib");
|
|
66128
|
-
var bufferUtil = require_buffer_util();
|
|
66129
|
-
var Limiter = require_limiter();
|
|
66130
|
-
var { kStatusCode } = require_constants11();
|
|
66131
|
-
var FastBuffer = Buffer[Symbol.species];
|
|
66132
|
-
var TRAILER = Buffer.from([0, 0, 255, 255]);
|
|
66133
|
-
var kPerMessageDeflate = Symbol("permessage-deflate");
|
|
66134
|
-
var kTotalLength = Symbol("total-length");
|
|
66135
|
-
var kCallback = Symbol("callback");
|
|
66136
|
-
var kBuffers = Symbol("buffers");
|
|
66137
|
-
var kError = Symbol("error");
|
|
66138
|
-
var zlibLimiter;
|
|
66139
|
-
|
|
66140
|
-
class PerMessageDeflate {
|
|
66141
|
-
constructor(options) {
|
|
66142
|
-
this._options = options || {};
|
|
66143
|
-
this._threshold = this._options.threshold !== undefined ? this._options.threshold : 1024;
|
|
66144
|
-
this._maxPayload = this._options.maxPayload | 0;
|
|
66145
|
-
this._isServer = !!this._options.isServer;
|
|
66146
|
-
this._deflate = null;
|
|
66147
|
-
this._inflate = null;
|
|
66148
|
-
this.params = null;
|
|
66149
|
-
if (!zlibLimiter) {
|
|
66150
|
-
const concurrency = this._options.concurrencyLimit !== undefined ? this._options.concurrencyLimit : 10;
|
|
66151
|
-
zlibLimiter = new Limiter(concurrency);
|
|
66152
|
-
}
|
|
66153
|
-
}
|
|
66154
|
-
static get extensionName() {
|
|
66155
|
-
return "permessage-deflate";
|
|
66156
|
-
}
|
|
66157
|
-
offer() {
|
|
66158
|
-
const params = {};
|
|
66159
|
-
if (this._options.serverNoContextTakeover) {
|
|
66160
|
-
params.server_no_context_takeover = true;
|
|
66161
|
-
}
|
|
66162
|
-
if (this._options.clientNoContextTakeover) {
|
|
66163
|
-
params.client_no_context_takeover = true;
|
|
66164
|
-
}
|
|
66165
|
-
if (this._options.serverMaxWindowBits) {
|
|
66166
|
-
params.server_max_window_bits = this._options.serverMaxWindowBits;
|
|
66167
|
-
}
|
|
66168
|
-
if (this._options.clientMaxWindowBits) {
|
|
66169
|
-
params.client_max_window_bits = this._options.clientMaxWindowBits;
|
|
66170
|
-
} else if (this._options.clientMaxWindowBits == null) {
|
|
66171
|
-
params.client_max_window_bits = true;
|
|
66172
|
-
}
|
|
66173
|
-
return params;
|
|
66174
|
-
}
|
|
66175
|
-
accept(configurations) {
|
|
66176
|
-
configurations = this.normalizeParams(configurations);
|
|
66177
|
-
this.params = this._isServer ? this.acceptAsServer(configurations) : this.acceptAsClient(configurations);
|
|
66178
|
-
return this.params;
|
|
66179
|
-
}
|
|
66180
|
-
cleanup() {
|
|
66181
|
-
if (this._inflate) {
|
|
66182
|
-
this._inflate.close();
|
|
66183
|
-
this._inflate = null;
|
|
66184
|
-
}
|
|
66185
|
-
if (this._deflate) {
|
|
66186
|
-
const callback = this._deflate[kCallback];
|
|
66187
|
-
this._deflate.close();
|
|
66188
|
-
this._deflate = null;
|
|
66189
|
-
if (callback) {
|
|
66190
|
-
callback(new Error("The deflate stream was closed while data was being processed"));
|
|
66191
|
-
}
|
|
66192
|
-
}
|
|
66193
|
-
}
|
|
66194
|
-
acceptAsServer(offers) {
|
|
66195
|
-
const opts = this._options;
|
|
66196
|
-
const accepted = offers.find((params) => {
|
|
66197
|
-
if (opts.serverNoContextTakeover === false && params.server_no_context_takeover || params.server_max_window_bits && (opts.serverMaxWindowBits === false || typeof opts.serverMaxWindowBits === "number" && opts.serverMaxWindowBits > params.server_max_window_bits) || typeof opts.clientMaxWindowBits === "number" && (typeof params.client_max_window_bits === "number" ? opts.clientMaxWindowBits > params.client_max_window_bits : !params.client_max_window_bits)) {
|
|
66198
|
-
return false;
|
|
66199
|
-
}
|
|
66200
|
-
return true;
|
|
66201
|
-
});
|
|
66202
|
-
if (!accepted) {
|
|
66203
|
-
throw new Error("None of the extension offers can be accepted");
|
|
66204
|
-
}
|
|
66205
|
-
if (opts.serverNoContextTakeover) {
|
|
66206
|
-
accepted.server_no_context_takeover = true;
|
|
66207
|
-
}
|
|
66208
|
-
if (opts.clientNoContextTakeover) {
|
|
66209
|
-
accepted.client_no_context_takeover = true;
|
|
66210
|
-
}
|
|
66211
|
-
if (typeof opts.serverMaxWindowBits === "number") {
|
|
66212
|
-
accepted.server_max_window_bits = opts.serverMaxWindowBits;
|
|
66213
|
-
}
|
|
66214
|
-
if (typeof opts.clientMaxWindowBits === "number") {
|
|
66215
|
-
accepted.client_max_window_bits = opts.clientMaxWindowBits;
|
|
66216
|
-
} else if (accepted.client_max_window_bits === true || opts.clientMaxWindowBits === false) {
|
|
66217
|
-
delete accepted.client_max_window_bits;
|
|
66218
|
-
}
|
|
66219
|
-
return accepted;
|
|
66220
|
-
}
|
|
66221
|
-
acceptAsClient(response) {
|
|
66222
|
-
const params = response[0];
|
|
66223
|
-
if (this._options.clientNoContextTakeover === false && params.client_no_context_takeover) {
|
|
66224
|
-
throw new Error('Unexpected parameter "client_no_context_takeover"');
|
|
66225
|
-
}
|
|
66226
|
-
if (!params.client_max_window_bits) {
|
|
66227
|
-
if (typeof this._options.clientMaxWindowBits === "number") {
|
|
66228
|
-
params.client_max_window_bits = this._options.clientMaxWindowBits;
|
|
66229
|
-
}
|
|
66230
|
-
} else if (this._options.clientMaxWindowBits === false || typeof this._options.clientMaxWindowBits === "number" && params.client_max_window_bits > this._options.clientMaxWindowBits) {
|
|
66231
|
-
throw new Error('Unexpected or invalid parameter "client_max_window_bits"');
|
|
66232
|
-
}
|
|
66233
|
-
return params;
|
|
66234
|
-
}
|
|
66235
|
-
normalizeParams(configurations) {
|
|
66236
|
-
configurations.forEach((params) => {
|
|
66237
|
-
Object.keys(params).forEach((key) => {
|
|
66238
|
-
let value = params[key];
|
|
66239
|
-
if (value.length > 1) {
|
|
66240
|
-
throw new Error(`Parameter "${key}" must have only a single value`);
|
|
66241
|
-
}
|
|
66242
|
-
value = value[0];
|
|
66243
|
-
if (key === "client_max_window_bits") {
|
|
66244
|
-
if (value !== true) {
|
|
66245
|
-
const num = +value;
|
|
66246
|
-
if (!Number.isInteger(num) || num < 8 || num > 15) {
|
|
66247
|
-
throw new TypeError(`Invalid value for parameter "${key}": ${value}`);
|
|
66248
|
-
}
|
|
66249
|
-
value = num;
|
|
66250
|
-
} else if (!this._isServer) {
|
|
66251
|
-
throw new TypeError(`Invalid value for parameter "${key}": ${value}`);
|
|
66252
|
-
}
|
|
66253
|
-
} else if (key === "server_max_window_bits") {
|
|
66254
|
-
const num = +value;
|
|
66255
|
-
if (!Number.isInteger(num) || num < 8 || num > 15) {
|
|
66256
|
-
throw new TypeError(`Invalid value for parameter "${key}": ${value}`);
|
|
66257
|
-
}
|
|
66258
|
-
value = num;
|
|
66259
|
-
} else if (key === "client_no_context_takeover" || key === "server_no_context_takeover") {
|
|
66260
|
-
if (value !== true) {
|
|
66261
|
-
throw new TypeError(`Invalid value for parameter "${key}": ${value}`);
|
|
66262
|
-
}
|
|
66263
|
-
} else {
|
|
66264
|
-
throw new Error(`Unknown parameter "${key}"`);
|
|
66265
|
-
}
|
|
66266
|
-
params[key] = value;
|
|
66267
|
-
});
|
|
66268
|
-
});
|
|
66269
|
-
return configurations;
|
|
66270
|
-
}
|
|
66271
|
-
decompress(data, fin, callback) {
|
|
66272
|
-
zlibLimiter.add((done) => {
|
|
66273
|
-
this._decompress(data, fin, (err, result) => {
|
|
66274
|
-
done();
|
|
66275
|
-
callback(err, result);
|
|
66276
|
-
});
|
|
66277
|
-
});
|
|
66278
|
-
}
|
|
66279
|
-
compress(data, fin, callback) {
|
|
66280
|
-
zlibLimiter.add((done) => {
|
|
66281
|
-
this._compress(data, fin, (err, result) => {
|
|
66282
|
-
done();
|
|
66283
|
-
callback(err, result);
|
|
66284
|
-
});
|
|
66285
|
-
});
|
|
66286
|
-
}
|
|
66287
|
-
_decompress(data, fin, callback) {
|
|
66288
|
-
const endpoint = this._isServer ? "client" : "server";
|
|
66289
|
-
if (!this._inflate) {
|
|
66290
|
-
const key = `${endpoint}_max_window_bits`;
|
|
66291
|
-
const windowBits = typeof this.params[key] !== "number" ? zlib.Z_DEFAULT_WINDOWBITS : this.params[key];
|
|
66292
|
-
this._inflate = zlib.createInflateRaw({
|
|
66293
|
-
...this._options.zlibInflateOptions,
|
|
66294
|
-
windowBits
|
|
66295
|
-
});
|
|
66296
|
-
this._inflate[kPerMessageDeflate] = this;
|
|
66297
|
-
this._inflate[kTotalLength] = 0;
|
|
66298
|
-
this._inflate[kBuffers] = [];
|
|
66299
|
-
this._inflate.on("error", inflateOnError);
|
|
66300
|
-
this._inflate.on("data", inflateOnData);
|
|
66301
|
-
}
|
|
66302
|
-
this._inflate[kCallback] = callback;
|
|
66303
|
-
this._inflate.write(data);
|
|
66304
|
-
if (fin)
|
|
66305
|
-
this._inflate.write(TRAILER);
|
|
66306
|
-
this._inflate.flush(() => {
|
|
66307
|
-
const err = this._inflate[kError];
|
|
66308
|
-
if (err) {
|
|
66309
|
-
this._inflate.close();
|
|
66310
|
-
this._inflate = null;
|
|
66311
|
-
callback(err);
|
|
66312
|
-
return;
|
|
66313
|
-
}
|
|
66314
|
-
const data = bufferUtil.concat(this._inflate[kBuffers], this._inflate[kTotalLength]);
|
|
66315
|
-
if (this._inflate._readableState.endEmitted) {
|
|
66316
|
-
this._inflate.close();
|
|
66317
|
-
this._inflate = null;
|
|
66318
|
-
} else {
|
|
66319
|
-
this._inflate[kTotalLength] = 0;
|
|
66320
|
-
this._inflate[kBuffers] = [];
|
|
66321
|
-
if (fin && this.params[`${endpoint}_no_context_takeover`]) {
|
|
66322
|
-
this._inflate.reset();
|
|
66323
|
-
}
|
|
66324
|
-
}
|
|
66325
|
-
callback(null, data);
|
|
66326
|
-
});
|
|
66327
|
-
}
|
|
66328
|
-
_compress(data, fin, callback) {
|
|
66329
|
-
const endpoint = this._isServer ? "server" : "client";
|
|
66330
|
-
if (!this._deflate) {
|
|
66331
|
-
const key = `${endpoint}_max_window_bits`;
|
|
66332
|
-
const windowBits = typeof this.params[key] !== "number" ? zlib.Z_DEFAULT_WINDOWBITS : this.params[key];
|
|
66333
|
-
this._deflate = zlib.createDeflateRaw({
|
|
66334
|
-
...this._options.zlibDeflateOptions,
|
|
66335
|
-
windowBits
|
|
66336
|
-
});
|
|
66337
|
-
this._deflate[kTotalLength] = 0;
|
|
66338
|
-
this._deflate[kBuffers] = [];
|
|
66339
|
-
this._deflate.on("data", deflateOnData);
|
|
66340
|
-
}
|
|
66341
|
-
this._deflate[kCallback] = callback;
|
|
66342
|
-
this._deflate.write(data);
|
|
66343
|
-
this._deflate.flush(zlib.Z_SYNC_FLUSH, () => {
|
|
66344
|
-
if (!this._deflate) {
|
|
66345
|
-
return;
|
|
66346
|
-
}
|
|
66347
|
-
let data = bufferUtil.concat(this._deflate[kBuffers], this._deflate[kTotalLength]);
|
|
66348
|
-
if (fin) {
|
|
66349
|
-
data = new FastBuffer(data.buffer, data.byteOffset, data.length - 4);
|
|
66350
|
-
}
|
|
66351
|
-
this._deflate[kCallback] = null;
|
|
66352
|
-
this._deflate[kTotalLength] = 0;
|
|
66353
|
-
this._deflate[kBuffers] = [];
|
|
66354
|
-
if (fin && this.params[`${endpoint}_no_context_takeover`]) {
|
|
66355
|
-
this._deflate.reset();
|
|
66356
|
-
}
|
|
66357
|
-
callback(null, data);
|
|
66358
|
-
});
|
|
66359
|
-
}
|
|
66360
|
-
}
|
|
66361
|
-
module2.exports = PerMessageDeflate;
|
|
66362
|
-
function deflateOnData(chunk) {
|
|
66363
|
-
this[kBuffers].push(chunk);
|
|
66364
|
-
this[kTotalLength] += chunk.length;
|
|
66365
|
-
}
|
|
66366
|
-
function inflateOnData(chunk) {
|
|
66367
|
-
this[kTotalLength] += chunk.length;
|
|
66368
|
-
if (this[kPerMessageDeflate]._maxPayload < 1 || this[kTotalLength] <= this[kPerMessageDeflate]._maxPayload) {
|
|
66369
|
-
this[kBuffers].push(chunk);
|
|
66370
|
-
return;
|
|
66371
|
-
}
|
|
66372
|
-
this[kError] = new RangeError("Max payload size exceeded");
|
|
66373
|
-
this[kError].code = "WS_ERR_UNSUPPORTED_MESSAGE_LENGTH";
|
|
66374
|
-
this[kError][kStatusCode] = 1009;
|
|
66375
|
-
this.removeListener("data", inflateOnData);
|
|
66376
|
-
this.reset();
|
|
66377
|
-
}
|
|
66378
|
-
function inflateOnError(err) {
|
|
66379
|
-
this[kPerMessageDeflate]._inflate = null;
|
|
66380
|
-
if (this[kError]) {
|
|
66381
|
-
this[kCallback](this[kError]);
|
|
66382
|
-
return;
|
|
66383
|
-
}
|
|
66384
|
-
err[kStatusCode] = 1007;
|
|
66385
|
-
this[kCallback](err);
|
|
66386
|
-
}
|
|
66387
|
-
});
|
|
66388
|
-
|
|
66389
|
-
// node_modules/@discordjs/ws/node_modules/ws/lib/validation.js
|
|
66390
|
-
var require_validation = __commonJS(function(exports2, module2) {
|
|
66391
|
-
var { isUtf8 } = __require("buffer");
|
|
66392
|
-
var { hasBlob } = require_constants11();
|
|
66393
|
-
var tokenChars = [
|
|
66394
|
-
0,
|
|
66395
|
-
0,
|
|
66396
|
-
0,
|
|
66397
|
-
0,
|
|
66398
|
-
0,
|
|
66399
|
-
0,
|
|
66400
|
-
0,
|
|
66401
|
-
0,
|
|
66402
|
-
0,
|
|
66403
|
-
0,
|
|
66404
|
-
0,
|
|
66405
|
-
0,
|
|
66406
|
-
0,
|
|
66407
|
-
0,
|
|
66408
|
-
0,
|
|
66409
|
-
0,
|
|
66410
|
-
0,
|
|
66411
|
-
0,
|
|
66412
|
-
0,
|
|
66413
|
-
0,
|
|
66414
|
-
0,
|
|
66415
|
-
0,
|
|
66416
|
-
0,
|
|
66417
|
-
0,
|
|
66418
|
-
0,
|
|
66419
|
-
0,
|
|
66420
|
-
0,
|
|
66421
|
-
0,
|
|
66422
|
-
0,
|
|
66423
|
-
0,
|
|
66424
|
-
0,
|
|
66425
|
-
0,
|
|
66426
|
-
0,
|
|
66427
|
-
1,
|
|
66428
|
-
0,
|
|
66429
|
-
1,
|
|
66430
|
-
1,
|
|
66431
|
-
1,
|
|
66432
|
-
1,
|
|
66433
|
-
1,
|
|
66434
|
-
0,
|
|
66435
|
-
0,
|
|
66436
|
-
1,
|
|
66437
|
-
1,
|
|
66438
|
-
0,
|
|
66439
|
-
1,
|
|
66440
|
-
1,
|
|
66441
|
-
0,
|
|
66442
|
-
1,
|
|
66443
|
-
1,
|
|
66444
|
-
1,
|
|
66445
|
-
1,
|
|
66446
|
-
1,
|
|
66447
|
-
1,
|
|
66448
|
-
1,
|
|
66449
|
-
1,
|
|
66450
|
-
1,
|
|
66451
|
-
1,
|
|
66452
|
-
0,
|
|
66453
|
-
0,
|
|
66454
|
-
0,
|
|
66455
|
-
0,
|
|
66456
|
-
0,
|
|
66457
|
-
0,
|
|
66458
|
-
0,
|
|
66459
|
-
1,
|
|
66460
|
-
1,
|
|
66461
|
-
1,
|
|
66462
|
-
1,
|
|
66463
|
-
1,
|
|
66464
|
-
1,
|
|
66465
|
-
1,
|
|
66466
|
-
1,
|
|
66467
|
-
1,
|
|
66468
|
-
1,
|
|
66469
|
-
1,
|
|
66470
|
-
1,
|
|
66471
|
-
1,
|
|
66472
|
-
1,
|
|
66473
|
-
1,
|
|
66474
|
-
1,
|
|
66475
|
-
1,
|
|
66476
|
-
1,
|
|
66477
|
-
1,
|
|
66478
|
-
1,
|
|
66479
|
-
1,
|
|
66480
|
-
1,
|
|
66481
|
-
1,
|
|
66482
|
-
1,
|
|
66483
|
-
1,
|
|
66484
|
-
1,
|
|
66485
|
-
0,
|
|
66486
|
-
0,
|
|
66487
|
-
0,
|
|
66488
|
-
1,
|
|
66489
|
-
1,
|
|
66490
|
-
1,
|
|
66491
|
-
1,
|
|
66492
|
-
1,
|
|
66493
|
-
1,
|
|
66494
|
-
1,
|
|
66495
|
-
1,
|
|
66496
|
-
1,
|
|
66497
|
-
1,
|
|
66498
|
-
1,
|
|
66499
|
-
1,
|
|
66500
|
-
1,
|
|
66501
|
-
1,
|
|
66502
|
-
1,
|
|
66503
|
-
1,
|
|
66504
|
-
1,
|
|
66505
|
-
1,
|
|
66506
|
-
1,
|
|
66507
|
-
1,
|
|
66508
|
-
1,
|
|
66509
|
-
1,
|
|
66510
|
-
1,
|
|
66511
|
-
1,
|
|
66512
|
-
1,
|
|
66513
|
-
1,
|
|
66514
|
-
1,
|
|
66515
|
-
1,
|
|
66516
|
-
1,
|
|
66517
|
-
0,
|
|
66518
|
-
1,
|
|
66519
|
-
0,
|
|
66520
|
-
1,
|
|
66521
|
-
0
|
|
66522
|
-
];
|
|
66523
|
-
function isValidStatusCode(code) {
|
|
66524
|
-
return code >= 1000 && code <= 1014 && code !== 1004 && code !== 1005 && code !== 1006 || code >= 3000 && code <= 4999;
|
|
66525
|
-
}
|
|
66526
|
-
function _isValidUTF8(buf) {
|
|
66527
|
-
const len = buf.length;
|
|
66528
|
-
let i = 0;
|
|
66529
|
-
while (i < len) {
|
|
66530
|
-
if ((buf[i] & 128) === 0) {
|
|
66531
|
-
i++;
|
|
66532
|
-
} else if ((buf[i] & 224) === 192) {
|
|
66533
|
-
if (i + 1 === len || (buf[i + 1] & 192) !== 128 || (buf[i] & 254) === 192) {
|
|
66534
|
-
return false;
|
|
66535
|
-
}
|
|
66536
|
-
i += 2;
|
|
66537
|
-
} else if ((buf[i] & 240) === 224) {
|
|
66538
|
-
if (i + 2 >= len || (buf[i + 1] & 192) !== 128 || (buf[i + 2] & 192) !== 128 || buf[i] === 224 && (buf[i + 1] & 224) === 128 || buf[i] === 237 && (buf[i + 1] & 224) === 160) {
|
|
66539
|
-
return false;
|
|
66540
|
-
}
|
|
66541
|
-
i += 3;
|
|
66542
|
-
} else if ((buf[i] & 248) === 240) {
|
|
66543
|
-
if (i + 3 >= len || (buf[i + 1] & 192) !== 128 || (buf[i + 2] & 192) !== 128 || (buf[i + 3] & 192) !== 128 || buf[i] === 240 && (buf[i + 1] & 240) === 128 || buf[i] === 244 && buf[i + 1] > 143 || buf[i] > 244) {
|
|
66544
|
-
return false;
|
|
66545
|
-
}
|
|
66546
|
-
i += 4;
|
|
66547
|
-
} else {
|
|
66548
|
-
return false;
|
|
66549
|
-
}
|
|
66550
|
-
}
|
|
66551
|
-
return true;
|
|
66552
|
-
}
|
|
66553
|
-
function isBlob(value) {
|
|
66554
|
-
return hasBlob && typeof value === "object" && typeof value.arrayBuffer === "function" && typeof value.type === "string" && typeof value.stream === "function" && (value[Symbol.toStringTag] === "Blob" || value[Symbol.toStringTag] === "File");
|
|
66555
|
-
}
|
|
66556
|
-
module2.exports = {
|
|
66557
|
-
isBlob,
|
|
66558
|
-
isValidStatusCode,
|
|
66559
|
-
isValidUTF8: _isValidUTF8,
|
|
66560
|
-
tokenChars
|
|
66561
|
-
};
|
|
66562
|
-
if (isUtf8) {
|
|
66563
|
-
module2.exports.isValidUTF8 = function(buf) {
|
|
66564
|
-
return buf.length < 24 ? _isValidUTF8(buf) : isUtf8(buf);
|
|
66565
|
-
};
|
|
66566
|
-
} else if (!process.env.WS_NO_UTF_8_VALIDATE) {
|
|
66567
|
-
try {
|
|
66568
|
-
const isValidUTF8 = (()=>{throw new Error("Cannot require module "+"utf-8-validate");})();
|
|
66569
|
-
module2.exports.isValidUTF8 = function(buf) {
|
|
66570
|
-
return buf.length < 32 ? _isValidUTF8(buf) : isValidUTF8(buf);
|
|
66571
|
-
};
|
|
66572
|
-
} catch (e) {}
|
|
66573
|
-
}
|
|
66574
|
-
});
|
|
66575
|
-
|
|
66576
|
-
// node_modules/@discordjs/ws/node_modules/ws/lib/receiver.js
|
|
66577
|
-
var require_receiver3 = __commonJS(function(exports2, module2) {
|
|
66578
|
-
var { Writable } = __require("stream");
|
|
66579
|
-
var PerMessageDeflate = require_permessage_deflate3();
|
|
66580
|
-
var {
|
|
66581
|
-
BINARY_TYPES,
|
|
66582
|
-
EMPTY_BUFFER,
|
|
66583
|
-
kStatusCode,
|
|
66584
|
-
kWebSocket
|
|
66585
|
-
} = require_constants11();
|
|
66586
|
-
var { concat, toArrayBuffer, unmask } = require_buffer_util();
|
|
66587
|
-
var { isValidStatusCode, isValidUTF8 } = require_validation();
|
|
66588
|
-
var FastBuffer = Buffer[Symbol.species];
|
|
66589
|
-
var GET_INFO = 0;
|
|
66590
|
-
var GET_PAYLOAD_LENGTH_16 = 1;
|
|
66591
|
-
var GET_PAYLOAD_LENGTH_64 = 2;
|
|
66592
|
-
var GET_MASK = 3;
|
|
66593
|
-
var GET_DATA = 4;
|
|
66594
|
-
var INFLATING = 5;
|
|
66595
|
-
var DEFER_EVENT = 6;
|
|
66596
|
-
|
|
66597
|
-
class Receiver extends Writable {
|
|
66598
|
-
constructor(options = {}) {
|
|
66599
|
-
super();
|
|
66600
|
-
this._allowSynchronousEvents = options.allowSynchronousEvents !== undefined ? options.allowSynchronousEvents : true;
|
|
66601
|
-
this._binaryType = options.binaryType || BINARY_TYPES[0];
|
|
66602
|
-
this._extensions = options.extensions || {};
|
|
66603
|
-
this._isServer = !!options.isServer;
|
|
66604
|
-
this._maxBufferedChunks = options.maxBufferedChunks | 0;
|
|
66605
|
-
this._maxFragments = options.maxFragments | 0;
|
|
66606
|
-
this._maxPayload = options.maxPayload | 0;
|
|
66607
|
-
this._skipUTF8Validation = !!options.skipUTF8Validation;
|
|
66608
|
-
this[kWebSocket] = undefined;
|
|
66609
|
-
this._bufferedBytes = 0;
|
|
66610
|
-
this._buffers = [];
|
|
66611
|
-
this._compressed = false;
|
|
66612
|
-
this._payloadLength = 0;
|
|
66613
|
-
this._mask = undefined;
|
|
66614
|
-
this._fragmented = 0;
|
|
66615
|
-
this._masked = false;
|
|
66616
|
-
this._fin = false;
|
|
66617
|
-
this._opcode = 0;
|
|
66618
|
-
this._totalPayloadLength = 0;
|
|
66619
|
-
this._messageLength = 0;
|
|
66620
|
-
this._numFragments = 0;
|
|
66621
|
-
this._fragments = [];
|
|
66622
|
-
this._errored = false;
|
|
66623
|
-
this._loop = false;
|
|
66624
|
-
this._state = GET_INFO;
|
|
66625
|
-
}
|
|
66626
|
-
_write(chunk, encoding, cb) {
|
|
66627
|
-
if (this._opcode === 8 && this._state == GET_INFO)
|
|
66628
|
-
return cb();
|
|
66629
|
-
if (this._maxBufferedChunks > 0 && this._buffers.length >= this._maxBufferedChunks) {
|
|
66630
|
-
cb(this.createError(RangeError, "Too many buffered chunks", false, 1008, "WS_ERR_TOO_MANY_BUFFERED_PARTS"));
|
|
66631
|
-
return;
|
|
66632
|
-
}
|
|
66633
|
-
this._bufferedBytes += chunk.length;
|
|
66634
|
-
this._buffers.push(chunk);
|
|
66635
|
-
this.startLoop(cb);
|
|
66636
|
-
}
|
|
66637
|
-
consume(n) {
|
|
66638
|
-
this._bufferedBytes -= n;
|
|
66639
|
-
if (n === this._buffers[0].length)
|
|
66640
|
-
return this._buffers.shift();
|
|
66641
|
-
if (n < this._buffers[0].length) {
|
|
66642
|
-
const buf = this._buffers[0];
|
|
66643
|
-
this._buffers[0] = new FastBuffer(buf.buffer, buf.byteOffset + n, buf.length - n);
|
|
66644
|
-
return new FastBuffer(buf.buffer, buf.byteOffset, n);
|
|
66645
|
-
}
|
|
66646
|
-
const dst = Buffer.allocUnsafe(n);
|
|
66647
|
-
do {
|
|
66648
|
-
const buf = this._buffers[0];
|
|
66649
|
-
const offset = dst.length - n;
|
|
66650
|
-
if (n >= buf.length) {
|
|
66651
|
-
dst.set(this._buffers.shift(), offset);
|
|
66652
|
-
} else {
|
|
66653
|
-
dst.set(new Uint8Array(buf.buffer, buf.byteOffset, n), offset);
|
|
66654
|
-
this._buffers[0] = new FastBuffer(buf.buffer, buf.byteOffset + n, buf.length - n);
|
|
66655
|
-
}
|
|
66656
|
-
n -= buf.length;
|
|
66657
|
-
} while (n > 0);
|
|
66658
|
-
return dst;
|
|
66659
|
-
}
|
|
66660
|
-
startLoop(cb) {
|
|
66661
|
-
this._loop = true;
|
|
66662
|
-
do {
|
|
66663
|
-
switch (this._state) {
|
|
66664
|
-
case GET_INFO:
|
|
66665
|
-
this.getInfo(cb);
|
|
66666
|
-
break;
|
|
66667
|
-
case GET_PAYLOAD_LENGTH_16:
|
|
66668
|
-
this.getPayloadLength16(cb);
|
|
66669
|
-
break;
|
|
66670
|
-
case GET_PAYLOAD_LENGTH_64:
|
|
66671
|
-
this.getPayloadLength64(cb);
|
|
66672
|
-
break;
|
|
66673
|
-
case GET_MASK:
|
|
66674
|
-
this.getMask();
|
|
66675
|
-
break;
|
|
66676
|
-
case GET_DATA:
|
|
66677
|
-
this.getData(cb);
|
|
66678
|
-
break;
|
|
66679
|
-
case INFLATING:
|
|
66680
|
-
case DEFER_EVENT:
|
|
66681
|
-
this._loop = false;
|
|
66682
|
-
return;
|
|
66683
|
-
}
|
|
66684
|
-
} while (this._loop);
|
|
66685
|
-
if (!this._errored)
|
|
66686
|
-
cb();
|
|
66687
|
-
}
|
|
66688
|
-
getInfo(cb) {
|
|
66689
|
-
if (this._bufferedBytes < 2) {
|
|
66690
|
-
this._loop = false;
|
|
66691
|
-
return;
|
|
66692
|
-
}
|
|
66693
|
-
const buf = this.consume(2);
|
|
66694
|
-
if ((buf[0] & 48) !== 0) {
|
|
66695
|
-
const error = this.createError(RangeError, "RSV2 and RSV3 must be clear", true, 1002, "WS_ERR_UNEXPECTED_RSV_2_3");
|
|
66696
|
-
cb(error);
|
|
66697
|
-
return;
|
|
66698
|
-
}
|
|
66699
|
-
const compressed = (buf[0] & 64) === 64;
|
|
66700
|
-
if (compressed && !this._extensions[PerMessageDeflate.extensionName]) {
|
|
66701
|
-
const error = this.createError(RangeError, "RSV1 must be clear", true, 1002, "WS_ERR_UNEXPECTED_RSV_1");
|
|
66702
|
-
cb(error);
|
|
66703
|
-
return;
|
|
66704
|
-
}
|
|
66705
|
-
this._fin = (buf[0] & 128) === 128;
|
|
66706
|
-
this._opcode = buf[0] & 15;
|
|
66707
|
-
this._payloadLength = buf[1] & 127;
|
|
66708
|
-
if (this._opcode === 0) {
|
|
66709
|
-
if (compressed) {
|
|
66710
|
-
const error = this.createError(RangeError, "RSV1 must be clear", true, 1002, "WS_ERR_UNEXPECTED_RSV_1");
|
|
66711
|
-
cb(error);
|
|
66712
|
-
return;
|
|
66713
|
-
}
|
|
66714
|
-
if (!this._fragmented) {
|
|
66715
|
-
const error = this.createError(RangeError, "invalid opcode 0", true, 1002, "WS_ERR_INVALID_OPCODE");
|
|
66716
|
-
cb(error);
|
|
66717
|
-
return;
|
|
66718
|
-
}
|
|
66719
|
-
this._opcode = this._fragmented;
|
|
66720
|
-
} else if (this._opcode === 1 || this._opcode === 2) {
|
|
66721
|
-
if (this._fragmented) {
|
|
66722
|
-
const error = this.createError(RangeError, `invalid opcode ${this._opcode}`, true, 1002, "WS_ERR_INVALID_OPCODE");
|
|
66723
|
-
cb(error);
|
|
66724
|
-
return;
|
|
66725
|
-
}
|
|
66726
|
-
this._compressed = compressed;
|
|
66727
|
-
} else if (this._opcode > 7 && this._opcode < 11) {
|
|
66728
|
-
if (!this._fin) {
|
|
66729
|
-
const error = this.createError(RangeError, "FIN must be set", true, 1002, "WS_ERR_EXPECTED_FIN");
|
|
66730
|
-
cb(error);
|
|
66731
|
-
return;
|
|
66732
|
-
}
|
|
66733
|
-
if (compressed) {
|
|
66734
|
-
const error = this.createError(RangeError, "RSV1 must be clear", true, 1002, "WS_ERR_UNEXPECTED_RSV_1");
|
|
66735
|
-
cb(error);
|
|
66736
|
-
return;
|
|
66737
|
-
}
|
|
66738
|
-
if (this._payloadLength > 125 || this._opcode === 8 && this._payloadLength === 1) {
|
|
66739
|
-
const error = this.createError(RangeError, `invalid payload length ${this._payloadLength}`, true, 1002, "WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");
|
|
66740
|
-
cb(error);
|
|
66741
|
-
return;
|
|
66742
|
-
}
|
|
66743
|
-
} else {
|
|
66744
|
-
const error = this.createError(RangeError, `invalid opcode ${this._opcode}`, true, 1002, "WS_ERR_INVALID_OPCODE");
|
|
66745
|
-
cb(error);
|
|
66746
|
-
return;
|
|
66747
|
-
}
|
|
66748
|
-
if (!this._fin && !this._fragmented)
|
|
66749
|
-
this._fragmented = this._opcode;
|
|
66750
|
-
this._masked = (buf[1] & 128) === 128;
|
|
66751
|
-
if (this._isServer) {
|
|
66752
|
-
if (!this._masked) {
|
|
66753
|
-
const error = this.createError(RangeError, "MASK must be set", true, 1002, "WS_ERR_EXPECTED_MASK");
|
|
66754
|
-
cb(error);
|
|
66755
|
-
return;
|
|
66756
|
-
}
|
|
66757
|
-
} else if (this._masked) {
|
|
66758
|
-
const error = this.createError(RangeError, "MASK must be clear", true, 1002, "WS_ERR_UNEXPECTED_MASK");
|
|
66759
|
-
cb(error);
|
|
66760
|
-
return;
|
|
66761
|
-
}
|
|
66762
|
-
if (this._payloadLength === 126)
|
|
66763
|
-
this._state = GET_PAYLOAD_LENGTH_16;
|
|
66764
|
-
else if (this._payloadLength === 127)
|
|
66765
|
-
this._state = GET_PAYLOAD_LENGTH_64;
|
|
66766
|
-
else
|
|
66767
|
-
this.haveLength(cb);
|
|
66768
|
-
}
|
|
66769
|
-
getPayloadLength16(cb) {
|
|
66770
|
-
if (this._bufferedBytes < 2) {
|
|
66771
|
-
this._loop = false;
|
|
66772
|
-
return;
|
|
66773
|
-
}
|
|
66774
|
-
this._payloadLength = this.consume(2).readUInt16BE(0);
|
|
66775
|
-
this.haveLength(cb);
|
|
66776
|
-
}
|
|
66777
|
-
getPayloadLength64(cb) {
|
|
66778
|
-
if (this._bufferedBytes < 8) {
|
|
66779
|
-
this._loop = false;
|
|
66780
|
-
return;
|
|
66781
|
-
}
|
|
66782
|
-
const buf = this.consume(8);
|
|
66783
|
-
const num = buf.readUInt32BE(0);
|
|
66784
|
-
if (num > Math.pow(2, 53 - 32) - 1) {
|
|
66785
|
-
const error = this.createError(RangeError, "Unsupported WebSocket frame: payload length > 2^53 - 1", false, 1009, "WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");
|
|
66786
|
-
cb(error);
|
|
66787
|
-
return;
|
|
66788
|
-
}
|
|
66789
|
-
this._payloadLength = num * Math.pow(2, 32) + buf.readUInt32BE(4);
|
|
66790
|
-
this.haveLength(cb);
|
|
66791
|
-
}
|
|
66792
|
-
haveLength(cb) {
|
|
66793
|
-
if (this._payloadLength && this._opcode < 8) {
|
|
66794
|
-
this._totalPayloadLength += this._payloadLength;
|
|
66795
|
-
if (this._totalPayloadLength > this._maxPayload && this._maxPayload > 0) {
|
|
66796
|
-
const error = this.createError(RangeError, "Max payload size exceeded", false, 1009, "WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");
|
|
66797
|
-
cb(error);
|
|
66798
|
-
return;
|
|
66799
|
-
}
|
|
66800
|
-
}
|
|
66801
|
-
if (this._masked)
|
|
66802
|
-
this._state = GET_MASK;
|
|
66803
|
-
else
|
|
66804
|
-
this._state = GET_DATA;
|
|
66805
|
-
}
|
|
66806
|
-
getMask() {
|
|
66807
|
-
if (this._bufferedBytes < 4) {
|
|
66808
|
-
this._loop = false;
|
|
66809
|
-
return;
|
|
66810
|
-
}
|
|
66811
|
-
this._mask = this.consume(4);
|
|
66812
|
-
this._state = GET_DATA;
|
|
66813
|
-
}
|
|
66814
|
-
getData(cb) {
|
|
66815
|
-
let data = EMPTY_BUFFER;
|
|
66816
|
-
if (this._payloadLength) {
|
|
66817
|
-
if (this._bufferedBytes < this._payloadLength) {
|
|
66818
|
-
this._loop = false;
|
|
66819
|
-
return;
|
|
66820
|
-
}
|
|
66821
|
-
data = this.consume(this._payloadLength);
|
|
66822
|
-
if (this._masked && (this._mask[0] | this._mask[1] | this._mask[2] | this._mask[3]) !== 0) {
|
|
66823
|
-
unmask(data, this._mask);
|
|
66824
|
-
}
|
|
66825
|
-
}
|
|
66826
|
-
if (this._opcode > 7) {
|
|
66827
|
-
this.controlMessage(data, cb);
|
|
66828
|
-
return;
|
|
66829
|
-
}
|
|
66830
|
-
if (this._maxFragments > 0 && ++this._numFragments > this._maxFragments) {
|
|
66831
|
-
const error = this.createError(RangeError, "Too many message fragments", false, 1008, "WS_ERR_TOO_MANY_BUFFERED_PARTS");
|
|
66832
|
-
cb(error);
|
|
66833
|
-
return;
|
|
66834
|
-
}
|
|
66835
|
-
if (this._compressed) {
|
|
66836
|
-
this._state = INFLATING;
|
|
66837
|
-
this.decompress(data, cb);
|
|
66838
|
-
return;
|
|
66839
|
-
}
|
|
66840
|
-
if (data.length) {
|
|
66841
|
-
this._messageLength = this._totalPayloadLength;
|
|
66842
|
-
this._fragments.push(data);
|
|
66843
|
-
}
|
|
66844
|
-
this.dataMessage(cb);
|
|
66845
|
-
}
|
|
66846
|
-
decompress(data, cb) {
|
|
66847
|
-
const perMessageDeflate = this._extensions[PerMessageDeflate.extensionName];
|
|
66848
|
-
perMessageDeflate.decompress(data, this._fin, (err, buf) => {
|
|
66849
|
-
if (err)
|
|
66850
|
-
return cb(err);
|
|
66851
|
-
if (buf.length) {
|
|
66852
|
-
this._messageLength += buf.length;
|
|
66853
|
-
if (this._messageLength > this._maxPayload && this._maxPayload > 0) {
|
|
66854
|
-
const error = this.createError(RangeError, "Max payload size exceeded", false, 1009, "WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");
|
|
66855
|
-
cb(error);
|
|
66856
|
-
return;
|
|
66857
|
-
}
|
|
66858
|
-
this._fragments.push(buf);
|
|
66859
|
-
}
|
|
66860
|
-
this.dataMessage(cb);
|
|
66861
|
-
if (this._state === GET_INFO)
|
|
66862
|
-
this.startLoop(cb);
|
|
66863
|
-
});
|
|
66864
|
-
}
|
|
66865
|
-
dataMessage(cb) {
|
|
66866
|
-
if (!this._fin) {
|
|
66867
|
-
this._state = GET_INFO;
|
|
66868
|
-
return;
|
|
66869
|
-
}
|
|
66870
|
-
const messageLength = this._messageLength;
|
|
66871
|
-
const fragments = this._fragments;
|
|
66872
|
-
this._totalPayloadLength = 0;
|
|
66873
|
-
this._messageLength = 0;
|
|
66874
|
-
this._fragmented = 0;
|
|
66875
|
-
this._numFragments = 0;
|
|
66876
|
-
this._fragments = [];
|
|
66877
|
-
if (this._opcode === 2) {
|
|
66878
|
-
let data;
|
|
66879
|
-
if (this._binaryType === "nodebuffer") {
|
|
66880
|
-
data = concat(fragments, messageLength);
|
|
66881
|
-
} else if (this._binaryType === "arraybuffer") {
|
|
66882
|
-
data = toArrayBuffer(concat(fragments, messageLength));
|
|
66883
|
-
} else if (this._binaryType === "blob") {
|
|
66884
|
-
data = new Blob(fragments);
|
|
66885
|
-
} else {
|
|
66886
|
-
data = fragments;
|
|
66887
|
-
}
|
|
66888
|
-
if (this._allowSynchronousEvents) {
|
|
66889
|
-
this.emit("message", data, true);
|
|
66890
|
-
this._state = GET_INFO;
|
|
66891
|
-
} else {
|
|
66892
|
-
this._state = DEFER_EVENT;
|
|
66893
|
-
setImmediate(() => {
|
|
66894
|
-
this.emit("message", data, true);
|
|
66895
|
-
this._state = GET_INFO;
|
|
66896
|
-
this.startLoop(cb);
|
|
66897
|
-
});
|
|
66898
|
-
}
|
|
66899
|
-
} else {
|
|
66900
|
-
const buf = concat(fragments, messageLength);
|
|
66901
|
-
if (!this._skipUTF8Validation && !isValidUTF8(buf)) {
|
|
66902
|
-
const error = this.createError(Error, "invalid UTF-8 sequence", true, 1007, "WS_ERR_INVALID_UTF8");
|
|
66903
|
-
cb(error);
|
|
66904
|
-
return;
|
|
66905
|
-
}
|
|
66906
|
-
if (this._state === INFLATING || this._allowSynchronousEvents) {
|
|
66907
|
-
this.emit("message", buf, false);
|
|
66908
|
-
this._state = GET_INFO;
|
|
66909
|
-
} else {
|
|
66910
|
-
this._state = DEFER_EVENT;
|
|
66911
|
-
setImmediate(() => {
|
|
66912
|
-
this.emit("message", buf, false);
|
|
66913
|
-
this._state = GET_INFO;
|
|
66914
|
-
this.startLoop(cb);
|
|
66915
|
-
});
|
|
66916
|
-
}
|
|
66917
|
-
}
|
|
66918
|
-
}
|
|
66919
|
-
controlMessage(data, cb) {
|
|
66920
|
-
if (this._opcode === 8) {
|
|
66921
|
-
if (data.length === 0) {
|
|
66922
|
-
this._loop = false;
|
|
66923
|
-
this.emit("conclude", 1005, EMPTY_BUFFER);
|
|
66924
|
-
this.end();
|
|
66925
|
-
} else {
|
|
66926
|
-
const code = data.readUInt16BE(0);
|
|
66927
|
-
if (!isValidStatusCode(code)) {
|
|
66928
|
-
const error = this.createError(RangeError, `invalid status code ${code}`, true, 1002, "WS_ERR_INVALID_CLOSE_CODE");
|
|
66929
|
-
cb(error);
|
|
66930
|
-
return;
|
|
66931
|
-
}
|
|
66932
|
-
const buf = new FastBuffer(data.buffer, data.byteOffset + 2, data.length - 2);
|
|
66933
|
-
if (!this._skipUTF8Validation && !isValidUTF8(buf)) {
|
|
66934
|
-
const error = this.createError(Error, "invalid UTF-8 sequence", true, 1007, "WS_ERR_INVALID_UTF8");
|
|
66935
|
-
cb(error);
|
|
66936
|
-
return;
|
|
66937
|
-
}
|
|
66938
|
-
this._loop = false;
|
|
66939
|
-
this.emit("conclude", code, buf);
|
|
66940
|
-
this.end();
|
|
66941
|
-
}
|
|
66942
|
-
this._state = GET_INFO;
|
|
66943
|
-
return;
|
|
66944
|
-
}
|
|
66945
|
-
if (this._allowSynchronousEvents) {
|
|
66946
|
-
this.emit(this._opcode === 9 ? "ping" : "pong", data);
|
|
66947
|
-
this._state = GET_INFO;
|
|
66948
|
-
} else {
|
|
66949
|
-
this._state = DEFER_EVENT;
|
|
66950
|
-
setImmediate(() => {
|
|
66951
|
-
this.emit(this._opcode === 9 ? "ping" : "pong", data);
|
|
66952
|
-
this._state = GET_INFO;
|
|
66953
|
-
this.startLoop(cb);
|
|
66954
|
-
});
|
|
66955
|
-
}
|
|
66956
|
-
}
|
|
66957
|
-
createError(ErrorCtor, message, prefix, statusCode, errorCode) {
|
|
66958
|
-
this._loop = false;
|
|
66959
|
-
this._errored = true;
|
|
66960
|
-
const err = new ErrorCtor(prefix ? `Invalid WebSocket frame: ${message}` : message);
|
|
66961
|
-
Error.captureStackTrace(err, this.createError);
|
|
66962
|
-
err.code = errorCode;
|
|
66963
|
-
err[kStatusCode] = statusCode;
|
|
66964
|
-
return err;
|
|
66965
|
-
}
|
|
66966
|
-
}
|
|
66967
|
-
module2.exports = Receiver;
|
|
66968
|
-
});
|
|
66969
|
-
|
|
66970
|
-
// node_modules/@discordjs/ws/node_modules/ws/lib/sender.js
|
|
66971
|
-
var require_sender3 = __commonJS(function(exports2, module2) {
|
|
66972
|
-
var { Duplex } = __require("stream");
|
|
66973
|
-
var { randomFillSync } = __require("crypto");
|
|
66974
|
-
var {
|
|
66975
|
-
types: { isUint8Array }
|
|
66976
|
-
} = __require("util");
|
|
66977
|
-
var PerMessageDeflate = require_permessage_deflate3();
|
|
66978
|
-
var { EMPTY_BUFFER, kWebSocket, NOOP } = require_constants11();
|
|
66979
|
-
var { isBlob, isValidStatusCode } = require_validation();
|
|
66980
|
-
var { mask: applyMask, toBuffer } = require_buffer_util();
|
|
66981
|
-
var kByteLength = Symbol("kByteLength");
|
|
66982
|
-
var maskBuffer = Buffer.alloc(4);
|
|
66983
|
-
var RANDOM_POOL_SIZE = 8 * 1024;
|
|
66984
|
-
var randomPool;
|
|
66985
|
-
var randomPoolPointer = RANDOM_POOL_SIZE;
|
|
66986
|
-
var DEFAULT = 0;
|
|
66987
|
-
var DEFLATING = 1;
|
|
66988
|
-
var GET_BLOB_DATA = 2;
|
|
66989
|
-
|
|
66990
|
-
class Sender {
|
|
66991
|
-
constructor(socket, extensions, generateMask) {
|
|
66992
|
-
this._extensions = extensions || {};
|
|
66993
|
-
if (generateMask) {
|
|
66994
|
-
this._generateMask = generateMask;
|
|
66995
|
-
this._maskBuffer = Buffer.alloc(4);
|
|
66996
|
-
}
|
|
66997
|
-
this._socket = socket;
|
|
66998
|
-
this._firstFragment = true;
|
|
66999
|
-
this._compress = false;
|
|
67000
|
-
this._bufferedBytes = 0;
|
|
67001
|
-
this._queue = [];
|
|
67002
|
-
this._state = DEFAULT;
|
|
67003
|
-
this.onerror = NOOP;
|
|
67004
|
-
this[kWebSocket] = undefined;
|
|
67005
|
-
}
|
|
67006
|
-
static frame(data, options) {
|
|
67007
|
-
let mask;
|
|
67008
|
-
let merge = false;
|
|
67009
|
-
let offset = 2;
|
|
67010
|
-
let skipMasking = false;
|
|
67011
|
-
if (options.mask) {
|
|
67012
|
-
mask = options.maskBuffer || maskBuffer;
|
|
67013
|
-
if (options.generateMask) {
|
|
67014
|
-
options.generateMask(mask);
|
|
67015
|
-
} else {
|
|
67016
|
-
if (randomPoolPointer === RANDOM_POOL_SIZE) {
|
|
67017
|
-
if (randomPool === undefined) {
|
|
67018
|
-
randomPool = Buffer.alloc(RANDOM_POOL_SIZE);
|
|
67019
|
-
}
|
|
67020
|
-
randomFillSync(randomPool, 0, RANDOM_POOL_SIZE);
|
|
67021
|
-
randomPoolPointer = 0;
|
|
67022
|
-
}
|
|
67023
|
-
mask[0] = randomPool[randomPoolPointer++];
|
|
67024
|
-
mask[1] = randomPool[randomPoolPointer++];
|
|
67025
|
-
mask[2] = randomPool[randomPoolPointer++];
|
|
67026
|
-
mask[3] = randomPool[randomPoolPointer++];
|
|
67027
|
-
}
|
|
67028
|
-
skipMasking = (mask[0] | mask[1] | mask[2] | mask[3]) === 0;
|
|
67029
|
-
offset = 6;
|
|
67030
|
-
}
|
|
67031
|
-
let dataLength;
|
|
67032
|
-
if (typeof data === "string") {
|
|
67033
|
-
if ((!options.mask || skipMasking) && options[kByteLength] !== undefined) {
|
|
67034
|
-
dataLength = options[kByteLength];
|
|
67035
|
-
} else {
|
|
67036
|
-
data = Buffer.from(data);
|
|
67037
|
-
dataLength = data.length;
|
|
67038
|
-
}
|
|
67039
|
-
} else {
|
|
67040
|
-
dataLength = data.length;
|
|
67041
|
-
merge = options.mask && options.readOnly && !skipMasking;
|
|
67042
|
-
}
|
|
67043
|
-
let payloadLength = dataLength;
|
|
67044
|
-
if (dataLength >= 65536) {
|
|
67045
|
-
offset += 8;
|
|
67046
|
-
payloadLength = 127;
|
|
67047
|
-
} else if (dataLength > 125) {
|
|
67048
|
-
offset += 2;
|
|
67049
|
-
payloadLength = 126;
|
|
67050
|
-
}
|
|
67051
|
-
const target = Buffer.allocUnsafe(merge ? dataLength + offset : offset);
|
|
67052
|
-
target[0] = options.fin ? options.opcode | 128 : options.opcode;
|
|
67053
|
-
if (options.rsv1)
|
|
67054
|
-
target[0] |= 64;
|
|
67055
|
-
target[1] = payloadLength;
|
|
67056
|
-
if (payloadLength === 126) {
|
|
67057
|
-
target.writeUInt16BE(dataLength, 2);
|
|
67058
|
-
} else if (payloadLength === 127) {
|
|
67059
|
-
target[2] = target[3] = 0;
|
|
67060
|
-
target.writeUIntBE(dataLength, 4, 6);
|
|
67061
|
-
}
|
|
67062
|
-
if (!options.mask)
|
|
67063
|
-
return [target, data];
|
|
67064
|
-
target[1] |= 128;
|
|
67065
|
-
target[offset - 4] = mask[0];
|
|
67066
|
-
target[offset - 3] = mask[1];
|
|
67067
|
-
target[offset - 2] = mask[2];
|
|
67068
|
-
target[offset - 1] = mask[3];
|
|
67069
|
-
if (skipMasking)
|
|
67070
|
-
return [target, data];
|
|
67071
|
-
if (merge) {
|
|
67072
|
-
applyMask(data, mask, target, offset, dataLength);
|
|
67073
|
-
return [target];
|
|
67074
|
-
}
|
|
67075
|
-
applyMask(data, mask, data, 0, dataLength);
|
|
67076
|
-
return [target, data];
|
|
67077
|
-
}
|
|
67078
|
-
close(code, data, mask, cb) {
|
|
67079
|
-
let buf;
|
|
67080
|
-
if (code === undefined) {
|
|
67081
|
-
buf = EMPTY_BUFFER;
|
|
67082
|
-
} else if (typeof code !== "number" || !isValidStatusCode(code)) {
|
|
67083
|
-
throw new TypeError("First argument must be a valid error code number");
|
|
67084
|
-
} else if (data === undefined || !data.length) {
|
|
67085
|
-
buf = Buffer.allocUnsafe(2);
|
|
67086
|
-
buf.writeUInt16BE(code, 0);
|
|
67087
|
-
} else {
|
|
67088
|
-
const length = Buffer.byteLength(data);
|
|
67089
|
-
if (length > 123) {
|
|
67090
|
-
throw new RangeError("The message must not be greater than 123 bytes");
|
|
67091
|
-
}
|
|
67092
|
-
buf = Buffer.allocUnsafe(2 + length);
|
|
67093
|
-
buf.writeUInt16BE(code, 0);
|
|
67094
|
-
if (typeof data === "string") {
|
|
67095
|
-
buf.write(data, 2);
|
|
67096
|
-
} else if (isUint8Array(data)) {
|
|
67097
|
-
buf.set(data, 2);
|
|
67098
|
-
} else {
|
|
67099
|
-
throw new TypeError("Second argument must be a string or a Uint8Array");
|
|
67100
|
-
}
|
|
67101
|
-
}
|
|
67102
|
-
const options = {
|
|
67103
|
-
[kByteLength]: buf.length,
|
|
67104
|
-
fin: true,
|
|
67105
|
-
generateMask: this._generateMask,
|
|
67106
|
-
mask,
|
|
67107
|
-
maskBuffer: this._maskBuffer,
|
|
67108
|
-
opcode: 8,
|
|
67109
|
-
readOnly: false,
|
|
67110
|
-
rsv1: false
|
|
67111
|
-
};
|
|
67112
|
-
if (this._state !== DEFAULT) {
|
|
67113
|
-
this.enqueue([this.dispatch, buf, false, options, cb]);
|
|
67114
|
-
} else {
|
|
67115
|
-
this.sendFrame(Sender.frame(buf, options), cb);
|
|
67116
|
-
}
|
|
67117
|
-
}
|
|
67118
|
-
ping(data, mask, cb) {
|
|
67119
|
-
let byteLength;
|
|
67120
|
-
let readOnly;
|
|
67121
|
-
if (typeof data === "string") {
|
|
67122
|
-
byteLength = Buffer.byteLength(data);
|
|
67123
|
-
readOnly = false;
|
|
67124
|
-
} else if (isBlob(data)) {
|
|
67125
|
-
byteLength = data.size;
|
|
67126
|
-
readOnly = false;
|
|
67127
|
-
} else {
|
|
67128
|
-
data = toBuffer(data);
|
|
67129
|
-
byteLength = data.length;
|
|
67130
|
-
readOnly = toBuffer.readOnly;
|
|
67131
|
-
}
|
|
67132
|
-
if (byteLength > 125) {
|
|
67133
|
-
throw new RangeError("The data size must not be greater than 125 bytes");
|
|
67134
|
-
}
|
|
67135
|
-
const options = {
|
|
67136
|
-
[kByteLength]: byteLength,
|
|
67137
|
-
fin: true,
|
|
67138
|
-
generateMask: this._generateMask,
|
|
67139
|
-
mask,
|
|
67140
|
-
maskBuffer: this._maskBuffer,
|
|
67141
|
-
opcode: 9,
|
|
67142
|
-
readOnly,
|
|
67143
|
-
rsv1: false
|
|
67144
|
-
};
|
|
67145
|
-
if (isBlob(data)) {
|
|
67146
|
-
if (this._state !== DEFAULT) {
|
|
67147
|
-
this.enqueue([this.getBlobData, data, false, options, cb]);
|
|
67148
|
-
} else {
|
|
67149
|
-
this.getBlobData(data, false, options, cb);
|
|
67150
|
-
}
|
|
67151
|
-
} else if (this._state !== DEFAULT) {
|
|
67152
|
-
this.enqueue([this.dispatch, data, false, options, cb]);
|
|
67153
|
-
} else {
|
|
67154
|
-
this.sendFrame(Sender.frame(data, options), cb);
|
|
67155
|
-
}
|
|
67156
|
-
}
|
|
67157
|
-
pong(data, mask, cb) {
|
|
67158
|
-
let byteLength;
|
|
67159
|
-
let readOnly;
|
|
67160
|
-
if (typeof data === "string") {
|
|
67161
|
-
byteLength = Buffer.byteLength(data);
|
|
67162
|
-
readOnly = false;
|
|
67163
|
-
} else if (isBlob(data)) {
|
|
67164
|
-
byteLength = data.size;
|
|
67165
|
-
readOnly = false;
|
|
67166
|
-
} else {
|
|
67167
|
-
data = toBuffer(data);
|
|
67168
|
-
byteLength = data.length;
|
|
67169
|
-
readOnly = toBuffer.readOnly;
|
|
67170
|
-
}
|
|
67171
|
-
if (byteLength > 125) {
|
|
67172
|
-
throw new RangeError("The data size must not be greater than 125 bytes");
|
|
67173
|
-
}
|
|
67174
|
-
const options = {
|
|
67175
|
-
[kByteLength]: byteLength,
|
|
67176
|
-
fin: true,
|
|
67177
|
-
generateMask: this._generateMask,
|
|
67178
|
-
mask,
|
|
67179
|
-
maskBuffer: this._maskBuffer,
|
|
67180
|
-
opcode: 10,
|
|
67181
|
-
readOnly,
|
|
67182
|
-
rsv1: false
|
|
67183
|
-
};
|
|
67184
|
-
if (isBlob(data)) {
|
|
67185
|
-
if (this._state !== DEFAULT) {
|
|
67186
|
-
this.enqueue([this.getBlobData, data, false, options, cb]);
|
|
67187
|
-
} else {
|
|
67188
|
-
this.getBlobData(data, false, options, cb);
|
|
67189
|
-
}
|
|
67190
|
-
} else if (this._state !== DEFAULT) {
|
|
67191
|
-
this.enqueue([this.dispatch, data, false, options, cb]);
|
|
67192
|
-
} else {
|
|
67193
|
-
this.sendFrame(Sender.frame(data, options), cb);
|
|
67194
|
-
}
|
|
67195
|
-
}
|
|
67196
|
-
send(data, options, cb) {
|
|
67197
|
-
const perMessageDeflate = this._extensions[PerMessageDeflate.extensionName];
|
|
67198
|
-
let opcode = options.binary ? 2 : 1;
|
|
67199
|
-
let rsv1 = options.compress;
|
|
67200
|
-
let byteLength;
|
|
67201
|
-
let readOnly;
|
|
67202
|
-
if (typeof data === "string") {
|
|
67203
|
-
byteLength = Buffer.byteLength(data);
|
|
67204
|
-
readOnly = false;
|
|
67205
|
-
} else if (isBlob(data)) {
|
|
67206
|
-
byteLength = data.size;
|
|
67207
|
-
readOnly = false;
|
|
67208
|
-
} else {
|
|
67209
|
-
data = toBuffer(data);
|
|
67210
|
-
byteLength = data.length;
|
|
67211
|
-
readOnly = toBuffer.readOnly;
|
|
67212
|
-
}
|
|
67213
|
-
if (this._firstFragment) {
|
|
67214
|
-
this._firstFragment = false;
|
|
67215
|
-
if (rsv1 && perMessageDeflate && perMessageDeflate.params[perMessageDeflate._isServer ? "server_no_context_takeover" : "client_no_context_takeover"]) {
|
|
67216
|
-
rsv1 = byteLength >= perMessageDeflate._threshold;
|
|
67217
|
-
}
|
|
67218
|
-
this._compress = rsv1;
|
|
67219
|
-
} else {
|
|
67220
|
-
rsv1 = false;
|
|
67221
|
-
opcode = 0;
|
|
67222
|
-
}
|
|
67223
|
-
if (options.fin)
|
|
67224
|
-
this._firstFragment = true;
|
|
67225
|
-
const opts = {
|
|
67226
|
-
[kByteLength]: byteLength,
|
|
67227
|
-
fin: options.fin,
|
|
67228
|
-
generateMask: this._generateMask,
|
|
67229
|
-
mask: options.mask,
|
|
67230
|
-
maskBuffer: this._maskBuffer,
|
|
67231
|
-
opcode,
|
|
67232
|
-
readOnly,
|
|
67233
|
-
rsv1
|
|
67234
|
-
};
|
|
67235
|
-
if (isBlob(data)) {
|
|
67236
|
-
if (this._state !== DEFAULT) {
|
|
67237
|
-
this.enqueue([this.getBlobData, data, this._compress, opts, cb]);
|
|
67238
|
-
} else {
|
|
67239
|
-
this.getBlobData(data, this._compress, opts, cb);
|
|
67240
|
-
}
|
|
67241
|
-
} else if (this._state !== DEFAULT) {
|
|
67242
|
-
this.enqueue([this.dispatch, data, this._compress, opts, cb]);
|
|
67243
|
-
} else {
|
|
67244
|
-
this.dispatch(data, this._compress, opts, cb);
|
|
67245
|
-
}
|
|
67246
|
-
}
|
|
67247
|
-
getBlobData(blob, compress, options, cb) {
|
|
67248
|
-
this._bufferedBytes += options[kByteLength];
|
|
67249
|
-
this._state = GET_BLOB_DATA;
|
|
67250
|
-
blob.arrayBuffer().then((arrayBuffer) => {
|
|
67251
|
-
if (this._socket.destroyed) {
|
|
67252
|
-
const err = new Error("The socket was closed while the blob was being read");
|
|
67253
|
-
process.nextTick(callCallbacks, this, err, cb);
|
|
67254
|
-
return;
|
|
67255
|
-
}
|
|
67256
|
-
this._bufferedBytes -= options[kByteLength];
|
|
67257
|
-
const data = toBuffer(arrayBuffer);
|
|
67258
|
-
if (!compress) {
|
|
67259
|
-
this._state = DEFAULT;
|
|
67260
|
-
this.sendFrame(Sender.frame(data, options), cb);
|
|
67261
|
-
this.dequeue();
|
|
67262
|
-
} else {
|
|
67263
|
-
this.dispatch(data, compress, options, cb);
|
|
67264
|
-
}
|
|
67265
|
-
}).catch((err) => {
|
|
67266
|
-
process.nextTick(onError, this, err, cb);
|
|
67267
|
-
});
|
|
67268
|
-
}
|
|
67269
|
-
dispatch(data, compress, options, cb) {
|
|
67270
|
-
if (!compress) {
|
|
67271
|
-
this.sendFrame(Sender.frame(data, options), cb);
|
|
67272
|
-
return;
|
|
67273
|
-
}
|
|
67274
|
-
const perMessageDeflate = this._extensions[PerMessageDeflate.extensionName];
|
|
67275
|
-
this._bufferedBytes += options[kByteLength];
|
|
67276
|
-
this._state = DEFLATING;
|
|
67277
|
-
perMessageDeflate.compress(data, options.fin, (_, buf) => {
|
|
67278
|
-
if (this._socket.destroyed) {
|
|
67279
|
-
const err = new Error("The socket was closed while data was being compressed");
|
|
67280
|
-
callCallbacks(this, err, cb);
|
|
67281
|
-
return;
|
|
67282
|
-
}
|
|
67283
|
-
this._bufferedBytes -= options[kByteLength];
|
|
67284
|
-
this._state = DEFAULT;
|
|
67285
|
-
options.readOnly = false;
|
|
67286
|
-
this.sendFrame(Sender.frame(buf, options), cb);
|
|
67287
|
-
this.dequeue();
|
|
67288
|
-
});
|
|
67289
|
-
}
|
|
67290
|
-
dequeue() {
|
|
67291
|
-
while (this._state === DEFAULT && this._queue.length) {
|
|
67292
|
-
const params = this._queue.shift();
|
|
67293
|
-
this._bufferedBytes -= params[3][kByteLength];
|
|
67294
|
-
Reflect.apply(params[0], this, params.slice(1));
|
|
67295
|
-
}
|
|
67296
|
-
}
|
|
67297
|
-
enqueue(params) {
|
|
67298
|
-
this._bufferedBytes += params[3][kByteLength];
|
|
67299
|
-
this._queue.push(params);
|
|
67300
|
-
}
|
|
67301
|
-
sendFrame(list, cb) {
|
|
67302
|
-
if (list.length === 2) {
|
|
67303
|
-
this._socket.cork();
|
|
67304
|
-
this._socket.write(list[0]);
|
|
67305
|
-
this._socket.write(list[1], cb);
|
|
67306
|
-
this._socket.uncork();
|
|
67307
|
-
} else {
|
|
67308
|
-
this._socket.write(list[0], cb);
|
|
67309
|
-
}
|
|
67310
|
-
}
|
|
67311
|
-
}
|
|
67312
|
-
module2.exports = Sender;
|
|
67313
|
-
function callCallbacks(sender, err, cb) {
|
|
67314
|
-
if (typeof cb === "function")
|
|
67315
|
-
cb(err);
|
|
67316
|
-
for (let i = 0;i < sender._queue.length; i++) {
|
|
67317
|
-
const params = sender._queue[i];
|
|
67318
|
-
const callback = params[params.length - 1];
|
|
67319
|
-
if (typeof callback === "function")
|
|
67320
|
-
callback(err);
|
|
67321
|
-
}
|
|
67322
|
-
}
|
|
67323
|
-
function onError(sender, err, cb) {
|
|
67324
|
-
callCallbacks(sender, err, cb);
|
|
67325
|
-
sender.onerror(err);
|
|
67326
|
-
}
|
|
67327
|
-
});
|
|
67328
|
-
|
|
67329
|
-
// node_modules/@discordjs/ws/node_modules/ws/lib/event-target.js
|
|
67330
|
-
var require_event_target = __commonJS(function(exports2, module2) {
|
|
67331
|
-
var { kForOnEventAttribute, kListener } = require_constants11();
|
|
67332
|
-
var kCode = Symbol("kCode");
|
|
67333
|
-
var kData = Symbol("kData");
|
|
67334
|
-
var kError = Symbol("kError");
|
|
67335
|
-
var kMessage = Symbol("kMessage");
|
|
67336
|
-
var kReason = Symbol("kReason");
|
|
67337
|
-
var kTarget = Symbol("kTarget");
|
|
67338
|
-
var kType = Symbol("kType");
|
|
67339
|
-
var kWasClean = Symbol("kWasClean");
|
|
67340
|
-
|
|
67341
|
-
class Event2 {
|
|
67342
|
-
constructor(type) {
|
|
67343
|
-
this[kTarget] = null;
|
|
67344
|
-
this[kType] = type;
|
|
67345
|
-
}
|
|
67346
|
-
get target() {
|
|
67347
|
-
return this[kTarget];
|
|
67348
|
-
}
|
|
67349
|
-
get type() {
|
|
67350
|
-
return this[kType];
|
|
67351
|
-
}
|
|
67352
|
-
}
|
|
67353
|
-
Object.defineProperty(Event2.prototype, "target", { enumerable: true });
|
|
67354
|
-
Object.defineProperty(Event2.prototype, "type", { enumerable: true });
|
|
67355
|
-
|
|
67356
|
-
class CloseEvent extends Event2 {
|
|
67357
|
-
constructor(type, options = {}) {
|
|
67358
|
-
super(type);
|
|
67359
|
-
this[kCode] = options.code === undefined ? 0 : options.code;
|
|
67360
|
-
this[kReason] = options.reason === undefined ? "" : options.reason;
|
|
67361
|
-
this[kWasClean] = options.wasClean === undefined ? false : options.wasClean;
|
|
67362
|
-
}
|
|
67363
|
-
get code() {
|
|
67364
|
-
return this[kCode];
|
|
67365
|
-
}
|
|
67366
|
-
get reason() {
|
|
67367
|
-
return this[kReason];
|
|
67368
|
-
}
|
|
67369
|
-
get wasClean() {
|
|
67370
|
-
return this[kWasClean];
|
|
67371
|
-
}
|
|
67372
|
-
}
|
|
67373
|
-
Object.defineProperty(CloseEvent.prototype, "code", { enumerable: true });
|
|
67374
|
-
Object.defineProperty(CloseEvent.prototype, "reason", { enumerable: true });
|
|
67375
|
-
Object.defineProperty(CloseEvent.prototype, "wasClean", { enumerable: true });
|
|
67376
|
-
|
|
67377
|
-
class ErrorEvent extends Event2 {
|
|
67378
|
-
constructor(type, options = {}) {
|
|
67379
|
-
super(type);
|
|
67380
|
-
this[kError] = options.error === undefined ? null : options.error;
|
|
67381
|
-
this[kMessage] = options.message === undefined ? "" : options.message;
|
|
67382
|
-
}
|
|
67383
|
-
get error() {
|
|
67384
|
-
return this[kError];
|
|
67385
|
-
}
|
|
67386
|
-
get message() {
|
|
67387
|
-
return this[kMessage];
|
|
67388
|
-
}
|
|
67389
|
-
}
|
|
67390
|
-
Object.defineProperty(ErrorEvent.prototype, "error", { enumerable: true });
|
|
67391
|
-
Object.defineProperty(ErrorEvent.prototype, "message", { enumerable: true });
|
|
67392
|
-
|
|
67393
|
-
class MessageEvent extends Event2 {
|
|
67394
|
-
constructor(type, options = {}) {
|
|
67395
|
-
super(type);
|
|
67396
|
-
this[kData] = options.data === undefined ? null : options.data;
|
|
67397
|
-
}
|
|
67398
|
-
get data() {
|
|
67399
|
-
return this[kData];
|
|
67400
|
-
}
|
|
67401
|
-
}
|
|
67402
|
-
Object.defineProperty(MessageEvent.prototype, "data", { enumerable: true });
|
|
67403
|
-
var EventTarget2 = {
|
|
67404
|
-
addEventListener(type, handler, options = {}) {
|
|
67405
|
-
for (const listener of this.listeners(type)) {
|
|
67406
|
-
if (!options[kForOnEventAttribute] && listener[kListener] === handler && !listener[kForOnEventAttribute]) {
|
|
67407
|
-
return;
|
|
67408
|
-
}
|
|
67409
|
-
}
|
|
67410
|
-
let wrapper;
|
|
67411
|
-
if (type === "message") {
|
|
67412
|
-
wrapper = function onMessage(data, isBinary) {
|
|
67413
|
-
const event = new MessageEvent("message", {
|
|
67414
|
-
data: isBinary ? data : data.toString()
|
|
67415
|
-
});
|
|
67416
|
-
event[kTarget] = this;
|
|
67417
|
-
callListener(handler, this, event);
|
|
67418
|
-
};
|
|
67419
|
-
} else if (type === "close") {
|
|
67420
|
-
wrapper = function onClose(code, message) {
|
|
67421
|
-
const event = new CloseEvent("close", {
|
|
67422
|
-
code,
|
|
67423
|
-
reason: message.toString(),
|
|
67424
|
-
wasClean: this._closeFrameReceived && this._closeFrameSent
|
|
67425
|
-
});
|
|
67426
|
-
event[kTarget] = this;
|
|
67427
|
-
callListener(handler, this, event);
|
|
67428
|
-
};
|
|
67429
|
-
} else if (type === "error") {
|
|
67430
|
-
wrapper = function onError(error) {
|
|
67431
|
-
const event = new ErrorEvent("error", {
|
|
67432
|
-
error,
|
|
67433
|
-
message: error.message
|
|
67434
|
-
});
|
|
67435
|
-
event[kTarget] = this;
|
|
67436
|
-
callListener(handler, this, event);
|
|
67437
|
-
};
|
|
67438
|
-
} else if (type === "open") {
|
|
67439
|
-
wrapper = function onOpen() {
|
|
67440
|
-
const event = new Event2("open");
|
|
67441
|
-
event[kTarget] = this;
|
|
67442
|
-
callListener(handler, this, event);
|
|
67443
|
-
};
|
|
67444
|
-
} else {
|
|
67445
|
-
return;
|
|
67446
|
-
}
|
|
67447
|
-
wrapper[kForOnEventAttribute] = !!options[kForOnEventAttribute];
|
|
67448
|
-
wrapper[kListener] = handler;
|
|
67449
|
-
if (options.once) {
|
|
67450
|
-
this.once(type, wrapper);
|
|
67451
|
-
} else {
|
|
67452
|
-
this.on(type, wrapper);
|
|
67453
|
-
}
|
|
67454
|
-
},
|
|
67455
|
-
removeEventListener(type, handler) {
|
|
67456
|
-
for (const listener of this.listeners(type)) {
|
|
67457
|
-
if (listener[kListener] === handler && !listener[kForOnEventAttribute]) {
|
|
67458
|
-
this.removeListener(type, listener);
|
|
67459
|
-
break;
|
|
67460
|
-
}
|
|
67461
|
-
}
|
|
67462
|
-
}
|
|
67463
|
-
};
|
|
67464
|
-
module2.exports = {
|
|
67465
|
-
CloseEvent,
|
|
67466
|
-
ErrorEvent,
|
|
67467
|
-
Event: Event2,
|
|
67468
|
-
EventTarget: EventTarget2,
|
|
67469
|
-
MessageEvent
|
|
67470
|
-
};
|
|
67471
|
-
function callListener(listener, thisArg, event) {
|
|
67472
|
-
if (typeof listener === "object" && listener.handleEvent) {
|
|
67473
|
-
listener.handleEvent.call(listener, event);
|
|
67474
|
-
} else {
|
|
67475
|
-
listener.call(thisArg, event);
|
|
67476
|
-
}
|
|
67477
|
-
}
|
|
67478
|
-
});
|
|
67479
|
-
|
|
67480
|
-
// node_modules/@discordjs/ws/node_modules/ws/lib/extension.js
|
|
67481
|
-
var require_extension = __commonJS(function(exports2, module2) {
|
|
67482
|
-
var { tokenChars } = require_validation();
|
|
67483
|
-
function push(dest, name, elem) {
|
|
67484
|
-
if (dest[name] === undefined)
|
|
67485
|
-
dest[name] = [elem];
|
|
67486
|
-
else
|
|
67487
|
-
dest[name].push(elem);
|
|
67488
|
-
}
|
|
67489
|
-
function parse(header) {
|
|
67490
|
-
const offers = Object.create(null);
|
|
67491
|
-
let params = Object.create(null);
|
|
67492
|
-
let mustUnescape = false;
|
|
67493
|
-
let isEscaping = false;
|
|
67494
|
-
let inQuotes = false;
|
|
67495
|
-
let extensionName;
|
|
67496
|
-
let paramName;
|
|
67497
|
-
let start = -1;
|
|
67498
|
-
let code = -1;
|
|
67499
|
-
let end = -1;
|
|
67500
|
-
let i = 0;
|
|
67501
|
-
for (;i < header.length; i++) {
|
|
67502
|
-
code = header.charCodeAt(i);
|
|
67503
|
-
if (extensionName === undefined) {
|
|
67504
|
-
if (end === -1 && tokenChars[code] === 1) {
|
|
67505
|
-
if (start === -1)
|
|
67506
|
-
start = i;
|
|
67507
|
-
} else if (i !== 0 && (code === 32 || code === 9)) {
|
|
67508
|
-
if (end === -1 && start !== -1)
|
|
67509
|
-
end = i;
|
|
67510
|
-
} else if (code === 59 || code === 44) {
|
|
67511
|
-
if (start === -1) {
|
|
67512
|
-
throw new SyntaxError(`Unexpected character at index ${i}`);
|
|
67513
|
-
}
|
|
67514
|
-
if (end === -1)
|
|
67515
|
-
end = i;
|
|
67516
|
-
const name = header.slice(start, end);
|
|
67517
|
-
if (code === 44) {
|
|
67518
|
-
push(offers, name, params);
|
|
67519
|
-
params = Object.create(null);
|
|
67520
|
-
} else {
|
|
67521
|
-
extensionName = name;
|
|
67522
|
-
}
|
|
67523
|
-
start = end = -1;
|
|
67524
|
-
} else {
|
|
67525
|
-
throw new SyntaxError(`Unexpected character at index ${i}`);
|
|
67526
|
-
}
|
|
67527
|
-
} else if (paramName === undefined) {
|
|
67528
|
-
if (end === -1 && tokenChars[code] === 1) {
|
|
67529
|
-
if (start === -1)
|
|
67530
|
-
start = i;
|
|
67531
|
-
} else if (code === 32 || code === 9) {
|
|
67532
|
-
if (end === -1 && start !== -1)
|
|
67533
|
-
end = i;
|
|
67534
|
-
} else if (code === 59 || code === 44) {
|
|
67535
|
-
if (start === -1) {
|
|
67536
|
-
throw new SyntaxError(`Unexpected character at index ${i}`);
|
|
67537
|
-
}
|
|
67538
|
-
if (end === -1)
|
|
67539
|
-
end = i;
|
|
67540
|
-
push(params, header.slice(start, end), true);
|
|
67541
|
-
if (code === 44) {
|
|
67542
|
-
push(offers, extensionName, params);
|
|
67543
|
-
params = Object.create(null);
|
|
67544
|
-
extensionName = undefined;
|
|
67545
|
-
}
|
|
67546
|
-
start = end = -1;
|
|
67547
|
-
} else if (code === 61 && start !== -1 && end === -1) {
|
|
67548
|
-
paramName = header.slice(start, i);
|
|
67549
|
-
start = end = -1;
|
|
67550
|
-
} else {
|
|
67551
|
-
throw new SyntaxError(`Unexpected character at index ${i}`);
|
|
67552
|
-
}
|
|
67553
|
-
} else {
|
|
67554
|
-
if (isEscaping) {
|
|
67555
|
-
if (tokenChars[code] !== 1) {
|
|
67556
|
-
throw new SyntaxError(`Unexpected character at index ${i}`);
|
|
67557
|
-
}
|
|
67558
|
-
if (start === -1)
|
|
67559
|
-
start = i;
|
|
67560
|
-
else if (!mustUnescape)
|
|
67561
|
-
mustUnescape = true;
|
|
67562
|
-
isEscaping = false;
|
|
67563
|
-
} else if (inQuotes) {
|
|
67564
|
-
if (tokenChars[code] === 1) {
|
|
67565
|
-
if (start === -1)
|
|
67566
|
-
start = i;
|
|
67567
|
-
} else if (code === 34 && start !== -1) {
|
|
67568
|
-
inQuotes = false;
|
|
67569
|
-
end = i;
|
|
67570
|
-
} else if (code === 92) {
|
|
67571
|
-
isEscaping = true;
|
|
67572
|
-
} else {
|
|
67573
|
-
throw new SyntaxError(`Unexpected character at index ${i}`);
|
|
67574
|
-
}
|
|
67575
|
-
} else if (code === 34 && header.charCodeAt(i - 1) === 61) {
|
|
67576
|
-
inQuotes = true;
|
|
67577
|
-
} else if (end === -1 && tokenChars[code] === 1) {
|
|
67578
|
-
if (start === -1)
|
|
67579
|
-
start = i;
|
|
67580
|
-
} else if (start !== -1 && (code === 32 || code === 9)) {
|
|
67581
|
-
if (end === -1)
|
|
67582
|
-
end = i;
|
|
67583
|
-
} else if (code === 59 || code === 44) {
|
|
67584
|
-
if (start === -1) {
|
|
67585
|
-
throw new SyntaxError(`Unexpected character at index ${i}`);
|
|
67586
|
-
}
|
|
67587
|
-
if (end === -1)
|
|
67588
|
-
end = i;
|
|
67589
|
-
let value = header.slice(start, end);
|
|
67590
|
-
if (mustUnescape) {
|
|
67591
|
-
value = value.replace(/\\/g, "");
|
|
67592
|
-
mustUnescape = false;
|
|
67593
|
-
}
|
|
67594
|
-
push(params, paramName, value);
|
|
67595
|
-
if (code === 44) {
|
|
67596
|
-
push(offers, extensionName, params);
|
|
67597
|
-
params = Object.create(null);
|
|
67598
|
-
extensionName = undefined;
|
|
67599
|
-
}
|
|
67600
|
-
paramName = undefined;
|
|
67601
|
-
start = end = -1;
|
|
67602
|
-
} else {
|
|
67603
|
-
throw new SyntaxError(`Unexpected character at index ${i}`);
|
|
67604
|
-
}
|
|
67605
|
-
}
|
|
67606
|
-
}
|
|
67607
|
-
if (start === -1 || inQuotes || code === 32 || code === 9) {
|
|
67608
|
-
throw new SyntaxError("Unexpected end of input");
|
|
67609
|
-
}
|
|
67610
|
-
if (end === -1)
|
|
67611
|
-
end = i;
|
|
67612
|
-
const token = header.slice(start, end);
|
|
67613
|
-
if (extensionName === undefined) {
|
|
67614
|
-
push(offers, token, params);
|
|
67615
|
-
} else {
|
|
67616
|
-
if (paramName === undefined) {
|
|
67617
|
-
push(params, token, true);
|
|
67618
|
-
} else if (mustUnescape) {
|
|
67619
|
-
push(params, paramName, token.replace(/\\/g, ""));
|
|
67620
|
-
} else {
|
|
67621
|
-
push(params, paramName, token);
|
|
67622
|
-
}
|
|
67623
|
-
push(offers, extensionName, params);
|
|
67624
|
-
}
|
|
67625
|
-
return offers;
|
|
67626
|
-
}
|
|
67627
|
-
function format(extensions) {
|
|
67628
|
-
return Object.keys(extensions).map((extension) => {
|
|
67629
|
-
let configurations = extensions[extension];
|
|
67630
|
-
if (!Array.isArray(configurations))
|
|
67631
|
-
configurations = [configurations];
|
|
67632
|
-
return configurations.map((params) => {
|
|
67633
|
-
return [extension].concat(Object.keys(params).map((k) => {
|
|
67634
|
-
let values = params[k];
|
|
67635
|
-
if (!Array.isArray(values))
|
|
67636
|
-
values = [values];
|
|
67637
|
-
return values.map((v) => v === true ? k : `${k}=${v}`).join("; ");
|
|
67638
|
-
})).join("; ");
|
|
67639
|
-
}).join(", ");
|
|
67640
|
-
}).join(", ");
|
|
67641
|
-
}
|
|
67642
|
-
module2.exports = { format, parse };
|
|
67643
|
-
});
|
|
67644
|
-
|
|
67645
|
-
// node_modules/@discordjs/ws/node_modules/ws/lib/websocket.js
|
|
67646
|
-
var require_websocket3 = __commonJS(function(exports2, module2) {
|
|
67647
|
-
var EventEmitter = __require("events");
|
|
67648
|
-
var https = __require("https");
|
|
67649
|
-
var http = __require("http");
|
|
67650
|
-
var net = __require("net");
|
|
67651
|
-
var tls = __require("tls");
|
|
67652
|
-
var { randomBytes, createHash } = __require("crypto");
|
|
67653
|
-
var { Duplex, Readable } = __require("stream");
|
|
67654
|
-
var { URL: URL2 } = __require("url");
|
|
67655
|
-
var PerMessageDeflate = require_permessage_deflate3();
|
|
67656
|
-
var Receiver = require_receiver3();
|
|
67657
|
-
var Sender = require_sender3();
|
|
67658
|
-
var { isBlob } = require_validation();
|
|
67659
|
-
var {
|
|
67660
|
-
BINARY_TYPES,
|
|
67661
|
-
CLOSE_TIMEOUT,
|
|
67662
|
-
EMPTY_BUFFER,
|
|
67663
|
-
GUID,
|
|
67664
|
-
kForOnEventAttribute,
|
|
67665
|
-
kListener,
|
|
67666
|
-
kStatusCode,
|
|
67667
|
-
kWebSocket,
|
|
67668
|
-
NOOP
|
|
67669
|
-
} = require_constants11();
|
|
67670
|
-
var {
|
|
67671
|
-
EventTarget: { addEventListener, removeEventListener }
|
|
67672
|
-
} = require_event_target();
|
|
67673
|
-
var { format, parse } = require_extension();
|
|
67674
|
-
var { toBuffer } = require_buffer_util();
|
|
67675
|
-
var kAborted = Symbol("kAborted");
|
|
67676
|
-
var protocolVersions = [8, 13];
|
|
67677
|
-
var readyStates = ["CONNECTING", "OPEN", "CLOSING", "CLOSED"];
|
|
67678
|
-
var subprotocolRegex = /^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;
|
|
67679
|
-
|
|
67680
|
-
class WebSocket extends EventEmitter {
|
|
67681
|
-
constructor(address, protocols, options) {
|
|
67682
|
-
super();
|
|
67683
|
-
this._binaryType = BINARY_TYPES[0];
|
|
67684
|
-
this._closeCode = 1006;
|
|
67685
|
-
this._closeFrameReceived = false;
|
|
67686
|
-
this._closeFrameSent = false;
|
|
67687
|
-
this._closeMessage = EMPTY_BUFFER;
|
|
67688
|
-
this._closeTimer = null;
|
|
67689
|
-
this._errorEmitted = false;
|
|
67690
|
-
this._extensions = {};
|
|
67691
|
-
this._paused = false;
|
|
67692
|
-
this._protocol = "";
|
|
67693
|
-
this._readyState = WebSocket.CONNECTING;
|
|
67694
|
-
this._receiver = null;
|
|
67695
|
-
this._sender = null;
|
|
67696
|
-
this._socket = null;
|
|
67697
|
-
if (address !== null) {
|
|
67698
|
-
this._bufferedAmount = 0;
|
|
67699
|
-
this._isServer = false;
|
|
67700
|
-
this._redirects = 0;
|
|
67701
|
-
if (protocols === undefined) {
|
|
67702
|
-
if (!options || options.protocols === undefined) {
|
|
67703
|
-
protocols = [];
|
|
67704
|
-
} else if (Array.isArray(options.protocols)) {
|
|
67705
|
-
protocols = options.protocols;
|
|
67706
|
-
} else {
|
|
67707
|
-
protocols = [options.protocols];
|
|
67708
|
-
}
|
|
67709
|
-
} else if (!Array.isArray(protocols)) {
|
|
67710
|
-
if (typeof protocols === "object" && protocols !== null) {
|
|
67711
|
-
options = protocols;
|
|
67712
|
-
if (options.protocols === undefined) {
|
|
67713
|
-
protocols = [];
|
|
67714
|
-
} else if (Array.isArray(options.protocols)) {
|
|
67715
|
-
protocols = options.protocols;
|
|
67716
|
-
} else {
|
|
67717
|
-
protocols = [options.protocols];
|
|
67718
|
-
}
|
|
67719
|
-
} else {
|
|
67720
|
-
protocols = [protocols];
|
|
67721
|
-
}
|
|
67722
|
-
}
|
|
67723
|
-
initAsClient(this, address, protocols, options);
|
|
67724
|
-
} else {
|
|
67725
|
-
this._autoPong = options.autoPong;
|
|
67726
|
-
this._closeTimeout = options.closeTimeout;
|
|
67727
|
-
this._isServer = true;
|
|
67728
|
-
}
|
|
67729
|
-
}
|
|
67730
|
-
get binaryType() {
|
|
67731
|
-
return this._binaryType;
|
|
67732
|
-
}
|
|
67733
|
-
set binaryType(type) {
|
|
67734
|
-
if (!BINARY_TYPES.includes(type))
|
|
67735
|
-
return;
|
|
67736
|
-
this._binaryType = type;
|
|
67737
|
-
if (this._receiver)
|
|
67738
|
-
this._receiver._binaryType = type;
|
|
67739
|
-
}
|
|
67740
|
-
get bufferedAmount() {
|
|
67741
|
-
if (!this._socket)
|
|
67742
|
-
return this._bufferedAmount;
|
|
67743
|
-
return this._socket._writableState.length + this._sender._bufferedBytes;
|
|
67744
|
-
}
|
|
67745
|
-
get extensions() {
|
|
67746
|
-
return Object.keys(this._extensions).join();
|
|
67747
|
-
}
|
|
67748
|
-
get isPaused() {
|
|
67749
|
-
return this._paused;
|
|
67750
|
-
}
|
|
67751
|
-
get onclose() {
|
|
67752
|
-
return null;
|
|
67753
|
-
}
|
|
67754
|
-
get onerror() {
|
|
67755
|
-
return null;
|
|
67756
|
-
}
|
|
67757
|
-
get onopen() {
|
|
67758
|
-
return null;
|
|
67759
|
-
}
|
|
67760
|
-
get onmessage() {
|
|
67761
|
-
return null;
|
|
67762
|
-
}
|
|
67763
|
-
get protocol() {
|
|
67764
|
-
return this._protocol;
|
|
67765
|
-
}
|
|
67766
|
-
get readyState() {
|
|
67767
|
-
return this._readyState;
|
|
67768
|
-
}
|
|
67769
|
-
get url() {
|
|
67770
|
-
return this._url;
|
|
67771
|
-
}
|
|
67772
|
-
setSocket(socket, head, options) {
|
|
67773
|
-
const receiver = new Receiver({
|
|
67774
|
-
allowSynchronousEvents: options.allowSynchronousEvents,
|
|
67775
|
-
binaryType: this.binaryType,
|
|
67776
|
-
extensions: this._extensions,
|
|
67777
|
-
isServer: this._isServer,
|
|
67778
|
-
maxBufferedChunks: options.maxBufferedChunks,
|
|
67779
|
-
maxFragments: options.maxFragments,
|
|
67780
|
-
maxPayload: options.maxPayload,
|
|
67781
|
-
skipUTF8Validation: options.skipUTF8Validation
|
|
67782
|
-
});
|
|
67783
|
-
const sender = new Sender(socket, this._extensions, options.generateMask);
|
|
67784
|
-
this._receiver = receiver;
|
|
67785
|
-
this._sender = sender;
|
|
67786
|
-
this._socket = socket;
|
|
67787
|
-
receiver[kWebSocket] = this;
|
|
67788
|
-
sender[kWebSocket] = this;
|
|
67789
|
-
socket[kWebSocket] = this;
|
|
67790
|
-
receiver.on("conclude", receiverOnConclude);
|
|
67791
|
-
receiver.on("drain", receiverOnDrain);
|
|
67792
|
-
receiver.on("error", receiverOnError);
|
|
67793
|
-
receiver.on("message", receiverOnMessage);
|
|
67794
|
-
receiver.on("ping", receiverOnPing);
|
|
67795
|
-
receiver.on("pong", receiverOnPong);
|
|
67796
|
-
sender.onerror = senderOnError;
|
|
67797
|
-
if (socket.setTimeout)
|
|
67798
|
-
socket.setTimeout(0);
|
|
67799
|
-
if (socket.setNoDelay)
|
|
67800
|
-
socket.setNoDelay();
|
|
67801
|
-
if (head.length > 0)
|
|
67802
|
-
socket.unshift(head);
|
|
67803
|
-
socket.on("close", socketOnClose);
|
|
67804
|
-
socket.on("data", socketOnData);
|
|
67805
|
-
socket.on("end", socketOnEnd);
|
|
67806
|
-
socket.on("error", socketOnError);
|
|
67807
|
-
this._readyState = WebSocket.OPEN;
|
|
67808
|
-
this.emit("open");
|
|
67809
|
-
}
|
|
67810
|
-
emitClose() {
|
|
67811
|
-
if (!this._socket) {
|
|
67812
|
-
this._readyState = WebSocket.CLOSED;
|
|
67813
|
-
this.emit("close", this._closeCode, this._closeMessage);
|
|
67814
|
-
return;
|
|
67815
|
-
}
|
|
67816
|
-
if (this._extensions[PerMessageDeflate.extensionName]) {
|
|
67817
|
-
this._extensions[PerMessageDeflate.extensionName].cleanup();
|
|
67818
|
-
}
|
|
67819
|
-
this._receiver.removeAllListeners();
|
|
67820
|
-
this._readyState = WebSocket.CLOSED;
|
|
67821
|
-
this.emit("close", this._closeCode, this._closeMessage);
|
|
67822
|
-
}
|
|
67823
|
-
close(code, data) {
|
|
67824
|
-
if (this.readyState === WebSocket.CLOSED)
|
|
67825
|
-
return;
|
|
67826
|
-
if (this.readyState === WebSocket.CONNECTING) {
|
|
67827
|
-
const msg = "WebSocket was closed before the connection was established";
|
|
67828
|
-
abortHandshake(this, this._req, msg);
|
|
67829
|
-
return;
|
|
67830
|
-
}
|
|
67831
|
-
if (this.readyState === WebSocket.CLOSING) {
|
|
67832
|
-
if (this._closeFrameSent && (this._closeFrameReceived || this._receiver._writableState.errorEmitted)) {
|
|
67833
|
-
this._socket.end();
|
|
67834
|
-
}
|
|
67835
|
-
return;
|
|
67836
|
-
}
|
|
67837
|
-
this._sender.close(code, data, !this._isServer, (err) => {
|
|
67838
|
-
if (err)
|
|
67839
|
-
return;
|
|
67840
|
-
this._closeFrameSent = true;
|
|
67841
|
-
if (this._closeFrameReceived || this._receiver._writableState.errorEmitted) {
|
|
67842
|
-
this._socket.end();
|
|
67843
|
-
}
|
|
67844
|
-
});
|
|
67845
|
-
this._readyState = WebSocket.CLOSING;
|
|
67846
|
-
setCloseTimer(this);
|
|
67847
|
-
}
|
|
67848
|
-
pause() {
|
|
67849
|
-
if (this.readyState === WebSocket.CONNECTING || this.readyState === WebSocket.CLOSED) {
|
|
67850
|
-
return;
|
|
67851
|
-
}
|
|
67852
|
-
this._paused = true;
|
|
67853
|
-
this._socket.pause();
|
|
67854
|
-
}
|
|
67855
|
-
ping(data, mask, cb) {
|
|
67856
|
-
if (this.readyState === WebSocket.CONNECTING) {
|
|
67857
|
-
throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");
|
|
67858
|
-
}
|
|
67859
|
-
if (typeof data === "function") {
|
|
67860
|
-
cb = data;
|
|
67861
|
-
data = mask = undefined;
|
|
67862
|
-
} else if (typeof mask === "function") {
|
|
67863
|
-
cb = mask;
|
|
67864
|
-
mask = undefined;
|
|
67865
|
-
}
|
|
67866
|
-
if (typeof data === "number")
|
|
67867
|
-
data = data.toString();
|
|
67868
|
-
if (this.readyState !== WebSocket.OPEN) {
|
|
67869
|
-
sendAfterClose(this, data, cb);
|
|
67870
|
-
return;
|
|
67871
|
-
}
|
|
67872
|
-
if (mask === undefined)
|
|
67873
|
-
mask = !this._isServer;
|
|
67874
|
-
this._sender.ping(data || EMPTY_BUFFER, mask, cb);
|
|
67875
|
-
}
|
|
67876
|
-
pong(data, mask, cb) {
|
|
67877
|
-
if (this.readyState === WebSocket.CONNECTING) {
|
|
67878
|
-
throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");
|
|
67879
|
-
}
|
|
67880
|
-
if (typeof data === "function") {
|
|
67881
|
-
cb = data;
|
|
67882
|
-
data = mask = undefined;
|
|
67883
|
-
} else if (typeof mask === "function") {
|
|
67884
|
-
cb = mask;
|
|
67885
|
-
mask = undefined;
|
|
67886
|
-
}
|
|
67887
|
-
if (typeof data === "number")
|
|
67888
|
-
data = data.toString();
|
|
67889
|
-
if (this.readyState !== WebSocket.OPEN) {
|
|
67890
|
-
sendAfterClose(this, data, cb);
|
|
67891
|
-
return;
|
|
67892
|
-
}
|
|
67893
|
-
if (mask === undefined)
|
|
67894
|
-
mask = !this._isServer;
|
|
67895
|
-
this._sender.pong(data || EMPTY_BUFFER, mask, cb);
|
|
67896
|
-
}
|
|
67897
|
-
resume() {
|
|
67898
|
-
if (this.readyState === WebSocket.CONNECTING || this.readyState === WebSocket.CLOSED) {
|
|
67899
|
-
return;
|
|
67900
|
-
}
|
|
67901
|
-
this._paused = false;
|
|
67902
|
-
if (!this._receiver._writableState.needDrain)
|
|
67903
|
-
this._socket.resume();
|
|
67904
|
-
}
|
|
67905
|
-
send(data, options, cb) {
|
|
67906
|
-
if (this.readyState === WebSocket.CONNECTING) {
|
|
67907
|
-
throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");
|
|
67908
|
-
}
|
|
67909
|
-
if (typeof options === "function") {
|
|
67910
|
-
cb = options;
|
|
67911
|
-
options = {};
|
|
67912
|
-
}
|
|
67913
|
-
if (typeof data === "number")
|
|
67914
|
-
data = data.toString();
|
|
67915
|
-
if (this.readyState !== WebSocket.OPEN) {
|
|
67916
|
-
sendAfterClose(this, data, cb);
|
|
67917
|
-
return;
|
|
67918
|
-
}
|
|
67919
|
-
const opts = {
|
|
67920
|
-
binary: typeof data !== "string",
|
|
67921
|
-
mask: !this._isServer,
|
|
67922
|
-
compress: true,
|
|
67923
|
-
fin: true,
|
|
67924
|
-
...options
|
|
67925
|
-
};
|
|
67926
|
-
if (!this._extensions[PerMessageDeflate.extensionName]) {
|
|
67927
|
-
opts.compress = false;
|
|
67928
|
-
}
|
|
67929
|
-
this._sender.send(data || EMPTY_BUFFER, opts, cb);
|
|
67930
|
-
}
|
|
67931
|
-
terminate() {
|
|
67932
|
-
if (this.readyState === WebSocket.CLOSED)
|
|
67933
|
-
return;
|
|
67934
|
-
if (this.readyState === WebSocket.CONNECTING) {
|
|
67935
|
-
const msg = "WebSocket was closed before the connection was established";
|
|
67936
|
-
abortHandshake(this, this._req, msg);
|
|
67937
|
-
return;
|
|
67938
|
-
}
|
|
67939
|
-
if (this._socket) {
|
|
67940
|
-
this._readyState = WebSocket.CLOSING;
|
|
67941
|
-
this._socket.destroy();
|
|
67942
|
-
}
|
|
67943
|
-
}
|
|
67944
|
-
}
|
|
67945
|
-
Object.defineProperty(WebSocket, "CONNECTING", {
|
|
67946
|
-
enumerable: true,
|
|
67947
|
-
value: readyStates.indexOf("CONNECTING")
|
|
67948
|
-
});
|
|
67949
|
-
Object.defineProperty(WebSocket.prototype, "CONNECTING", {
|
|
67950
|
-
enumerable: true,
|
|
67951
|
-
value: readyStates.indexOf("CONNECTING")
|
|
67952
|
-
});
|
|
67953
|
-
Object.defineProperty(WebSocket, "OPEN", {
|
|
67954
|
-
enumerable: true,
|
|
67955
|
-
value: readyStates.indexOf("OPEN")
|
|
67956
|
-
});
|
|
67957
|
-
Object.defineProperty(WebSocket.prototype, "OPEN", {
|
|
67958
|
-
enumerable: true,
|
|
67959
|
-
value: readyStates.indexOf("OPEN")
|
|
67960
|
-
});
|
|
67961
|
-
Object.defineProperty(WebSocket, "CLOSING", {
|
|
67962
|
-
enumerable: true,
|
|
67963
|
-
value: readyStates.indexOf("CLOSING")
|
|
67964
|
-
});
|
|
67965
|
-
Object.defineProperty(WebSocket.prototype, "CLOSING", {
|
|
67966
|
-
enumerable: true,
|
|
67967
|
-
value: readyStates.indexOf("CLOSING")
|
|
67968
|
-
});
|
|
67969
|
-
Object.defineProperty(WebSocket, "CLOSED", {
|
|
67970
|
-
enumerable: true,
|
|
67971
|
-
value: readyStates.indexOf("CLOSED")
|
|
67972
|
-
});
|
|
67973
|
-
Object.defineProperty(WebSocket.prototype, "CLOSED", {
|
|
67974
|
-
enumerable: true,
|
|
67975
|
-
value: readyStates.indexOf("CLOSED")
|
|
67976
|
-
});
|
|
67977
|
-
[
|
|
67978
|
-
"binaryType",
|
|
67979
|
-
"bufferedAmount",
|
|
67980
|
-
"extensions",
|
|
67981
|
-
"isPaused",
|
|
67982
|
-
"protocol",
|
|
67983
|
-
"readyState",
|
|
67984
|
-
"url"
|
|
67985
|
-
].forEach((property) => {
|
|
67986
|
-
Object.defineProperty(WebSocket.prototype, property, { enumerable: true });
|
|
67987
|
-
});
|
|
67988
|
-
["open", "error", "close", "message"].forEach((method) => {
|
|
67989
|
-
Object.defineProperty(WebSocket.prototype, `on${method}`, {
|
|
67990
|
-
enumerable: true,
|
|
67991
|
-
get() {
|
|
67992
|
-
for (const listener of this.listeners(method)) {
|
|
67993
|
-
if (listener[kForOnEventAttribute])
|
|
67994
|
-
return listener[kListener];
|
|
67995
|
-
}
|
|
67996
|
-
return null;
|
|
67997
|
-
},
|
|
67998
|
-
set(handler) {
|
|
67999
|
-
for (const listener of this.listeners(method)) {
|
|
68000
|
-
if (listener[kForOnEventAttribute]) {
|
|
68001
|
-
this.removeListener(method, listener);
|
|
68002
|
-
break;
|
|
68003
|
-
}
|
|
68004
|
-
}
|
|
68005
|
-
if (typeof handler !== "function")
|
|
68006
|
-
return;
|
|
68007
|
-
this.addEventListener(method, handler, {
|
|
68008
|
-
[kForOnEventAttribute]: true
|
|
68009
|
-
});
|
|
68010
|
-
}
|
|
68011
|
-
});
|
|
68012
|
-
});
|
|
68013
|
-
WebSocket.prototype.addEventListener = addEventListener;
|
|
68014
|
-
WebSocket.prototype.removeEventListener = removeEventListener;
|
|
68015
|
-
module2.exports = WebSocket;
|
|
68016
|
-
function initAsClient(websocket, address, protocols, options) {
|
|
68017
|
-
const opts = {
|
|
68018
|
-
allowSynchronousEvents: true,
|
|
68019
|
-
autoPong: true,
|
|
68020
|
-
closeTimeout: CLOSE_TIMEOUT,
|
|
68021
|
-
protocolVersion: protocolVersions[1],
|
|
68022
|
-
maxBufferedChunks: 256 * 1024,
|
|
68023
|
-
maxFragments: 16 * 1024,
|
|
68024
|
-
maxPayload: 100 * 1024 * 1024,
|
|
68025
|
-
skipUTF8Validation: false,
|
|
68026
|
-
perMessageDeflate: true,
|
|
68027
|
-
followRedirects: false,
|
|
68028
|
-
maxRedirects: 10,
|
|
68029
|
-
...options,
|
|
68030
|
-
socketPath: undefined,
|
|
68031
|
-
hostname: undefined,
|
|
68032
|
-
protocol: undefined,
|
|
68033
|
-
protocols: undefined,
|
|
68034
|
-
timeout: undefined,
|
|
68035
|
-
method: "GET",
|
|
68036
|
-
host: undefined,
|
|
68037
|
-
path: undefined,
|
|
68038
|
-
port: undefined
|
|
68039
|
-
};
|
|
68040
|
-
websocket._autoPong = opts.autoPong;
|
|
68041
|
-
websocket._closeTimeout = opts.closeTimeout;
|
|
68042
|
-
if (!protocolVersions.includes(opts.protocolVersion)) {
|
|
68043
|
-
throw new RangeError(`Unsupported protocol version: ${opts.protocolVersion} ` + `(supported versions: ${protocolVersions.join(", ")})`);
|
|
68044
|
-
}
|
|
68045
|
-
let parsedUrl;
|
|
68046
|
-
if (address instanceof URL2) {
|
|
68047
|
-
parsedUrl = address;
|
|
68048
|
-
} else {
|
|
68049
|
-
try {
|
|
68050
|
-
parsedUrl = new URL2(address);
|
|
68051
|
-
} catch {
|
|
68052
|
-
throw new SyntaxError(`Invalid URL: ${address}`);
|
|
68053
|
-
}
|
|
68054
|
-
}
|
|
68055
|
-
if (parsedUrl.protocol === "http:") {
|
|
68056
|
-
parsedUrl.protocol = "ws:";
|
|
68057
|
-
} else if (parsedUrl.protocol === "https:") {
|
|
68058
|
-
parsedUrl.protocol = "wss:";
|
|
68059
|
-
}
|
|
68060
|
-
websocket._url = parsedUrl.href;
|
|
68061
|
-
const isSecure = parsedUrl.protocol === "wss:";
|
|
68062
|
-
const isIpcUrl = parsedUrl.protocol === "ws+unix:";
|
|
68063
|
-
let invalidUrlMessage;
|
|
68064
|
-
if (parsedUrl.protocol !== "ws:" && !isSecure && !isIpcUrl) {
|
|
68065
|
-
invalidUrlMessage = `The URL's protocol must be one of "ws:", "wss:", ` + '"http:", "https:", or "ws+unix:"';
|
|
68066
|
-
} else if (isIpcUrl && !parsedUrl.pathname) {
|
|
68067
|
-
invalidUrlMessage = "The URL's pathname is empty";
|
|
68068
|
-
} else if (parsedUrl.hash) {
|
|
68069
|
-
invalidUrlMessage = "The URL contains a fragment identifier";
|
|
68070
|
-
}
|
|
68071
|
-
if (invalidUrlMessage) {
|
|
68072
|
-
const err = new SyntaxError(invalidUrlMessage);
|
|
68073
|
-
if (websocket._redirects === 0) {
|
|
68074
|
-
throw err;
|
|
68075
|
-
} else {
|
|
68076
|
-
emitErrorAndClose(websocket, err);
|
|
68077
|
-
return;
|
|
68078
|
-
}
|
|
68079
|
-
}
|
|
68080
|
-
const defaultPort = isSecure ? 443 : 80;
|
|
68081
|
-
const key = randomBytes(16).toString("base64");
|
|
68082
|
-
const request3 = isSecure ? https.request : http.request;
|
|
68083
|
-
const protocolSet = new Set;
|
|
68084
|
-
let perMessageDeflate;
|
|
68085
|
-
opts.createConnection = opts.createConnection || (isSecure ? tlsConnect : netConnect);
|
|
68086
|
-
opts.defaultPort = opts.defaultPort || defaultPort;
|
|
68087
|
-
opts.port = parsedUrl.port || defaultPort;
|
|
68088
|
-
opts.host = parsedUrl.hostname.startsWith("[") ? parsedUrl.hostname.slice(1, -1) : parsedUrl.hostname;
|
|
68089
|
-
opts.headers = {
|
|
68090
|
-
...opts.headers,
|
|
68091
|
-
"Sec-WebSocket-Version": opts.protocolVersion,
|
|
68092
|
-
"Sec-WebSocket-Key": key,
|
|
68093
|
-
Connection: "Upgrade",
|
|
68094
|
-
Upgrade: "websocket"
|
|
68095
|
-
};
|
|
68096
|
-
opts.path = parsedUrl.pathname + parsedUrl.search;
|
|
68097
|
-
opts.timeout = opts.handshakeTimeout;
|
|
68098
|
-
if (opts.perMessageDeflate) {
|
|
68099
|
-
perMessageDeflate = new PerMessageDeflate({
|
|
68100
|
-
...opts.perMessageDeflate,
|
|
68101
|
-
isServer: false,
|
|
68102
|
-
maxPayload: opts.maxPayload
|
|
68103
|
-
});
|
|
68104
|
-
opts.headers["Sec-WebSocket-Extensions"] = format({
|
|
68105
|
-
[PerMessageDeflate.extensionName]: perMessageDeflate.offer()
|
|
68106
|
-
});
|
|
68107
|
-
}
|
|
68108
|
-
if (protocols.length) {
|
|
68109
|
-
for (const protocol of protocols) {
|
|
68110
|
-
if (typeof protocol !== "string" || !subprotocolRegex.test(protocol) || protocolSet.has(protocol)) {
|
|
68111
|
-
throw new SyntaxError("An invalid or duplicated subprotocol was specified");
|
|
68112
|
-
}
|
|
68113
|
-
protocolSet.add(protocol);
|
|
68114
|
-
}
|
|
68115
|
-
opts.headers["Sec-WebSocket-Protocol"] = protocols.join(",");
|
|
68116
|
-
}
|
|
68117
|
-
if (opts.origin) {
|
|
68118
|
-
if (opts.protocolVersion < 13) {
|
|
68119
|
-
opts.headers["Sec-WebSocket-Origin"] = opts.origin;
|
|
68120
|
-
} else {
|
|
68121
|
-
opts.headers.Origin = opts.origin;
|
|
68122
|
-
}
|
|
68123
|
-
}
|
|
68124
|
-
if (parsedUrl.username || parsedUrl.password) {
|
|
68125
|
-
opts.auth = `${parsedUrl.username}:${parsedUrl.password}`;
|
|
68126
|
-
}
|
|
68127
|
-
if (isIpcUrl) {
|
|
68128
|
-
const parts = opts.path.split(":");
|
|
68129
|
-
opts.socketPath = parts[0];
|
|
68130
|
-
opts.path = parts[1];
|
|
68131
|
-
}
|
|
68132
|
-
let req;
|
|
68133
|
-
if (opts.followRedirects) {
|
|
68134
|
-
if (websocket._redirects === 0) {
|
|
68135
|
-
websocket._originalIpc = isIpcUrl;
|
|
68136
|
-
websocket._originalSecure = isSecure;
|
|
68137
|
-
websocket._originalHostOrSocketPath = isIpcUrl ? opts.socketPath : parsedUrl.host;
|
|
68138
|
-
const headers = options && options.headers;
|
|
68139
|
-
options = { ...options, headers: {} };
|
|
68140
|
-
if (headers) {
|
|
68141
|
-
for (const [key, value] of Object.entries(headers)) {
|
|
68142
|
-
options.headers[key.toLowerCase()] = value;
|
|
68143
|
-
}
|
|
68144
|
-
}
|
|
68145
|
-
} else if (websocket.listenerCount("redirect") === 0) {
|
|
68146
|
-
const isSameHost = isIpcUrl ? websocket._originalIpc ? opts.socketPath === websocket._originalHostOrSocketPath : false : websocket._originalIpc ? false : parsedUrl.host === websocket._originalHostOrSocketPath;
|
|
68147
|
-
if (!isSameHost || websocket._originalSecure && !isSecure) {
|
|
68148
|
-
delete opts.headers.authorization;
|
|
68149
|
-
delete opts.headers.cookie;
|
|
68150
|
-
if (!isSameHost)
|
|
68151
|
-
delete opts.headers.host;
|
|
68152
|
-
opts.auth = undefined;
|
|
68153
|
-
}
|
|
68154
|
-
}
|
|
68155
|
-
if (opts.auth && !options.headers.authorization) {
|
|
68156
|
-
options.headers.authorization = "Basic " + Buffer.from(opts.auth).toString("base64");
|
|
68157
|
-
}
|
|
68158
|
-
req = websocket._req = request3(opts);
|
|
68159
|
-
if (websocket._redirects) {
|
|
68160
|
-
websocket.emit("redirect", websocket.url, req);
|
|
68161
|
-
}
|
|
68162
|
-
} else {
|
|
68163
|
-
req = websocket._req = request3(opts);
|
|
68164
|
-
}
|
|
68165
|
-
if (opts.timeout) {
|
|
68166
|
-
req.on("timeout", () => {
|
|
68167
|
-
abortHandshake(websocket, req, "Opening handshake has timed out");
|
|
68168
|
-
});
|
|
68169
|
-
}
|
|
68170
|
-
req.on("error", (err) => {
|
|
68171
|
-
if (req === null || req[kAborted])
|
|
68172
|
-
return;
|
|
68173
|
-
req = websocket._req = null;
|
|
68174
|
-
emitErrorAndClose(websocket, err);
|
|
68175
|
-
});
|
|
68176
|
-
req.on("response", (res) => {
|
|
68177
|
-
const location = res.headers.location;
|
|
68178
|
-
const statusCode = res.statusCode;
|
|
68179
|
-
if (location && opts.followRedirects && statusCode >= 300 && statusCode < 400) {
|
|
68180
|
-
if (++websocket._redirects > opts.maxRedirects) {
|
|
68181
|
-
abortHandshake(websocket, req, "Maximum redirects exceeded");
|
|
68182
|
-
return;
|
|
68183
|
-
}
|
|
68184
|
-
req.abort();
|
|
68185
|
-
let addr;
|
|
68186
|
-
try {
|
|
68187
|
-
addr = new URL2(location, address);
|
|
68188
|
-
} catch (e) {
|
|
68189
|
-
const err = new SyntaxError(`Invalid URL: ${location}`);
|
|
68190
|
-
emitErrorAndClose(websocket, err);
|
|
68191
|
-
return;
|
|
68192
|
-
}
|
|
68193
|
-
initAsClient(websocket, addr, protocols, options);
|
|
68194
|
-
} else if (!websocket.emit("unexpected-response", req, res)) {
|
|
68195
|
-
abortHandshake(websocket, req, `Unexpected server response: ${res.statusCode}`);
|
|
68196
|
-
}
|
|
68197
|
-
});
|
|
68198
|
-
req.on("upgrade", (res, socket, head) => {
|
|
68199
|
-
websocket.emit("upgrade", res);
|
|
68200
|
-
if (websocket.readyState !== WebSocket.CONNECTING)
|
|
68201
|
-
return;
|
|
68202
|
-
req = websocket._req = null;
|
|
68203
|
-
const upgrade = res.headers.upgrade;
|
|
68204
|
-
if (upgrade === undefined || upgrade.toLowerCase() !== "websocket") {
|
|
68205
|
-
abortHandshake(websocket, socket, "Invalid Upgrade header");
|
|
68206
|
-
return;
|
|
68207
|
-
}
|
|
68208
|
-
const digest = createHash("sha1").update(key + GUID).digest("base64");
|
|
68209
|
-
if (res.headers["sec-websocket-accept"] !== digest) {
|
|
68210
|
-
abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
|
|
68211
|
-
return;
|
|
68212
|
-
}
|
|
68213
|
-
const serverProt = res.headers["sec-websocket-protocol"];
|
|
68214
|
-
let protError;
|
|
68215
|
-
if (serverProt !== undefined) {
|
|
68216
|
-
if (!protocolSet.size) {
|
|
68217
|
-
protError = "Server sent a subprotocol but none was requested";
|
|
68218
|
-
} else if (!protocolSet.has(serverProt)) {
|
|
68219
|
-
protError = "Server sent an invalid subprotocol";
|
|
68220
|
-
}
|
|
68221
|
-
} else if (protocolSet.size) {
|
|
68222
|
-
protError = "Server sent no subprotocol";
|
|
68223
|
-
}
|
|
68224
|
-
if (protError) {
|
|
68225
|
-
abortHandshake(websocket, socket, protError);
|
|
68226
|
-
return;
|
|
68227
|
-
}
|
|
68228
|
-
if (serverProt)
|
|
68229
|
-
websocket._protocol = serverProt;
|
|
68230
|
-
const secWebSocketExtensions = res.headers["sec-websocket-extensions"];
|
|
68231
|
-
if (secWebSocketExtensions !== undefined) {
|
|
68232
|
-
if (!perMessageDeflate) {
|
|
68233
|
-
const message = "Server sent a Sec-WebSocket-Extensions header but no extension " + "was requested";
|
|
68234
|
-
abortHandshake(websocket, socket, message);
|
|
68235
|
-
return;
|
|
68236
|
-
}
|
|
68237
|
-
let extensions;
|
|
68238
|
-
try {
|
|
68239
|
-
extensions = parse(secWebSocketExtensions);
|
|
68240
|
-
} catch (err) {
|
|
68241
|
-
const message = "Invalid Sec-WebSocket-Extensions header";
|
|
68242
|
-
abortHandshake(websocket, socket, message);
|
|
68243
|
-
return;
|
|
68244
|
-
}
|
|
68245
|
-
const extensionNames = Object.keys(extensions);
|
|
68246
|
-
if (extensionNames.length !== 1 || extensionNames[0] !== PerMessageDeflate.extensionName) {
|
|
68247
|
-
const message = "Server indicated an extension that was not requested";
|
|
68248
|
-
abortHandshake(websocket, socket, message);
|
|
68249
|
-
return;
|
|
68250
|
-
}
|
|
68251
|
-
try {
|
|
68252
|
-
perMessageDeflate.accept(extensions[PerMessageDeflate.extensionName]);
|
|
68253
|
-
} catch (err) {
|
|
68254
|
-
const message = "Invalid Sec-WebSocket-Extensions header";
|
|
68255
|
-
abortHandshake(websocket, socket, message);
|
|
68256
|
-
return;
|
|
68257
|
-
}
|
|
68258
|
-
websocket._extensions[PerMessageDeflate.extensionName] = perMessageDeflate;
|
|
68259
|
-
}
|
|
68260
|
-
websocket.setSocket(socket, head, {
|
|
68261
|
-
allowSynchronousEvents: opts.allowSynchronousEvents,
|
|
68262
|
-
generateMask: opts.generateMask,
|
|
68263
|
-
maxBufferedChunks: opts.maxBufferedChunks,
|
|
68264
|
-
maxFragments: opts.maxFragments,
|
|
68265
|
-
maxPayload: opts.maxPayload,
|
|
68266
|
-
skipUTF8Validation: opts.skipUTF8Validation
|
|
68267
|
-
});
|
|
68268
|
-
});
|
|
68269
|
-
if (opts.finishRequest) {
|
|
68270
|
-
opts.finishRequest(req, websocket);
|
|
68271
|
-
} else {
|
|
68272
|
-
req.end();
|
|
68273
|
-
}
|
|
68274
|
-
}
|
|
68275
|
-
function emitErrorAndClose(websocket, err) {
|
|
68276
|
-
websocket._readyState = WebSocket.CLOSING;
|
|
68277
|
-
websocket._errorEmitted = true;
|
|
68278
|
-
websocket.emit("error", err);
|
|
68279
|
-
websocket.emitClose();
|
|
68280
|
-
}
|
|
68281
|
-
function netConnect(options) {
|
|
68282
|
-
options.path = options.socketPath;
|
|
68283
|
-
return net.connect(options);
|
|
68284
|
-
}
|
|
68285
|
-
function tlsConnect(options) {
|
|
68286
|
-
options.path = undefined;
|
|
68287
|
-
if (!options.servername && options.servername !== "") {
|
|
68288
|
-
options.servername = net.isIP(options.host) ? "" : options.host;
|
|
68289
|
-
}
|
|
68290
|
-
return tls.connect(options);
|
|
68291
|
-
}
|
|
68292
|
-
function abortHandshake(websocket, stream, message) {
|
|
68293
|
-
websocket._readyState = WebSocket.CLOSING;
|
|
68294
|
-
const err = new Error(message);
|
|
68295
|
-
Error.captureStackTrace(err, abortHandshake);
|
|
68296
|
-
if (stream.setHeader) {
|
|
68297
|
-
stream[kAborted] = true;
|
|
68298
|
-
stream.abort();
|
|
68299
|
-
if (stream.socket && !stream.socket.destroyed) {
|
|
68300
|
-
stream.socket.destroy();
|
|
68301
|
-
}
|
|
68302
|
-
process.nextTick(emitErrorAndClose, websocket, err);
|
|
68303
|
-
} else {
|
|
68304
|
-
stream.destroy(err);
|
|
68305
|
-
stream.once("error", websocket.emit.bind(websocket, "error"));
|
|
68306
|
-
stream.once("close", websocket.emitClose.bind(websocket));
|
|
68307
|
-
}
|
|
68308
|
-
}
|
|
68309
|
-
function sendAfterClose(websocket, data, cb) {
|
|
68310
|
-
if (data) {
|
|
68311
|
-
const length = isBlob(data) ? data.size : toBuffer(data).length;
|
|
68312
|
-
if (websocket._socket)
|
|
68313
|
-
websocket._sender._bufferedBytes += length;
|
|
68314
|
-
else
|
|
68315
|
-
websocket._bufferedAmount += length;
|
|
68316
|
-
}
|
|
68317
|
-
if (cb) {
|
|
68318
|
-
const err = new Error(`WebSocket is not open: readyState ${websocket.readyState} ` + `(${readyStates[websocket.readyState]})`);
|
|
68319
|
-
process.nextTick(cb, err);
|
|
68320
|
-
}
|
|
68321
|
-
}
|
|
68322
|
-
function receiverOnConclude(code, reason) {
|
|
68323
|
-
const websocket = this[kWebSocket];
|
|
68324
|
-
websocket._closeFrameReceived = true;
|
|
68325
|
-
websocket._closeMessage = reason;
|
|
68326
|
-
websocket._closeCode = code;
|
|
68327
|
-
if (websocket._socket[kWebSocket] === undefined)
|
|
68328
|
-
return;
|
|
68329
|
-
websocket._socket.removeListener("data", socketOnData);
|
|
68330
|
-
process.nextTick(resume, websocket._socket);
|
|
68331
|
-
if (code === 1005)
|
|
68332
|
-
websocket.close();
|
|
68333
|
-
else
|
|
68334
|
-
websocket.close(code, reason);
|
|
68335
|
-
}
|
|
68336
|
-
function receiverOnDrain() {
|
|
68337
|
-
const websocket = this[kWebSocket];
|
|
68338
|
-
if (!websocket.isPaused)
|
|
68339
|
-
websocket._socket.resume();
|
|
68340
|
-
}
|
|
68341
|
-
function receiverOnError(err) {
|
|
68342
|
-
const websocket = this[kWebSocket];
|
|
68343
|
-
if (websocket._socket[kWebSocket] !== undefined) {
|
|
68344
|
-
websocket._socket.removeListener("data", socketOnData);
|
|
68345
|
-
process.nextTick(resume, websocket._socket);
|
|
68346
|
-
websocket.close(err[kStatusCode]);
|
|
68347
|
-
}
|
|
68348
|
-
if (!websocket._errorEmitted) {
|
|
68349
|
-
websocket._errorEmitted = true;
|
|
68350
|
-
websocket.emit("error", err);
|
|
68351
|
-
}
|
|
68352
|
-
}
|
|
68353
|
-
function receiverOnFinish() {
|
|
68354
|
-
this[kWebSocket].emitClose();
|
|
68355
|
-
}
|
|
68356
|
-
function receiverOnMessage(data, isBinary) {
|
|
68357
|
-
this[kWebSocket].emit("message", data, isBinary);
|
|
68358
|
-
}
|
|
68359
|
-
function receiverOnPing(data) {
|
|
68360
|
-
const websocket = this[kWebSocket];
|
|
68361
|
-
if (websocket._autoPong)
|
|
68362
|
-
websocket.pong(data, !this._isServer, NOOP);
|
|
68363
|
-
websocket.emit("ping", data);
|
|
68364
|
-
}
|
|
68365
|
-
function receiverOnPong(data) {
|
|
68366
|
-
this[kWebSocket].emit("pong", data);
|
|
68367
|
-
}
|
|
68368
|
-
function resume(stream) {
|
|
68369
|
-
stream.resume();
|
|
68370
|
-
}
|
|
68371
|
-
function senderOnError(err) {
|
|
68372
|
-
const websocket = this[kWebSocket];
|
|
68373
|
-
if (websocket.readyState === WebSocket.CLOSED)
|
|
68374
|
-
return;
|
|
68375
|
-
if (websocket.readyState === WebSocket.OPEN) {
|
|
68376
|
-
websocket._readyState = WebSocket.CLOSING;
|
|
68377
|
-
setCloseTimer(websocket);
|
|
68378
|
-
}
|
|
68379
|
-
this._socket.end();
|
|
68380
|
-
if (!websocket._errorEmitted) {
|
|
68381
|
-
websocket._errorEmitted = true;
|
|
68382
|
-
websocket.emit("error", err);
|
|
68383
|
-
}
|
|
68384
|
-
}
|
|
68385
|
-
function setCloseTimer(websocket) {
|
|
68386
|
-
websocket._closeTimer = setTimeout(websocket._socket.destroy.bind(websocket._socket), websocket._closeTimeout);
|
|
68387
|
-
}
|
|
68388
|
-
function socketOnClose() {
|
|
68389
|
-
const websocket = this[kWebSocket];
|
|
68390
|
-
this.removeListener("close", socketOnClose);
|
|
68391
|
-
this.removeListener("data", socketOnData);
|
|
68392
|
-
this.removeListener("end", socketOnEnd);
|
|
68393
|
-
websocket._readyState = WebSocket.CLOSING;
|
|
68394
|
-
if (!this._readableState.endEmitted && !websocket._closeFrameReceived && !websocket._receiver._writableState.errorEmitted && this._readableState.length !== 0) {
|
|
68395
|
-
const chunk = this.read(this._readableState.length);
|
|
68396
|
-
websocket._receiver.write(chunk);
|
|
68397
|
-
}
|
|
68398
|
-
websocket._receiver.end();
|
|
68399
|
-
this[kWebSocket] = undefined;
|
|
68400
|
-
clearTimeout(websocket._closeTimer);
|
|
68401
|
-
if (websocket._receiver._writableState.finished || websocket._receiver._writableState.errorEmitted) {
|
|
68402
|
-
websocket.emitClose();
|
|
68403
|
-
} else {
|
|
68404
|
-
websocket._receiver.on("error", receiverOnFinish);
|
|
68405
|
-
websocket._receiver.on("finish", receiverOnFinish);
|
|
68406
|
-
}
|
|
68407
|
-
}
|
|
68408
|
-
function socketOnData(chunk) {
|
|
68409
|
-
if (!this[kWebSocket]._receiver.write(chunk)) {
|
|
68410
|
-
this.pause();
|
|
68411
|
-
}
|
|
68412
|
-
}
|
|
68413
|
-
function socketOnEnd() {
|
|
68414
|
-
const websocket = this[kWebSocket];
|
|
68415
|
-
websocket._readyState = WebSocket.CLOSING;
|
|
68416
|
-
websocket._receiver.end();
|
|
68417
|
-
this.end();
|
|
68418
|
-
}
|
|
68419
|
-
function socketOnError() {
|
|
68420
|
-
const websocket = this[kWebSocket];
|
|
68421
|
-
this.removeListener("error", socketOnError);
|
|
68422
|
-
this.on("error", NOOP);
|
|
68423
|
-
if (websocket) {
|
|
68424
|
-
websocket._readyState = WebSocket.CLOSING;
|
|
68425
|
-
this.destroy();
|
|
68426
|
-
}
|
|
68427
|
-
}
|
|
68428
|
-
});
|
|
68429
|
-
|
|
68430
|
-
// node_modules/@discordjs/ws/node_modules/ws/lib/stream.js
|
|
68431
|
-
var require_stream = __commonJS(function(exports2, module2) {
|
|
68432
|
-
var WebSocket = require_websocket3();
|
|
68433
|
-
var { Duplex } = __require("stream");
|
|
68434
|
-
function emitClose(stream) {
|
|
68435
|
-
stream.emit("close");
|
|
68436
|
-
}
|
|
68437
|
-
function duplexOnEnd() {
|
|
68438
|
-
if (!this.destroyed && this._writableState.finished) {
|
|
68439
|
-
this.destroy();
|
|
68440
|
-
}
|
|
68441
|
-
}
|
|
68442
|
-
function duplexOnError(err) {
|
|
68443
|
-
this.removeListener("error", duplexOnError);
|
|
68444
|
-
this.destroy();
|
|
68445
|
-
if (this.listenerCount("error") === 0) {
|
|
68446
|
-
this.emit("error", err);
|
|
68447
|
-
}
|
|
68448
|
-
}
|
|
68449
|
-
function createWebSocketStream(ws, options) {
|
|
68450
|
-
let terminateOnDestroy = true;
|
|
68451
|
-
const duplex = new Duplex({
|
|
68452
|
-
...options,
|
|
68453
|
-
autoDestroy: false,
|
|
68454
|
-
emitClose: false,
|
|
68455
|
-
objectMode: false,
|
|
68456
|
-
writableObjectMode: false
|
|
68457
|
-
});
|
|
68458
|
-
ws.on("message", function message(msg, isBinary) {
|
|
68459
|
-
const data = !isBinary && duplex._readableState.objectMode ? msg.toString() : msg;
|
|
68460
|
-
if (!duplex.push(data))
|
|
68461
|
-
ws.pause();
|
|
68462
|
-
});
|
|
68463
|
-
ws.once("error", function error(err) {
|
|
68464
|
-
if (duplex.destroyed)
|
|
68465
|
-
return;
|
|
68466
|
-
terminateOnDestroy = false;
|
|
68467
|
-
duplex.destroy(err);
|
|
68468
|
-
});
|
|
68469
|
-
ws.once("close", function close() {
|
|
68470
|
-
if (duplex.destroyed)
|
|
68471
|
-
return;
|
|
68472
|
-
duplex.push(null);
|
|
68473
|
-
});
|
|
68474
|
-
duplex._destroy = function(err, callback) {
|
|
68475
|
-
if (ws.readyState === ws.CLOSED) {
|
|
68476
|
-
callback(err);
|
|
68477
|
-
process.nextTick(emitClose, duplex);
|
|
68478
|
-
return;
|
|
68479
|
-
}
|
|
68480
|
-
let called = false;
|
|
68481
|
-
ws.once("error", function error(err) {
|
|
68482
|
-
called = true;
|
|
68483
|
-
callback(err);
|
|
68484
|
-
});
|
|
68485
|
-
ws.once("close", function close() {
|
|
68486
|
-
if (!called)
|
|
68487
|
-
callback(err);
|
|
68488
|
-
process.nextTick(emitClose, duplex);
|
|
68489
|
-
});
|
|
68490
|
-
if (terminateOnDestroy)
|
|
68491
|
-
ws.terminate();
|
|
68492
|
-
};
|
|
68493
|
-
duplex._final = function(callback) {
|
|
68494
|
-
if (ws.readyState === ws.CONNECTING) {
|
|
68495
|
-
ws.once("open", function open() {
|
|
68496
|
-
duplex._final(callback);
|
|
68497
|
-
});
|
|
68498
|
-
return;
|
|
68499
|
-
}
|
|
68500
|
-
if (ws._socket === null)
|
|
68501
|
-
return;
|
|
68502
|
-
if (ws._socket._writableState.finished) {
|
|
68503
|
-
callback();
|
|
68504
|
-
if (duplex._readableState.endEmitted)
|
|
68505
|
-
duplex.destroy();
|
|
68506
|
-
} else {
|
|
68507
|
-
ws._socket.once("finish", function finish() {
|
|
68508
|
-
callback();
|
|
68509
|
-
});
|
|
68510
|
-
ws.close();
|
|
68511
|
-
}
|
|
68512
|
-
};
|
|
68513
|
-
duplex._read = function() {
|
|
68514
|
-
if (ws.isPaused)
|
|
68515
|
-
ws.resume();
|
|
68516
|
-
};
|
|
68517
|
-
duplex._write = function(chunk, encoding, callback) {
|
|
68518
|
-
if (ws.readyState === ws.CONNECTING) {
|
|
68519
|
-
ws.once("open", function open() {
|
|
68520
|
-
duplex._write(chunk, encoding, callback);
|
|
68521
|
-
});
|
|
68522
|
-
return;
|
|
68523
|
-
}
|
|
68524
|
-
ws.send(chunk, callback);
|
|
68525
|
-
};
|
|
68526
|
-
duplex.on("end", duplexOnEnd);
|
|
68527
|
-
duplex.on("error", duplexOnError);
|
|
68528
|
-
return duplex;
|
|
68529
|
-
}
|
|
68530
|
-
module2.exports = createWebSocketStream;
|
|
68531
|
-
});
|
|
68532
|
-
|
|
68533
|
-
// node_modules/@discordjs/ws/node_modules/ws/lib/subprotocol.js
|
|
68534
|
-
var require_subprotocol = __commonJS(function(exports2, module2) {
|
|
68535
|
-
var { tokenChars } = require_validation();
|
|
68536
|
-
function parse(header) {
|
|
68537
|
-
const protocols = new Set;
|
|
68538
|
-
let start = -1;
|
|
68539
|
-
let end = -1;
|
|
68540
|
-
let i = 0;
|
|
68541
|
-
for (i;i < header.length; i++) {
|
|
68542
|
-
const code = header.charCodeAt(i);
|
|
68543
|
-
if (end === -1 && tokenChars[code] === 1) {
|
|
68544
|
-
if (start === -1)
|
|
68545
|
-
start = i;
|
|
68546
|
-
} else if (i !== 0 && (code === 32 || code === 9)) {
|
|
68547
|
-
if (end === -1 && start !== -1)
|
|
68548
|
-
end = i;
|
|
68549
|
-
} else if (code === 44) {
|
|
68550
|
-
if (start === -1) {
|
|
68551
|
-
throw new SyntaxError(`Unexpected character at index ${i}`);
|
|
68552
|
-
}
|
|
68553
|
-
if (end === -1)
|
|
68554
|
-
end = i;
|
|
68555
|
-
const protocol = header.slice(start, end);
|
|
68556
|
-
if (protocols.has(protocol)) {
|
|
68557
|
-
throw new SyntaxError(`The "${protocol}" subprotocol is duplicated`);
|
|
68558
|
-
}
|
|
68559
|
-
protocols.add(protocol);
|
|
68560
|
-
start = end = -1;
|
|
68561
|
-
} else {
|
|
68562
|
-
throw new SyntaxError(`Unexpected character at index ${i}`);
|
|
68563
|
-
}
|
|
68564
|
-
}
|
|
68565
|
-
if (start === -1 || end !== -1) {
|
|
68566
|
-
throw new SyntaxError("Unexpected end of input");
|
|
68567
|
-
}
|
|
68568
|
-
const protocol = header.slice(start, i);
|
|
68569
|
-
if (protocols.has(protocol)) {
|
|
68570
|
-
throw new SyntaxError(`The "${protocol}" subprotocol is duplicated`);
|
|
68571
|
-
}
|
|
68572
|
-
protocols.add(protocol);
|
|
68573
|
-
return protocols;
|
|
68574
|
-
}
|
|
68575
|
-
module2.exports = { parse };
|
|
68576
|
-
});
|
|
68577
|
-
|
|
68578
|
-
// node_modules/@discordjs/ws/node_modules/ws/lib/websocket-server.js
|
|
68579
|
-
var require_websocket_server = __commonJS(function(exports2, module2) {
|
|
68580
|
-
var EventEmitter = __require("events");
|
|
68581
|
-
var http = __require("http");
|
|
68582
|
-
var { Duplex } = __require("stream");
|
|
68583
|
-
var { createHash } = __require("crypto");
|
|
68584
|
-
var extension = require_extension();
|
|
68585
|
-
var PerMessageDeflate = require_permessage_deflate3();
|
|
68586
|
-
var subprotocol = require_subprotocol();
|
|
68587
|
-
var WebSocket = require_websocket3();
|
|
68588
|
-
var { CLOSE_TIMEOUT, GUID, kWebSocket } = require_constants11();
|
|
68589
|
-
var keyRegex = /^[+/0-9A-Za-z]{22}==$/;
|
|
68590
|
-
var RUNNING = 0;
|
|
68591
|
-
var CLOSING = 1;
|
|
68592
|
-
var CLOSED = 2;
|
|
68593
|
-
|
|
68594
|
-
class WebSocketServer extends EventEmitter {
|
|
68595
|
-
constructor(options, callback) {
|
|
68596
|
-
super();
|
|
68597
|
-
options = {
|
|
68598
|
-
allowSynchronousEvents: true,
|
|
68599
|
-
autoPong: true,
|
|
68600
|
-
maxBufferedChunks: 256 * 1024,
|
|
68601
|
-
maxFragments: 16 * 1024,
|
|
68602
|
-
maxPayload: 100 * 1024 * 1024,
|
|
68603
|
-
skipUTF8Validation: false,
|
|
68604
|
-
perMessageDeflate: false,
|
|
68605
|
-
handleProtocols: null,
|
|
68606
|
-
clientTracking: true,
|
|
68607
|
-
closeTimeout: CLOSE_TIMEOUT,
|
|
68608
|
-
verifyClient: null,
|
|
68609
|
-
noServer: false,
|
|
68610
|
-
backlog: null,
|
|
68611
|
-
server: null,
|
|
68612
|
-
host: null,
|
|
68613
|
-
path: null,
|
|
68614
|
-
port: null,
|
|
68615
|
-
WebSocket,
|
|
68616
|
-
...options
|
|
68617
|
-
};
|
|
68618
|
-
if (options.port == null && !options.server && !options.noServer || options.port != null && (options.server || options.noServer) || options.server && options.noServer) {
|
|
68619
|
-
throw new TypeError('One and only one of the "port", "server", or "noServer" options ' + "must be specified");
|
|
68620
|
-
}
|
|
68621
|
-
if (options.port != null) {
|
|
68622
|
-
this._server = http.createServer((req, res) => {
|
|
68623
|
-
const body = http.STATUS_CODES[426];
|
|
68624
|
-
res.writeHead(426, {
|
|
68625
|
-
"Content-Length": body.length,
|
|
68626
|
-
"Content-Type": "text/plain"
|
|
68627
|
-
});
|
|
68628
|
-
res.end(body);
|
|
68629
|
-
});
|
|
68630
|
-
this._server.listen(options.port, options.host, options.backlog, callback);
|
|
68631
|
-
} else if (options.server) {
|
|
68632
|
-
this._server = options.server;
|
|
68633
|
-
}
|
|
68634
|
-
if (this._server) {
|
|
68635
|
-
const emitConnection = this.emit.bind(this, "connection");
|
|
68636
|
-
this._removeListeners = addListeners(this._server, {
|
|
68637
|
-
listening: this.emit.bind(this, "listening"),
|
|
68638
|
-
error: this.emit.bind(this, "error"),
|
|
68639
|
-
upgrade: (req, socket, head) => {
|
|
68640
|
-
this.handleUpgrade(req, socket, head, emitConnection);
|
|
68641
|
-
}
|
|
68642
|
-
});
|
|
68643
|
-
}
|
|
68644
|
-
if (options.perMessageDeflate === true)
|
|
68645
|
-
options.perMessageDeflate = {};
|
|
68646
|
-
if (options.clientTracking) {
|
|
68647
|
-
this.clients = new Set;
|
|
68648
|
-
this._shouldEmitClose = false;
|
|
68649
|
-
}
|
|
68650
|
-
this.options = options;
|
|
68651
|
-
this._state = RUNNING;
|
|
68652
|
-
}
|
|
68653
|
-
address() {
|
|
68654
|
-
if (this.options.noServer) {
|
|
68655
|
-
throw new Error('The server is operating in "noServer" mode');
|
|
68656
|
-
}
|
|
68657
|
-
if (!this._server)
|
|
68658
|
-
return null;
|
|
68659
|
-
return this._server.address();
|
|
68660
|
-
}
|
|
68661
|
-
close(cb) {
|
|
68662
|
-
if (this._state === CLOSED) {
|
|
68663
|
-
if (cb) {
|
|
68664
|
-
this.once("close", () => {
|
|
68665
|
-
cb(new Error("The server is not running"));
|
|
68666
|
-
});
|
|
68667
|
-
}
|
|
68668
|
-
process.nextTick(emitClose, this);
|
|
68669
|
-
return;
|
|
68670
|
-
}
|
|
68671
|
-
if (cb)
|
|
68672
|
-
this.once("close", cb);
|
|
68673
|
-
if (this._state === CLOSING)
|
|
68674
|
-
return;
|
|
68675
|
-
this._state = CLOSING;
|
|
68676
|
-
if (this.options.noServer || this.options.server) {
|
|
68677
|
-
if (this._server) {
|
|
68678
|
-
this._removeListeners();
|
|
68679
|
-
this._removeListeners = this._server = null;
|
|
68680
|
-
}
|
|
68681
|
-
if (this.clients) {
|
|
68682
|
-
if (!this.clients.size) {
|
|
68683
|
-
process.nextTick(emitClose, this);
|
|
68684
|
-
} else {
|
|
68685
|
-
this._shouldEmitClose = true;
|
|
68686
|
-
}
|
|
68687
|
-
} else {
|
|
68688
|
-
process.nextTick(emitClose, this);
|
|
68689
|
-
}
|
|
68690
|
-
} else {
|
|
68691
|
-
const server = this._server;
|
|
68692
|
-
this._removeListeners();
|
|
68693
|
-
this._removeListeners = this._server = null;
|
|
68694
|
-
server.close(() => {
|
|
68695
|
-
emitClose(this);
|
|
68696
|
-
});
|
|
68697
|
-
}
|
|
68698
|
-
}
|
|
68699
|
-
shouldHandle(req) {
|
|
68700
|
-
if (this.options.path) {
|
|
68701
|
-
const index = req.url.indexOf("?");
|
|
68702
|
-
const pathname = index !== -1 ? req.url.slice(0, index) : req.url;
|
|
68703
|
-
if (pathname !== this.options.path)
|
|
68704
|
-
return false;
|
|
68705
|
-
}
|
|
68706
|
-
return true;
|
|
68707
|
-
}
|
|
68708
|
-
handleUpgrade(req, socket, head, cb) {
|
|
68709
|
-
socket.on("error", socketOnError);
|
|
68710
|
-
const key = req.headers["sec-websocket-key"];
|
|
68711
|
-
const upgrade = req.headers.upgrade;
|
|
68712
|
-
const version = +req.headers["sec-websocket-version"];
|
|
68713
|
-
if (req.method !== "GET") {
|
|
68714
|
-
const message = "Invalid HTTP method";
|
|
68715
|
-
abortHandshakeOrEmitwsClientError(this, req, socket, 405, message);
|
|
68716
|
-
return;
|
|
68717
|
-
}
|
|
68718
|
-
if (upgrade === undefined || upgrade.toLowerCase() !== "websocket") {
|
|
68719
|
-
const message = "Invalid Upgrade header";
|
|
68720
|
-
abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
|
|
68721
|
-
return;
|
|
68722
|
-
}
|
|
68723
|
-
if (key === undefined || !keyRegex.test(key)) {
|
|
68724
|
-
const message = "Missing or invalid Sec-WebSocket-Key header";
|
|
68725
|
-
abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
|
|
68726
|
-
return;
|
|
68727
|
-
}
|
|
68728
|
-
if (version !== 13 && version !== 8) {
|
|
68729
|
-
const message = "Missing or invalid Sec-WebSocket-Version header";
|
|
68730
|
-
abortHandshakeOrEmitwsClientError(this, req, socket, 400, message, {
|
|
68731
|
-
"Sec-WebSocket-Version": "13, 8"
|
|
68732
|
-
});
|
|
68733
|
-
return;
|
|
68734
|
-
}
|
|
68735
|
-
if (!this.shouldHandle(req)) {
|
|
68736
|
-
abortHandshake(socket, 400);
|
|
68737
|
-
return;
|
|
68738
|
-
}
|
|
68739
|
-
const secWebSocketProtocol = req.headers["sec-websocket-protocol"];
|
|
68740
|
-
let protocols = new Set;
|
|
68741
|
-
if (secWebSocketProtocol !== undefined) {
|
|
68742
|
-
try {
|
|
68743
|
-
protocols = subprotocol.parse(secWebSocketProtocol);
|
|
68744
|
-
} catch (err) {
|
|
68745
|
-
const message = "Invalid Sec-WebSocket-Protocol header";
|
|
68746
|
-
abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
|
|
68747
|
-
return;
|
|
68748
|
-
}
|
|
68749
|
-
}
|
|
68750
|
-
const secWebSocketExtensions = req.headers["sec-websocket-extensions"];
|
|
68751
|
-
const extensions = {};
|
|
68752
|
-
if (this.options.perMessageDeflate && secWebSocketExtensions !== undefined) {
|
|
68753
|
-
const perMessageDeflate = new PerMessageDeflate({
|
|
68754
|
-
...this.options.perMessageDeflate,
|
|
68755
|
-
isServer: true,
|
|
68756
|
-
maxPayload: this.options.maxPayload
|
|
68757
|
-
});
|
|
68758
|
-
try {
|
|
68759
|
-
const offers = extension.parse(secWebSocketExtensions);
|
|
68760
|
-
if (offers[PerMessageDeflate.extensionName]) {
|
|
68761
|
-
perMessageDeflate.accept(offers[PerMessageDeflate.extensionName]);
|
|
68762
|
-
extensions[PerMessageDeflate.extensionName] = perMessageDeflate;
|
|
68763
|
-
}
|
|
68764
|
-
} catch (err) {
|
|
68765
|
-
const message = "Invalid or unacceptable Sec-WebSocket-Extensions header";
|
|
68766
|
-
abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
|
|
68767
|
-
return;
|
|
68768
|
-
}
|
|
68769
|
-
}
|
|
68770
|
-
if (this.options.verifyClient) {
|
|
68771
|
-
const info = {
|
|
68772
|
-
origin: req.headers[`${version === 8 ? "sec-websocket-origin" : "origin"}`],
|
|
68773
|
-
secure: !!(req.socket.authorized || req.socket.encrypted),
|
|
68774
|
-
req
|
|
68775
|
-
};
|
|
68776
|
-
if (this.options.verifyClient.length === 2) {
|
|
68777
|
-
this.options.verifyClient(info, (verified, code, message, headers) => {
|
|
68778
|
-
if (!verified) {
|
|
68779
|
-
return abortHandshake(socket, code || 401, message, headers);
|
|
68780
|
-
}
|
|
68781
|
-
this.completeUpgrade(extensions, key, protocols, req, socket, head, cb);
|
|
68782
|
-
});
|
|
68783
|
-
return;
|
|
68784
|
-
}
|
|
68785
|
-
if (!this.options.verifyClient(info))
|
|
68786
|
-
return abortHandshake(socket, 401);
|
|
68787
|
-
}
|
|
68788
|
-
this.completeUpgrade(extensions, key, protocols, req, socket, head, cb);
|
|
68789
|
-
}
|
|
68790
|
-
completeUpgrade(extensions, key, protocols, req, socket, head, cb) {
|
|
68791
|
-
if (!socket.readable || !socket.writable)
|
|
68792
|
-
return socket.destroy();
|
|
68793
|
-
if (socket[kWebSocket]) {
|
|
68794
|
-
throw new Error("server.handleUpgrade() was called more than once with the same " + "socket, possibly due to a misconfiguration");
|
|
68795
|
-
}
|
|
68796
|
-
if (this._state > RUNNING)
|
|
68797
|
-
return abortHandshake(socket, 503);
|
|
68798
|
-
const digest = createHash("sha1").update(key + GUID).digest("base64");
|
|
68799
|
-
const headers = [
|
|
68800
|
-
"HTTP/1.1 101 Switching Protocols",
|
|
68801
|
-
"Upgrade: websocket",
|
|
68802
|
-
"Connection: Upgrade",
|
|
68803
|
-
`Sec-WebSocket-Accept: ${digest}`
|
|
68804
|
-
];
|
|
68805
|
-
const ws = new this.options.WebSocket(null, undefined, this.options);
|
|
68806
|
-
if (protocols.size) {
|
|
68807
|
-
const protocol = this.options.handleProtocols ? this.options.handleProtocols(protocols, req) : protocols.values().next().value;
|
|
68808
|
-
if (protocol) {
|
|
68809
|
-
headers.push(`Sec-WebSocket-Protocol: ${protocol}`);
|
|
68810
|
-
ws._protocol = protocol;
|
|
68811
|
-
}
|
|
68812
|
-
}
|
|
68813
|
-
if (extensions[PerMessageDeflate.extensionName]) {
|
|
68814
|
-
const params = extensions[PerMessageDeflate.extensionName].params;
|
|
68815
|
-
const value = extension.format({
|
|
68816
|
-
[PerMessageDeflate.extensionName]: [params]
|
|
68817
|
-
});
|
|
68818
|
-
headers.push(`Sec-WebSocket-Extensions: ${value}`);
|
|
68819
|
-
ws._extensions = extensions;
|
|
68820
|
-
}
|
|
68821
|
-
this.emit("headers", headers, req);
|
|
68822
|
-
socket.write(headers.concat(`\r
|
|
68823
|
-
`).join(`\r
|
|
68824
|
-
`));
|
|
68825
|
-
socket.removeListener("error", socketOnError);
|
|
68826
|
-
ws.setSocket(socket, head, {
|
|
68827
|
-
allowSynchronousEvents: this.options.allowSynchronousEvents,
|
|
68828
|
-
maxBufferedChunks: this.options.maxBufferedChunks,
|
|
68829
|
-
maxFragments: this.options.maxFragments,
|
|
68830
|
-
maxPayload: this.options.maxPayload,
|
|
68831
|
-
skipUTF8Validation: this.options.skipUTF8Validation
|
|
68832
|
-
});
|
|
68833
|
-
if (this.clients) {
|
|
68834
|
-
this.clients.add(ws);
|
|
68835
|
-
ws.on("close", () => {
|
|
68836
|
-
this.clients.delete(ws);
|
|
68837
|
-
if (this._shouldEmitClose && !this.clients.size) {
|
|
68838
|
-
process.nextTick(emitClose, this);
|
|
68839
|
-
}
|
|
68840
|
-
});
|
|
68841
|
-
}
|
|
68842
|
-
cb(ws, req);
|
|
68843
|
-
}
|
|
68844
|
-
}
|
|
68845
|
-
module2.exports = WebSocketServer;
|
|
68846
|
-
function addListeners(server, map) {
|
|
68847
|
-
for (const event of Object.keys(map))
|
|
68848
|
-
server.on(event, map[event]);
|
|
68849
|
-
return function removeListeners() {
|
|
68850
|
-
for (const event of Object.keys(map)) {
|
|
68851
|
-
server.removeListener(event, map[event]);
|
|
68852
|
-
}
|
|
68853
|
-
};
|
|
68854
|
-
}
|
|
68855
|
-
function emitClose(server) {
|
|
68856
|
-
server._state = CLOSED;
|
|
68857
|
-
server.emit("close");
|
|
68858
|
-
}
|
|
68859
|
-
function socketOnError() {
|
|
68860
|
-
this.destroy();
|
|
68861
|
-
}
|
|
68862
|
-
function abortHandshake(socket, code, message, headers) {
|
|
68863
|
-
message = message || http.STATUS_CODES[code];
|
|
68864
|
-
headers = {
|
|
68865
|
-
Connection: "close",
|
|
68866
|
-
"Content-Type": "text/html",
|
|
68867
|
-
"Content-Length": Buffer.byteLength(message),
|
|
68868
|
-
...headers
|
|
68869
|
-
};
|
|
68870
|
-
socket.once("finish", socket.destroy);
|
|
68871
|
-
socket.end(`HTTP/1.1 ${code} ${http.STATUS_CODES[code]}\r
|
|
68872
|
-
` + Object.keys(headers).map((h) => `${h}: ${headers[h]}`).join(`\r
|
|
68873
|
-
`) + `\r
|
|
68874
|
-
\r
|
|
68875
|
-
` + message);
|
|
68876
|
-
}
|
|
68877
|
-
function abortHandshakeOrEmitwsClientError(server, req, socket, code, message, headers) {
|
|
68878
|
-
if (server.listenerCount("wsClientError")) {
|
|
68879
|
-
const err = new Error(message);
|
|
68880
|
-
Error.captureStackTrace(err, abortHandshakeOrEmitwsClientError);
|
|
68881
|
-
server.emit("wsClientError", err, socket, req);
|
|
68882
|
-
} else {
|
|
68883
|
-
abortHandshake(socket, code, message, headers);
|
|
68884
|
-
}
|
|
68885
|
-
}
|
|
68886
|
-
});
|
|
68887
|
-
|
|
68888
|
-
// node_modules/@discordjs/ws/node_modules/ws/index.js
|
|
68889
|
-
var require_ws = __commonJS(function(exports2, module2) {
|
|
68890
|
-
var createWebSocketStream = require_stream();
|
|
68891
|
-
var extension = require_extension();
|
|
68892
|
-
var PerMessageDeflate = require_permessage_deflate3();
|
|
68893
|
-
var Receiver = require_receiver3();
|
|
68894
|
-
var Sender = require_sender3();
|
|
68895
|
-
var subprotocol = require_subprotocol();
|
|
68896
|
-
var WebSocket = require_websocket3();
|
|
68897
|
-
var WebSocketServer = require_websocket_server();
|
|
68898
|
-
WebSocket.createWebSocketStream = createWebSocketStream;
|
|
68899
|
-
WebSocket.extension = extension;
|
|
68900
|
-
WebSocket.PerMessageDeflate = PerMessageDeflate;
|
|
68901
|
-
WebSocket.Receiver = Receiver;
|
|
68902
|
-
WebSocket.Sender = Sender;
|
|
68903
|
-
WebSocket.Server = WebSocketServer;
|
|
68904
|
-
WebSocket.subprotocol = subprotocol;
|
|
68905
|
-
WebSocket.WebSocket = WebSocket;
|
|
68906
|
-
WebSocket.WebSocketServer = WebSocketServer;
|
|
68907
|
-
module2.exports = WebSocket;
|
|
68908
|
-
});
|
|
68909
|
-
|
|
68910
65998
|
// node_modules/@discordjs/ws/dist/index.js
|
|
68911
65999
|
var require_dist10 = __commonJS(function(exports2, module2) {
|
|
68912
66000
|
var __dirname = "/home/runner/work/agent-swarm/agent-swarm/node_modules/@discordjs/ws/dist";
|