From 4b6ef0a03b27db6d1f6ad646dbd93e08e8dac5fd Mon Sep 17 00:00:00 2001 From: weaigc <879821485@qq.com> Date: Wed, 13 Sep 2023 00:54:34 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=20replit=20=E5=8F=8A?= =?UTF-8?q?=20cf=20=E9=83=A8=E7=BD=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 39 ++- cloudflare/cli.js | 13 + cloudflare/worker.js | 87 ++++++- package-lock.json | 581 ++++++++++++++++++++++++++++++++++++++++++- package.json | 2 + 5 files changed, 687 insertions(+), 35 deletions(-) create mode 100644 cloudflare/cli.js diff --git a/README.md b/README.md index 0248d521..41da1b43 100644 --- a/README.md +++ b/README.md @@ -14,10 +14,11 @@ Bingo,一个让你呼吸顺畅 New Bing。 -## 演示站点 +## 演示站点(由于 New Bing 封锁,目前需要绑定用户信息才能使用,请参考说明自行配置) -https://bing.github1s.tk +站点1:https://bing.github1s.tk +站点2:https://bingo.weaigc.repl.co [![img](./docs/images/demo.png)](https://bing.github1s.tk) @@ -46,24 +47,12 @@ https://bing.github1s.tk - [ ] 国际化翻译 - [ ] 支持 OpenAI API -## 一键部署 -> HuggingFace 已经被封禁,新方法正在内测中,如有需要,请直接访问演示站点 https://bing.github1s.tk +## 在线部署(Replit及CF均受到不同程度的封锁,故需要配置用户信息才能使用) +### 1. 部署到 Replit -你也可以一键部署自己的 New Bing AI 到 🤗 HuggingFace 。 +[点击部署Replit](https://replit.com/@weaigc/bingo?v=1) -### 部署到 Huggingface -1. 点击此图标 -[![Deploy to HuggingFace](https://img.shields.io/badge/%E7%82%B9%E5%87%BB%E9%83%A8%E7%BD%B2-%F0%9F%A4%97-fff)](https://huggingface.co/login?next=%2Fspaces%2Fhf4all%2Fbingo%3Fduplicate%3Dtrue%26visibility%3Dpublic),配置可以不改。 - -2. 部署署完成后,点击“设置” 》“站点域名”,点一下,复制一下 HF 域名信息,然后分享给别人即可。 - -> Huggingface 不支持绑定自己的域名,不过我们可以使用曲线救国的方式来达到这个目的 -> 1. 方式二,借助 Cloudflare Workers [部署Cloudflare Workers](#使用Cloudflare-Workers自定义域名) -> 2. 方式一,借助 Github Pages 及 iframe [如何绑定域名](https://github.com/weaigc/bingo/issues/4) - -### 使用Cloudflare Workers自定义域名 - -> 核心代码 [worker.js](./cloudflare/worker.js) +### 2. 部署到 CloudFlare (需要有自己的域名才可以) - [注册 Cloudflare 账号](https://dash.cloudflare.com/sign-up) @@ -71,16 +60,23 @@ https://bing.github1s.tk - 通过左侧菜单进入「Workers」,并点击「Create a Worker」。 -- 创建 Worker 服务,复制 [worker.js](./cloudflare/worker.js) 全部代码,粘贴至创建的服务中,根据注释进行改动,保存并部署。 +- 创建 Worker 服务,复制 [worker.js](./cloudflare/worker.js) 全部代码,修改第一行 `SITE_HOST` 为自己的域名,粘贴至创建的服务中,根据注释进行改动,保存并部署。 - 触发器 中自定义访问域名。 ### 部署其它平台
-由于其他平台目前遭到 New Bing 封杀,会遇到很多问题,不再做推荐,有需要的可以自行查看 +由于其他平台目前遭到 New Bing 比较彻底的封杀,会遇到很多问题,不再做推荐,有需要的可以自行查看 +#### 部署到 HuggingFace +1. 点击此图标 +[![Deploy to HuggingFace](https://img.shields.io/badge/%E7%82%B9%E5%87%BB%E9%83%A8%E7%BD%B2-%F0%9F%A4%97-fff)](https://huggingface.co/login?next=%2Fspaces%2Fhf4all%2Fbingo%3Fduplicate%3Dtrue%26visibility%3Dpublic),配置可以不改。 + +2. 部署署完成后,点击“设置” 》“站点域名”,点一下,复制一下 HF 域名信息,然后分享给别人即可。 + + #### 部署到 Netlify [![Deploy to Netlify Button](https://www.netlify.com/img/deploy/button.svg)](https://app.netlify.com/start/deploy?repository=https://github.com/weaigc/bingo) @@ -101,7 +97,6 @@ https://bing.github1s.tk ## 安装和使用 -> 由于目前微软封杀比较严重,推荐优先使用 [部署 Huggingface](#部署到-huggingface) 。 > 本地部署需要你本机或服务器 IP 是国外 IP ,否则会无法连接到 New Bing。 * 使用 Node 启动 @@ -125,7 +120,7 @@ docker run --rm -it -e BING_HEADER=xxxx -p 7860:7860 weaigc/bingo ## 如何获取 BING_HEADER > 配置了 BING_HEADER 意味着你将自己的账号共享给所有使用此服务的人,如果不需要免登录画图的功能,不建议设置此变量 -打开 https://www.bing.com 并登录,然后访问 https://www.bing.com/turing/captcha/challenge ,通过人机校验,然后 +打开 https://www.bing.com 并登录,然后访问 https://www.bing.com/turing/captcha/challenge ,通过人机校验(如果显示**无效域**,则跳过校验不管),然后 ![BING HEADER](./docs/images/curl.png) diff --git a/cloudflare/cli.js b/cloudflare/cli.js new file mode 100644 index 00000000..5b3a6371 --- /dev/null +++ b/cloudflare/cli.js @@ -0,0 +1,13 @@ +const { spawn } = require('child_process'); +const { join } = require('path'); + +const miniflare = join(require.resolve('miniflare'), '../cli.js') +const script = join(__dirname, './worker.js'); + +const proc = spawn(`node`, ['--experimental-vm-modules', miniflare, script, '-w', '-d', '-m', '-p', process.env.PORT || 8080]) +proc.stdout.on('data', (chunk) => { + process.stdout.write(chunk) +}) +proc.stderr.on('data', (chunk) => { + process.stderr.write(chunk) +}) diff --git a/cloudflare/worker.js b/cloudflare/worker.js index e0debd75..d52faa2b 100644 --- a/cloudflare/worker.js +++ b/cloudflare/worker.js @@ -1,18 +1,83 @@ -const TRAGET_HOST='hf4all-bingo.hf.space' // 请将此域名改成你自己的,域名信息在设置》站点域名查看。 +const SITE_HOST = '这城改为你的域名' // 为空则自动推断 +const TARGET_HOST='hf4all-bingo.hf.space' // 后台服务,默认不需要修改 export default { - async fetch(request) { - const uri = new URL(request.url); - if (uri.protocol === 'http:') { - uri.protocol = 'https:'; - return new Response('', { - status: 301, + async handleOptions(request) { + const corsHeaders = { + 'Access-Control-Allow-Origin': '*', + 'Access-Control-Allow-Methods': 'GET,HEAD,POST,OPTIONS', + 'Access-Control-Max-Age': '86400', + } + + if ( + request.headers.get('Origin') !== null && + request.headers.get('Access-Control-Request-Method') !== null && + request.headers.get('Access-Control-Request-Headers') !== null + ) { + return new Response(null, { headers: { - location: uri.toString(), + ...corsHeaders, + 'Access-Control-Allow-Headers': request.headers.get( + 'Access-Control-Request-Headers' + ), }, }) + } else { + return new Response(null, { + headers: { + Allow: 'GET, HEAD, POST, OPTIONS', + }, + }) + } + }, + + async handleWebSocket(headers) { + headers.set('Host', 'sydney.bing.com') + return fetch('https://sydney.bing.com/sydney/ChatHub', { + headers + }) + }, + + async fetch(request) { + const uri = new URL(request.url) + console.log('uri', uri.toString()) + if (request.method === 'OPTIONS') { + return this.handleOptions(request) + } + const headersObj = {} + for (const [key, value] of request.headers.entries()) { + if (key.startsWith('cf-') || key.startsWith('x-') || ['connection', 'origin', 'referer', 'host', 'authority'].includes(key)) continue + headersObj[key] = value + } + headersObj['x-forwarded-for'] = request.headers.get('x-forwarded-for')?.split(',')?.[0] + if (!headersObj['x-forwarded-for']) { + delete headersObj['x-forwarded-for'] + } + headersObj['x-ms-useragent'] = request.headers.get('x-ms-useragent') || 'azsdk-js-api-client-factory/1.0.0-beta.1 core-rest-pipeline/1.10.3 OS/Win32' + headersObj['referer'] = 'https://www.bing.com/search?q=Bing+AI' + const headers = new Headers(headersObj) + console.log('headers', headersObj) + + const upgradeHeader = headers.get('Upgrade') + if (upgradeHeader === 'websocket') { + return this.handleWebSocket(headers) + } + if (uri.pathname.startsWith('/turing/')) { + uri.host = 'www.bing.com' + } else { + if (uri.protocol === 'http:' && !/^[0-9.:]+$/.test(TARGET_HOST)) { + uri.protocol = 'https:'; + } + headers.set('x-endpoint', SITE_HOST || uri.host) + headers.set('x-ws-endpoint', SITE_HOST || uri.host) + uri.host = TARGET_HOST } - uri.host = TRAGET_HOST - return fetch(new Request(uri.toString(), request)); + headers.set('Host', uri.host) + return fetch(uri.toString(), { + headers, + method: request.method, + redirect: request.redirect, + body: request.body, + }) }, -}; +} diff --git a/package-lock.json b/package-lock.json index c3ff585b..ac4396d6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "bingo", - "version": "0.6.2", + "version": "0.7.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "bingo", - "version": "0.6.2", + "version": "0.7.0", "dependencies": { "@headlessui/react": "^1.7.17", "@radix-ui/react-alert-dialog": "^1.0.4", @@ -38,6 +38,7 @@ "js-base64": "^3.7.5", "lodash": "^4.17.21", "md5": "^2.3.0", + "miniflare": "^2.14.1", "namestorage": "^1.3.0", "nanoid": "^4.0.2", "next": "13.4.19", @@ -2294,6 +2295,11 @@ "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz", "integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==" }, + "node_modules/@iarna/toml": { + "version": "2.2.5", + "resolved": "https://registry.npmjs.org/@iarna/toml/-/toml-2.2.5.tgz", + "integrity": "sha512-trnsAYxU3xnS1gPHPyU961coFyLkh4gAD/0zQ5mymY4yOZ+CYvsPqUbOFSw0aDM4y0tV7tiFxL/1XfXPNC6IPg==" + }, "node_modules/@jridgewell/gen-mapping": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.3.tgz", @@ -2342,6 +2348,329 @@ "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz", "integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==" }, + "node_modules/@miniflare/cache": { + "version": "2.14.1", + "resolved": "https://registry.npmjs.org/@miniflare/cache/-/cache-2.14.1.tgz", + "integrity": "sha512-f/o6UBV6UX+MlhjcEch73/wjQvvNo37dgYmP6Pn2ax1/mEHhJ7allNAqenmonT4djNeyB3eEYV3zUl54wCEwrg==", + "dependencies": { + "@miniflare/core": "2.14.1", + "@miniflare/shared": "2.14.1", + "http-cache-semantics": "^4.1.0", + "undici": "5.20.0" + }, + "engines": { + "node": ">=16.13" + } + }, + "node_modules/@miniflare/cache/node_modules/undici": { + "version": "5.20.0", + "resolved": "https://registry.npmjs.org/undici/-/undici-5.20.0.tgz", + "integrity": "sha512-J3j60dYzuo6Eevbawwp1sdg16k5Tf768bxYK4TUJRH7cBM4kFCbf3mOnM/0E3vQYXvpxITbbWmBafaDbxLDz3g==", + "dependencies": { + "busboy": "^1.6.0" + }, + "engines": { + "node": ">=12.18" + } + }, + "node_modules/@miniflare/cli-parser": { + "version": "2.14.1", + "resolved": "https://registry.npmjs.org/@miniflare/cli-parser/-/cli-parser-2.14.1.tgz", + "integrity": "sha512-MLvMuvxQPL/uw94Dg6CR3CM62uGoxxCkgF7aDtBYF9zb6YCfjOQn0q5d7zWxydpYAb5Dn1N1hZMnjAy7mlpNdQ==", + "dependencies": { + "@miniflare/shared": "2.14.1", + "kleur": "^4.1.4" + }, + "engines": { + "node": ">=16.13" + } + }, + "node_modules/@miniflare/core": { + "version": "2.14.1", + "resolved": "https://registry.npmjs.org/@miniflare/core/-/core-2.14.1.tgz", + "integrity": "sha512-d+SGAda/VoXq+SKz04oq8ATUwQw5755L87fgPR8pTdR2YbWkxdbmEm1z2olOpDiUjcR86aN6NtCjY6tUC7fqaw==", + "dependencies": { + "@iarna/toml": "^2.2.5", + "@miniflare/queues": "2.14.1", + "@miniflare/shared": "2.14.1", + "@miniflare/watcher": "2.14.1", + "busboy": "^1.6.0", + "dotenv": "^10.0.0", + "kleur": "^4.1.4", + "set-cookie-parser": "^2.4.8", + "undici": "5.20.0", + "urlpattern-polyfill": "^4.0.3" + }, + "engines": { + "node": ">=16.13" + } + }, + "node_modules/@miniflare/core/node_modules/dotenv": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-10.0.0.tgz", + "integrity": "sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==", + "engines": { + "node": ">=10" + } + }, + "node_modules/@miniflare/core/node_modules/undici": { + "version": "5.20.0", + "resolved": "https://registry.npmjs.org/undici/-/undici-5.20.0.tgz", + "integrity": "sha512-J3j60dYzuo6Eevbawwp1sdg16k5Tf768bxYK4TUJRH7cBM4kFCbf3mOnM/0E3vQYXvpxITbbWmBafaDbxLDz3g==", + "dependencies": { + "busboy": "^1.6.0" + }, + "engines": { + "node": ">=12.18" + } + }, + "node_modules/@miniflare/d1": { + "version": "2.14.1", + "resolved": "https://registry.npmjs.org/@miniflare/d1/-/d1-2.14.1.tgz", + "integrity": "sha512-MulDDBsDD8o5DwiqdMeJZy2vLoMji+NWnLcuibSag2mayA0LJcp0eHezseZNkW+knciWR1gMP8Xpa4Q1KwkbKA==", + "dependencies": { + "@miniflare/core": "2.14.1", + "@miniflare/shared": "2.14.1" + }, + "engines": { + "node": ">=16.7" + } + }, + "node_modules/@miniflare/durable-objects": { + "version": "2.14.1", + "resolved": "https://registry.npmjs.org/@miniflare/durable-objects/-/durable-objects-2.14.1.tgz", + "integrity": "sha512-T+oHGw5GcEIilkzrf0xDES7jzLVqcXJzSGsEIWqnBFLtdlKmrZF679ulRLBbyMVgvpQz6FRONh9jTH1XIiuObQ==", + "dependencies": { + "@miniflare/core": "2.14.1", + "@miniflare/shared": "2.14.1", + "@miniflare/storage-memory": "2.14.1", + "undici": "5.20.0" + }, + "engines": { + "node": ">=16.13" + } + }, + "node_modules/@miniflare/durable-objects/node_modules/undici": { + "version": "5.20.0", + "resolved": "https://registry.npmjs.org/undici/-/undici-5.20.0.tgz", + "integrity": "sha512-J3j60dYzuo6Eevbawwp1sdg16k5Tf768bxYK4TUJRH7cBM4kFCbf3mOnM/0E3vQYXvpxITbbWmBafaDbxLDz3g==", + "dependencies": { + "busboy": "^1.6.0" + }, + "engines": { + "node": ">=12.18" + } + }, + "node_modules/@miniflare/html-rewriter": { + "version": "2.14.1", + "resolved": "https://registry.npmjs.org/@miniflare/html-rewriter/-/html-rewriter-2.14.1.tgz", + "integrity": "sha512-vp4uZXuEKhtIaxoXa7jgDAPItlzjbfoUqYWp+fwDKv4J4mfQnzzs/5hwjbE7+Ihm/KNI0zNi8P0sSWjIRFl6ng==", + "dependencies": { + "@miniflare/core": "2.14.1", + "@miniflare/shared": "2.14.1", + "html-rewriter-wasm": "^0.4.1", + "undici": "5.20.0" + }, + "engines": { + "node": ">=16.13" + } + }, + "node_modules/@miniflare/html-rewriter/node_modules/undici": { + "version": "5.20.0", + "resolved": "https://registry.npmjs.org/undici/-/undici-5.20.0.tgz", + "integrity": "sha512-J3j60dYzuo6Eevbawwp1sdg16k5Tf768bxYK4TUJRH7cBM4kFCbf3mOnM/0E3vQYXvpxITbbWmBafaDbxLDz3g==", + "dependencies": { + "busboy": "^1.6.0" + }, + "engines": { + "node": ">=12.18" + } + }, + "node_modules/@miniflare/http-server": { + "version": "2.14.1", + "resolved": "https://registry.npmjs.org/@miniflare/http-server/-/http-server-2.14.1.tgz", + "integrity": "sha512-ICT9KuecAF5+AHs9dTnk7DRxCPYLfI3QCtfHOcGQWFuOoe4MCtQk4joo0pxMaSgAJ4TiOOxz3KRWO0G2FwgiPQ==", + "dependencies": { + "@miniflare/core": "2.14.1", + "@miniflare/shared": "2.14.1", + "@miniflare/web-sockets": "2.14.1", + "kleur": "^4.1.4", + "selfsigned": "^2.0.0", + "undici": "5.20.0", + "ws": "^8.2.2", + "youch": "^2.2.2" + }, + "engines": { + "node": ">=16.13" + } + }, + "node_modules/@miniflare/http-server/node_modules/undici": { + "version": "5.20.0", + "resolved": "https://registry.npmjs.org/undici/-/undici-5.20.0.tgz", + "integrity": "sha512-J3j60dYzuo6Eevbawwp1sdg16k5Tf768bxYK4TUJRH7cBM4kFCbf3mOnM/0E3vQYXvpxITbbWmBafaDbxLDz3g==", + "dependencies": { + "busboy": "^1.6.0" + }, + "engines": { + "node": ">=12.18" + } + }, + "node_modules/@miniflare/kv": { + "version": "2.14.1", + "resolved": "https://registry.npmjs.org/@miniflare/kv/-/kv-2.14.1.tgz", + "integrity": "sha512-Gp07Wcszle7ptsoO8mCtKQRs0AbQnYo1rgnxUcsTL3xJJaHXEA/B9EKSADS2XzJMeY4PgUOHU6Rf08OOF2yWag==", + "dependencies": { + "@miniflare/shared": "2.14.1" + }, + "engines": { + "node": ">=16.13" + } + }, + "node_modules/@miniflare/queues": { + "version": "2.14.1", + "resolved": "https://registry.npmjs.org/@miniflare/queues/-/queues-2.14.1.tgz", + "integrity": "sha512-uBzrbBkIgtNoztDpmMMISg/brYtxLHRE7oTaN8OVnq3bG+3nF9kQC42HUz+Vg+sf65UlvhSaqkjllgx+fNtOxQ==", + "dependencies": { + "@miniflare/shared": "2.14.1" + }, + "engines": { + "node": ">=16.7" + } + }, + "node_modules/@miniflare/r2": { + "version": "2.14.1", + "resolved": "https://registry.npmjs.org/@miniflare/r2/-/r2-2.14.1.tgz", + "integrity": "sha512-grOMnGf2XSicbgxMYMBfWE37k/e7l5NnwXZIViQ+N06uksp+MLA8E6yKQNtvrWQS66TM8gBvMnWo96OFmYjb6Q==", + "dependencies": { + "@miniflare/core": "2.14.1", + "@miniflare/shared": "2.14.1", + "undici": "5.20.0" + }, + "engines": { + "node": ">=16.13" + } + }, + "node_modules/@miniflare/r2/node_modules/undici": { + "version": "5.20.0", + "resolved": "https://registry.npmjs.org/undici/-/undici-5.20.0.tgz", + "integrity": "sha512-J3j60dYzuo6Eevbawwp1sdg16k5Tf768bxYK4TUJRH7cBM4kFCbf3mOnM/0E3vQYXvpxITbbWmBafaDbxLDz3g==", + "dependencies": { + "busboy": "^1.6.0" + }, + "engines": { + "node": ">=12.18" + } + }, + "node_modules/@miniflare/runner-vm": { + "version": "2.14.1", + "resolved": "https://registry.npmjs.org/@miniflare/runner-vm/-/runner-vm-2.14.1.tgz", + "integrity": "sha512-UobsGM0ICVPDlJD54VPDSx0EXrIY3nJMXBy2zIFuuUOz4hQKXvMQ6jtAlJ8UNKer+XXI3Mb/9R/gfU8r6kxIMA==", + "dependencies": { + "@miniflare/shared": "2.14.1" + }, + "engines": { + "node": ">=16.13" + } + }, + "node_modules/@miniflare/scheduler": { + "version": "2.14.1", + "resolved": "https://registry.npmjs.org/@miniflare/scheduler/-/scheduler-2.14.1.tgz", + "integrity": "sha512-mCFUkGpPcV74tbDAuDLSrLPDiRei7hIIPQL53C4rtCDyLfxYgwLQFDecllQs5IvDzAx4qFpu835Ppc6tbHR5Mw==", + "dependencies": { + "@miniflare/core": "2.14.1", + "@miniflare/shared": "2.14.1", + "cron-schedule": "^3.0.4" + }, + "engines": { + "node": ">=16.13" + } + }, + "node_modules/@miniflare/shared": { + "version": "2.14.1", + "resolved": "https://registry.npmjs.org/@miniflare/shared/-/shared-2.14.1.tgz", + "integrity": "sha512-73GnLtWn5iP936ctE6ZJrMqGu134KOoIIveq5Yd/B+NnbFfzpuzjCpkLrnqjkDdsxDbruXSb5eTR/SmAdpJxZQ==", + "dependencies": { + "@types/better-sqlite3": "^7.6.0", + "kleur": "^4.1.4", + "npx-import": "^1.1.4", + "picomatch": "^2.3.1" + }, + "engines": { + "node": ">=16.13" + } + }, + "node_modules/@miniflare/sites": { + "version": "2.14.1", + "resolved": "https://registry.npmjs.org/@miniflare/sites/-/sites-2.14.1.tgz", + "integrity": "sha512-AbbIcU6VBeaNqVgMiLMWN2a09eX3jZmjaEi0uKqufVDqW/QIz47/30aC0O9qTe+XYpi3jjph/Ux7uEY8Z+enMw==", + "dependencies": { + "@miniflare/kv": "2.14.1", + "@miniflare/shared": "2.14.1", + "@miniflare/storage-file": "2.14.1" + }, + "engines": { + "node": ">=16.13" + } + }, + "node_modules/@miniflare/storage-file": { + "version": "2.14.1", + "resolved": "https://registry.npmjs.org/@miniflare/storage-file/-/storage-file-2.14.1.tgz", + "integrity": "sha512-faZu9tRSW6c/looVFI/ZhkdGsIc9NfNCbSl3jJRmm7xgyZ+/S+dQ5JtGVbVsUIX8YGWDyE2j3oWCGCjxGLEpkg==", + "dependencies": { + "@miniflare/shared": "2.14.1", + "@miniflare/storage-memory": "2.14.1" + }, + "engines": { + "node": ">=16.13" + } + }, + "node_modules/@miniflare/storage-memory": { + "version": "2.14.1", + "resolved": "https://registry.npmjs.org/@miniflare/storage-memory/-/storage-memory-2.14.1.tgz", + "integrity": "sha512-lfQbQwopVWd4W5XzrYdp0rhk3dJpvSmv1Wwn9RhNO20WrcuoxpdSzbmpBahsgYVg+OheVaEbS6RpFqdmwwLTog==", + "dependencies": { + "@miniflare/shared": "2.14.1" + }, + "engines": { + "node": ">=16.13" + } + }, + "node_modules/@miniflare/watcher": { + "version": "2.14.1", + "resolved": "https://registry.npmjs.org/@miniflare/watcher/-/watcher-2.14.1.tgz", + "integrity": "sha512-dkFvetm5wk6pwunlYb/UkI0yFNb3otLpRm5RDywMUzqObEf+rCiNNAbJe3HUspr2ncZVAaRWcEaDh82vYK5cmw==", + "dependencies": { + "@miniflare/shared": "2.14.1" + }, + "engines": { + "node": ">=16.13" + } + }, + "node_modules/@miniflare/web-sockets": { + "version": "2.14.1", + "resolved": "https://registry.npmjs.org/@miniflare/web-sockets/-/web-sockets-2.14.1.tgz", + "integrity": "sha512-3N//L5EjF7+xXd7qCLR2ylUwm8t2MKyGPGWEtRBrQ2xqYYWhewKTjlquHCOPU5Irnnd/4BhTmFA55MNrq7m4Nw==", + "dependencies": { + "@miniflare/core": "2.14.1", + "@miniflare/shared": "2.14.1", + "undici": "5.20.0", + "ws": "^8.2.2" + }, + "engines": { + "node": ">=16.13" + } + }, + "node_modules/@miniflare/web-sockets/node_modules/undici": { + "version": "5.20.0", + "resolved": "https://registry.npmjs.org/undici/-/undici-5.20.0.tgz", + "integrity": "sha512-J3j60dYzuo6Eevbawwp1sdg16k5Tf768bxYK4TUJRH7cBM4kFCbf3mOnM/0E3vQYXvpxITbbWmBafaDbxLDz3g==", + "dependencies": { + "busboy": "^1.6.0" + }, + "engines": { + "node": ">=12.18" + } + }, "node_modules/@next/env": { "version": "13.4.19", "resolved": "https://registry.npmjs.org/@next/env/-/env-13.4.19.tgz", @@ -3592,6 +3921,14 @@ "node": ">=10.13.0" } }, + "node_modules/@types/better-sqlite3": { + "version": "7.6.4", + "resolved": "https://registry.npmjs.org/@types/better-sqlite3/-/better-sqlite3-7.6.4.tgz", + "integrity": "sha512-dzrRZCYPXIXfSR1/surNbJ/grU3scTaygS0OMzjlGf71i9sc2fGyHPXXiXmEvNIoE0cGwsanEFMVJxPXmco9Eg==", + "dependencies": { + "@types/node": "*" + } + }, "node_modules/@types/debug": { "version": "4.1.8", "resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.8.tgz", @@ -3735,6 +4072,11 @@ "integrity": "sha512-G8hZ6XJiHnuhQKR7ZmysCeJWE08o8T0AXtk5darsCaTVsYZhhgUrq53jizaR2FvsoeCwJhlmwTjkXBY5Pn/ZHw==", "dev": true }, + "node_modules/@types/stack-trace": { + "version": "0.0.29", + "resolved": "https://registry.npmjs.org/@types/stack-trace/-/stack-trace-0.0.29.tgz", + "integrity": "sha512-TgfOX+mGY/NyNxJLIbDWrO9DjGoVSW9+aB8H2yy1fy32jsvxijhmyJI9fDFgvz3YP4lvJaq9DzdR/M1bOgVc9g==" + }, "node_modules/@types/unist": { "version": "2.0.7", "resolved": "https://registry.npmjs.org/@types/unist/-/unist-2.0.7.tgz", @@ -4374,6 +4716,19 @@ "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" } }, + "node_modules/buffer-from": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", + "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==" + }, + "node_modules/builtins": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/builtins/-/builtins-5.0.1.tgz", + "integrity": "sha512-qwVpFEHNfhYJIzNRBvd2C1kyo6jz3ZSMPyyuR47OPdiKWlbYnZNyDWuyR175qDnAJLiCo5fBBqPb3RiXgWlkOQ==", + "dependencies": { + "semver": "^7.0.0" + } + }, "node_modules/bundle-name": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/bundle-name/-/bundle-name-3.0.0.tgz", @@ -4686,6 +5041,11 @@ "url": "https://github.com/sponsors/d-fischer" } }, + "node_modules/cron-schedule": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/cron-schedule/-/cron-schedule-3.0.6.tgz", + "integrity": "sha512-izfGgKyzzIyLaeb1EtZ3KbglkS6AKp9cv7LxmiyoOu+fXfol1tQDC0Cof0enVZGNtudTHW+3lfuW9ZkLQss4Wg==" + }, "node_modules/cross-env": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz", @@ -6889,6 +7249,11 @@ "node": ">=12.0.0" } }, + "node_modules/html-rewriter-wasm": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/html-rewriter-wasm/-/html-rewriter-wasm-0.4.1.tgz", + "integrity": "sha512-lNovG8CMCCmcVB1Q7xggMSf7tqPCijZXaH4gL6iE8BFghdQCbaY5Met9i1x2Ex8m/cZHDUtXK9H6/znKamRP8Q==" + }, "node_modules/html-void-elements": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/html-void-elements/-/html-void-elements-3.0.0.tgz", @@ -6898,6 +7263,11 @@ "url": "https://github.com/sponsors/wooorm" } }, + "node_modules/http-cache-semantics": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.1.tgz", + "integrity": "sha512-er295DKPVsV82j5kw1Gjt+ADA/XYHsajl82cGNQG2eyoPkvgUhX+nDIyelzhIWbbsXP39EHcI6l5tYs2FYqYXQ==" + }, "node_modules/https-proxy-agent": { "version": "7.0.2", "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.2.tgz", @@ -8581,6 +8951,67 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/miniflare": { + "version": "2.14.1", + "resolved": "https://registry.npmjs.org/miniflare/-/miniflare-2.14.1.tgz", + "integrity": "sha512-8Yqms4OZp1J1k0SGhOQ6MKWptWSXCm8Yh4kfFh11zZIlT1PoE0qXWQmAzwZnT5hFNmS3tsghu3GOgToxM+jCnA==", + "dependencies": { + "@miniflare/cache": "2.14.1", + "@miniflare/cli-parser": "2.14.1", + "@miniflare/core": "2.14.1", + "@miniflare/d1": "2.14.1", + "@miniflare/durable-objects": "2.14.1", + "@miniflare/html-rewriter": "2.14.1", + "@miniflare/http-server": "2.14.1", + "@miniflare/kv": "2.14.1", + "@miniflare/queues": "2.14.1", + "@miniflare/r2": "2.14.1", + "@miniflare/runner-vm": "2.14.1", + "@miniflare/scheduler": "2.14.1", + "@miniflare/shared": "2.14.1", + "@miniflare/sites": "2.14.1", + "@miniflare/storage-file": "2.14.1", + "@miniflare/storage-memory": "2.14.1", + "@miniflare/web-sockets": "2.14.1", + "kleur": "^4.1.4", + "semiver": "^1.1.0", + "source-map-support": "^0.5.20", + "undici": "5.20.0" + }, + "bin": { + "miniflare": "bootstrap.js" + }, + "engines": { + "node": ">=16.13" + }, + "peerDependencies": { + "@miniflare/storage-redis": "2.14.1", + "cron-schedule": "^3.0.4", + "ioredis": "^4.27.9" + }, + "peerDependenciesMeta": { + "@miniflare/storage-redis": { + "optional": true + }, + "cron-schedule": { + "optional": true + }, + "ioredis": { + "optional": true + } + } + }, + "node_modules/miniflare/node_modules/undici": { + "version": "5.20.0", + "resolved": "https://registry.npmjs.org/undici/-/undici-5.20.0.tgz", + "integrity": "sha512-J3j60dYzuo6Eevbawwp1sdg16k5Tf768bxYK4TUJRH7cBM4kFCbf3mOnM/0E3vQYXvpxITbbWmBafaDbxLDz3g==", + "dependencies": { + "busboy": "^1.6.0" + }, + "engines": { + "node": ">=12.18" + } + }, "node_modules/minimatch": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", @@ -8613,6 +9044,14 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, + "node_modules/mustache": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/mustache/-/mustache-4.2.0.tgz", + "integrity": "sha512-71ippSywq5Yb7/tVYyGbkBggbU8H3u5Rz56fH60jGFgr8uHwxs+aSKeqmluIVzM0m0kB7xQjKS6qPfd0b2ZoqQ==", + "bin": { + "mustache": "bin/mustache" + } + }, "node_modules/mz": { "version": "2.7.0", "resolved": "https://registry.npmjs.org/mz/-/mz-2.7.0.tgz", @@ -8797,6 +9236,14 @@ "tslib": "^2.0.3" } }, + "node_modules/node-forge": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-1.3.1.tgz", + "integrity": "sha512-dPEtOeMvF9VMcYV/1Wb8CPoVAXtp6MKMlcbAt4ddqmGqUJ6fQZFXkNZNkNlfevtNkGtaSoXf/vNNNSvgrdXwtA==", + "engines": { + "node": ">= 6.13.0" + } + }, "node_modules/node-imei": { "version": "1.0.8", "resolved": "https://registry.npmjs.org/node-imei/-/node-imei-1.0.8.tgz", @@ -8848,6 +9295,47 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/npx-import": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/npx-import/-/npx-import-1.1.4.tgz", + "integrity": "sha512-3ShymTWOgqGyNlh5lMJAejLuIv3W1K3fbI5Ewc6YErZU3Sp0PqsNs8UIU1O8z5+KVl/Du5ag56Gza9vdorGEoA==", + "dependencies": { + "execa": "^6.1.0", + "parse-package-name": "^1.0.0", + "semver": "^7.3.7", + "validate-npm-package-name": "^4.0.0" + } + }, + "node_modules/npx-import/node_modules/execa": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/execa/-/execa-6.1.0.tgz", + "integrity": "sha512-QVWlX2e50heYJcCPG0iWtf8r0xjEYfz/OYLGDYH+IyjWezzPNxz63qNFOu0l4YftGWuizFVZHHs8PrLU5p2IDA==", + "dependencies": { + "cross-spawn": "^7.0.3", + "get-stream": "^6.0.1", + "human-signals": "^3.0.1", + "is-stream": "^3.0.0", + "merge-stream": "^2.0.0", + "npm-run-path": "^5.1.0", + "onetime": "^6.0.0", + "signal-exit": "^3.0.7", + "strip-final-newline": "^3.0.0" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sindresorhus/execa?sponsor=1" + } + }, + "node_modules/npx-import/node_modules/human-signals": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-3.0.1.tgz", + "integrity": "sha512-rQLskxnM/5OCldHo+wNXbpVgDn5A17CUoKX+7Sokwaknlq7CdSnphy0W39GU8dw59XiCXmFXDg4fRuckQRKewQ==", + "engines": { + "node": ">=12.20.0" + } + }, "node_modules/nth-check": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-2.1.1.tgz", @@ -9148,6 +9636,11 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/parse-package-name": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/parse-package-name/-/parse-package-name-1.0.0.tgz", + "integrity": "sha512-kBeTUtcj+SkyfaW4+KBe0HtsloBJ/mKTPoxpVdA57GZiPerREsUWJOhVj9anXweFiJkm5y8FG1sxFZkZ0SN6wg==" + }, "node_modules/parse5": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/parse5/-/parse5-7.1.2.tgz", @@ -10366,6 +10859,25 @@ "loose-envify": "^1.1.0" } }, + "node_modules/selfsigned": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/selfsigned/-/selfsigned-2.1.1.tgz", + "integrity": "sha512-GSL3aowiF7wa/WtSFwnUrludWFoNhftq8bUkH9pkzjpN2XSPOAYEgg6e0sS9s0rZwgJzJiQRPU18A6clnoW5wQ==", + "dependencies": { + "node-forge": "^1" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/semiver": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/semiver/-/semiver-1.1.0.tgz", + "integrity": "sha512-QNI2ChmuioGC1/xjyYwyZYADILWyW6AmS1UH6gDj/SFUUUS4MBAWs/7mxnkRPc/F4iHezDP+O8t0dO8WHiEOdg==", + "engines": { + "node": ">=6" + } + }, "node_modules/semver": { "version": "7.5.4", "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", @@ -10380,6 +10892,11 @@ "node": ">=10" } }, + "node_modules/set-cookie-parser": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/set-cookie-parser/-/set-cookie-parser-2.6.0.tgz", + "integrity": "sha512-RVnVQxTXuerk653XfuliOxBP81Sf0+qfQE73LIYKcyMYHG94AuH0kgrQpRDuTZnSmjpysHmzxJXKNfa6PjFhyQ==" + }, "node_modules/shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", @@ -10435,6 +10952,14 @@ "tslib": "^2.0.3" } }, + "node_modules/source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/source-map-js": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz", @@ -10443,6 +10968,15 @@ "node": ">=0.10.0" } }, + "node_modules/source-map-support": { + "version": "0.5.21", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", + "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", + "dependencies": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } + }, "node_modules/space-separated-tokens": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/space-separated-tokens/-/space-separated-tokens-2.0.2.tgz", @@ -10452,6 +10986,14 @@ "url": "https://github.com/sponsors/wooorm" } }, + "node_modules/stack-trace": { + "version": "0.0.10", + "resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.10.tgz", + "integrity": "sha512-KGzahc7puUKkzyMt+IqAep+TVNbKP+k2Lmwhub39m1AsTSkaDutx56aDCo+HLDzf/D26BIHTJWNiTG1KAJiQCg==", + "engines": { + "node": "*" + } + }, "node_modules/streamsearch": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-1.1.0.tgz", @@ -11210,6 +11752,11 @@ "punycode": "^2.1.0" } }, + "node_modules/urlpattern-polyfill": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/urlpattern-polyfill/-/urlpattern-polyfill-4.0.3.tgz", + "integrity": "sha512-DOE84vZT2fEcl9gqCUTcnAw5ZY5Id55ikUcziSUntuEFL3pRvavg5kwDmTEUJkeCHInTlV/HexFomgYnzO5kdQ==" + }, "node_modules/use-callback-ref": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/use-callback-ref/-/use-callback-ref-1.3.0.tgz", @@ -11310,6 +11857,17 @@ "node": ">=8" } }, + "node_modules/validate-npm-package-name": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/validate-npm-package-name/-/validate-npm-package-name-4.0.0.tgz", + "integrity": "sha512-mzR0L8ZDktZjpX4OB46KT+56MAhl4EIazWP/+G/HPGuvfdaqg4YsCdtOm6U9+LOFyYDoh4dpnpxZRB9MQQns5Q==", + "dependencies": { + "builtins": "^5.0.0" + }, + "engines": { + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" + } + }, "node_modules/vfile": { "version": "5.3.7", "resolved": "https://registry.npmjs.org/vfile/-/vfile-5.3.7.tgz", @@ -11557,6 +12115,25 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/youch": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/youch/-/youch-2.2.2.tgz", + "integrity": "sha512-/FaCeG3GkuJwaMR34GHVg0l8jCbafZLHiFowSjqLlqhC6OMyf2tPJBu8UirF7/NI9X/R5ai4QfEKUCOxMAGxZQ==", + "dependencies": { + "@types/stack-trace": "0.0.29", + "cookie": "^0.4.1", + "mustache": "^4.2.0", + "stack-trace": "0.0.10" + } + }, + "node_modules/youch/node_modules/cookie": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.2.tgz", + "integrity": "sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA==", + "engines": { + "node": ">= 0.6" + } + }, "node_modules/zod": { "version": "3.21.4", "resolved": "https://registry.npmjs.org/zod/-/zod-3.21.4.tgz", diff --git a/package.json b/package.json index dfb7330d..98a2e5c7 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "name": "bingo", "version": "0.7.0", "private": true, + "main": "./cloudflare/cli.js", "scripts": { "dev": "cross-env DEBUG=bingo* next dev --hostname 0.0.0.0", "build": "next build", @@ -39,6 +40,7 @@ "js-base64": "^3.7.5", "lodash": "^4.17.21", "md5": "^2.3.0", + "miniflare": "^2.14.1", "namestorage": "^1.3.0", "nanoid": "^4.0.2", "next": "13.4.19",