Upload 21 files
Browse files- .editorconfig +12 -0
- .github/workflows/main.yml +31 -0
- .gitignore +179 -0
- .prettierrc +6 -0
- LICENSE +21 -0
- README.md +189 -10
- iptest/iiptest.ts +89 -0
- package-lock.json +0 -0
- package.json +23 -0
- rollup.config.pages.mjs +27 -0
- rollup.config.workers.mjs +27 -0
- src/html/index.html +90 -0
- src/pages.ts +6 -0
- src/proxy/bingPorxyWorker.ts +61 -0
- src/proxy/usIps.json +0 -0
- src/workers.ts +8 -0
- tsconfig.json +104 -0
- typings.d.ts +4 -0
- vitest.config.ts +11 -0
- worker-configuration.d.ts +5 -0
- wrangler.toml +108 -0
.editorconfig
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# http://editorconfig.org
|
2 |
+
root = true
|
3 |
+
|
4 |
+
[*]
|
5 |
+
indent_style = tab
|
6 |
+
end_of_line = lf
|
7 |
+
charset = utf-8
|
8 |
+
trim_trailing_whitespace = true
|
9 |
+
insert_final_newline = true
|
10 |
+
|
11 |
+
[*.yml]
|
12 |
+
indent_style = space
|
.github/workflows/main.yml
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: Cloudfalre Worker Deploy
|
2 |
+
on:
|
3 |
+
push:
|
4 |
+
branches:
|
5 |
+
- master
|
6 |
+
repository_dispatch:
|
7 |
+
workflow_dispatch:
|
8 |
+
|
9 |
+
jobs:
|
10 |
+
deploy:
|
11 |
+
runs-on: ubuntu-latest
|
12 |
+
timeout-minutes: 60
|
13 |
+
steps:
|
14 |
+
- name: Checkout
|
15 |
+
uses: actions/[email protected]
|
16 |
+
- name: Setup pnpm
|
17 |
+
uses: pnpm/[email protected]
|
18 |
+
with:
|
19 |
+
run_install: true
|
20 |
+
version: 9
|
21 |
+
- name: build - 构建
|
22 |
+
run: pnpm run build-worker
|
23 |
+
- name: Deploy to Cloudflare Workers with Wrangler
|
24 |
+
uses: cloudflare/[email protected]
|
25 |
+
with:
|
26 |
+
# Your Cloudflare API Token
|
27 |
+
apiToken: ${{ secrets.CF_API_TOKEN }} # optional
|
28 |
+
# Your Cloudflare Account ID
|
29 |
+
accountId: ${{ secrets.CF_ACCOUNT_ID }} # optional
|
30 |
+
# The Wrangler command (along with any arguments) you wish to run. Multiple Wrangler commands can be run by separating each command with a newline. Defaults to `"deploy"`.
|
31 |
+
command: 'deploy --keep-vars'
|
.gitignore
ADDED
@@ -0,0 +1,179 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Logs
|
2 |
+
|
3 |
+
logs
|
4 |
+
_.log
|
5 |
+
npm-debug.log_
|
6 |
+
yarn-debug.log*
|
7 |
+
yarn-error.log*
|
8 |
+
lerna-debug.log*
|
9 |
+
.pnpm-debug.log*
|
10 |
+
|
11 |
+
# Diagnostic reports (https://nodejs.org/api/report.html)
|
12 |
+
|
13 |
+
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
|
14 |
+
|
15 |
+
# Runtime data
|
16 |
+
|
17 |
+
pids
|
18 |
+
_.pid
|
19 |
+
_.seed
|
20 |
+
\*.pid.lock
|
21 |
+
|
22 |
+
# Directory for instrumented libs generated by jscoverage/JSCover
|
23 |
+
|
24 |
+
lib-cov
|
25 |
+
|
26 |
+
# Coverage directory used by tools like istanbul
|
27 |
+
|
28 |
+
coverage
|
29 |
+
\*.lcov
|
30 |
+
|
31 |
+
# nyc test coverage
|
32 |
+
|
33 |
+
.nyc_output
|
34 |
+
|
35 |
+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
36 |
+
|
37 |
+
.grunt
|
38 |
+
|
39 |
+
# Bower dependency directory (https://bower.io/)
|
40 |
+
|
41 |
+
bower_components
|
42 |
+
|
43 |
+
# node-waf configuration
|
44 |
+
|
45 |
+
.lock-wscript
|
46 |
+
|
47 |
+
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
48 |
+
|
49 |
+
build/Release
|
50 |
+
|
51 |
+
# Dependency directories
|
52 |
+
|
53 |
+
node_modules/
|
54 |
+
jspm_packages/
|
55 |
+
|
56 |
+
# Snowpack dependency directory (https://snowpack.dev/)
|
57 |
+
|
58 |
+
web_modules/
|
59 |
+
|
60 |
+
# TypeScript cache
|
61 |
+
|
62 |
+
\*.tsbuildinfo
|
63 |
+
|
64 |
+
# Optional npm cache directory
|
65 |
+
|
66 |
+
.npm
|
67 |
+
|
68 |
+
# Optional eslint cache
|
69 |
+
|
70 |
+
.eslintcache
|
71 |
+
|
72 |
+
# Optional stylelint cache
|
73 |
+
|
74 |
+
.stylelintcache
|
75 |
+
|
76 |
+
# Microbundle cache
|
77 |
+
|
78 |
+
.rpt2_cache/
|
79 |
+
.rts2_cache_cjs/
|
80 |
+
.rts2_cache_es/
|
81 |
+
.rts2_cache_umd/
|
82 |
+
|
83 |
+
# Optional REPL history
|
84 |
+
|
85 |
+
.node_repl_history
|
86 |
+
|
87 |
+
# Output of 'npm pack'
|
88 |
+
|
89 |
+
\*.tgz
|
90 |
+
|
91 |
+
# Yarn Integrity file
|
92 |
+
|
93 |
+
.yarn-integrity
|
94 |
+
|
95 |
+
# dotenv environment variable files
|
96 |
+
|
97 |
+
.env
|
98 |
+
.env.development.local
|
99 |
+
.env.test.local
|
100 |
+
.env.production.local
|
101 |
+
.env.local
|
102 |
+
|
103 |
+
# parcel-bundler cache (https://parceljs.org/)
|
104 |
+
|
105 |
+
.cache
|
106 |
+
.parcel-cache
|
107 |
+
|
108 |
+
# Next.js build output
|
109 |
+
|
110 |
+
.next
|
111 |
+
out
|
112 |
+
|
113 |
+
# Nuxt.js build / generate output
|
114 |
+
|
115 |
+
.nuxt
|
116 |
+
dist
|
117 |
+
|
118 |
+
# Gatsby files
|
119 |
+
|
120 |
+
.cache/
|
121 |
+
|
122 |
+
# Comment in the public line in if your project uses Gatsby and not Next.js
|
123 |
+
|
124 |
+
# https://nextjs.org/blog/next-9-1#public-directory-support
|
125 |
+
|
126 |
+
# public
|
127 |
+
|
128 |
+
# vuepress build output
|
129 |
+
|
130 |
+
.vuepress/dist
|
131 |
+
|
132 |
+
# vuepress v2.x temp and cache directory
|
133 |
+
|
134 |
+
.temp
|
135 |
+
.cache
|
136 |
+
|
137 |
+
# Docusaurus cache and generated files
|
138 |
+
|
139 |
+
.docusaurus
|
140 |
+
|
141 |
+
# Serverless directories
|
142 |
+
|
143 |
+
.serverless/
|
144 |
+
|
145 |
+
# FuseBox cache
|
146 |
+
|
147 |
+
.fusebox/
|
148 |
+
|
149 |
+
# DynamoDB Local files
|
150 |
+
|
151 |
+
.dynamodb/
|
152 |
+
|
153 |
+
# TernJS port file
|
154 |
+
|
155 |
+
.tern-port
|
156 |
+
|
157 |
+
# Stores VSCode versions used for testing VSCode extensions
|
158 |
+
|
159 |
+
.vscode-test
|
160 |
+
|
161 |
+
# yarn v2
|
162 |
+
|
163 |
+
.yarn/cache
|
164 |
+
.yarn/unplugged
|
165 |
+
.yarn/build-state.yml
|
166 |
+
.yarn/install-state.gz
|
167 |
+
.pnp.\*
|
168 |
+
|
169 |
+
# wrangler project
|
170 |
+
|
171 |
+
.dev.vars
|
172 |
+
.wrangler/
|
173 |
+
|
174 |
+
iptest/iiptest.js
|
175 |
+
iptest/iiptest/iiptest*.txt
|
176 |
+
functions/
|
177 |
+
go-bingai-pass.wasm
|
178 |
+
|
179 |
+
.idea
|
.prettierrc
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"printWidth": 140,
|
3 |
+
"singleQuote": true,
|
4 |
+
"semi": true,
|
5 |
+
"useTabs": true
|
6 |
+
}
|
LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
MIT License
|
2 |
+
|
3 |
+
Copyright (c) 2024 jianjianai
|
4 |
+
|
5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6 |
+
of this software and associated documentation files (the "Software"), to deal
|
7 |
+
in the Software without restriction, including without limitation the rights
|
8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9 |
+
copies of the Software, and to permit persons to whom the Software is
|
10 |
+
furnished to do so, subject to the following conditions:
|
11 |
+
|
12 |
+
The above copyright notice and this permission notice shall be included in all
|
13 |
+
copies or substantial portions of the Software.
|
14 |
+
|
15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21 |
+
SOFTWARE.
|
README.md
CHANGED
@@ -1,10 +1,189 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# microsoft-copilot-play-app
|
2 |
+
## 简介
|
3 |
+
|
4 |
+
**Cloudflare Worker 的 Microsoft Copilot 加速服务 app。**
|
5 |
+
|
6 |
+
**Microsoft Copilot 是基于 OpenAI GPT-4 的强大 AI 并且能够使用 Bing 搜索来解答问题。**
|
7 |
+
|
8 |
+
**简单部署即可在国内高速使用原滋原味的 Microsoft Copilot 的几乎全部功能,聊天,笔记本,插件,图像生成,分享等等..**
|
9 |
+
|
10 |
+
|
11 |
+

|
12 |
+
|
13 |
+
|
14 |
+
|
15 |
+
## 亮点
|
16 |
+
- 🎉可在国内高速访问
|
17 |
+
- 🚀cloudflare worker一件部署无需其他操作,完全免费无限制
|
18 |
+
- ⚡高速访问,cloudflare是全球最大的CDN
|
19 |
+
|
20 |
+
## 演示站
|
21 |
+
- Copilot -> https://copilot.6m6c.cn/
|
22 |
+
|
23 |
+
|
24 |
+
## CloudFlare Pages 部署
|
25 |
+
<details>
|
26 |
+
<summary>详细教学,点击展开</summary>
|
27 |
+
|
28 |
+
1.Fork此仓库
|
29 |
+
|
30 |
+

|
31 |
+

|
32 |
+
|
33 |
+
2. Page连接到GitHub
|
34 |
+
|
35 |
+

|
36 |
+

|
37 |
+

|
38 |
+

|
39 |
+

|
40 |
+
|
41 |
+
3. 设置设置仓库
|
42 |
+
|
43 |
+
输入构建命令
|
44 |
+
``` shell
|
45 |
+
npm run build-page
|
46 |
+
```
|
47 |
+

|
48 |
+
|
49 |
+
之后就完成了。
|
50 |
+

|
51 |
+
|
52 |
+
|
53 |
+
4. 后续更新
|
54 |
+
|
55 |
+
同步 github 仓库后 Workers 和 Pages 会自动同步更新。
|
56 |
+
|
57 |
+

|
58 |
+
</details>
|
59 |
+
|
60 |
+
|
61 |
+
## CloudFlare Worker 部署
|
62 |
+
### 自动部署 (不熟悉开发流程的小伙伴推荐)
|
63 |
+
[](https://deploy.workers.cloudflare.com/?url=https://github.com/jianjianai/microsoft-copilot-porxy)
|
64 |
+
<details>
|
65 |
+
<summary>详细教学,点击展开</summary>
|
66 |
+
|
67 |
+
|
68 |
+
1. 点击这个部署按钮
|
69 |
+
|
70 |
+
[](https://deploy.workers.cloudflare.com/?url=https://github.com/jianjianai/microsoft-copilot-porxy)
|
71 |
+
|
72 |
+
2. 在打开的页面点击`Authorize Workers`
|
73 |
+
|
74 |
+

|
75 |
+
|
76 |
+
3. 如果有 Cloudflare 账号则点击 `I have an account` 如果没有则点击 `Create account` 去创建一个。
|
77 |
+
|
78 |
+

|
79 |
+
|
80 |
+
4. 去复制账户id
|
81 |
+
|
82 |
+

|
83 |
+
|
84 |
+

|
85 |
+
|
86 |
+
5. 去创建APIKEY
|
87 |
+
|
88 |
+

|
89 |
+
|
90 |
+

|
91 |
+
|
92 |
+

|
93 |
+
|
94 |
+

|
95 |
+
|
96 |
+

|
97 |
+
|
98 |
+

|
99 |
+
|
100 |
+
5. 连接账户
|
101 |
+
|
102 |
+

|
103 |
+
|
104 |
+
6. Fork repository
|
105 |
+
|
106 |
+

|
107 |
+
|
108 |
+
8. 启用 GitHub Actions
|
109 |
+
|
110 |
+

|
111 |
+
|
112 |
+

|
113 |
+
|
114 |
+

|
115 |
+
|
116 |
+
9. 部署
|
117 |
+
|
118 |
+

|
119 |
+
|
120 |
+
10. 成功
|
121 |
+
|
122 |
+

|
123 |
+
|
124 |
+
11. 管理页面出现新的 Workers 和 Pages 后续可以进行其他设置。
|
125 |
+
|
126 |
+

|
127 |
+
|
128 |
+
12. 添加自定义域
|
129 |
+
|
130 |
+

|
131 |
+
|
132 |
+
|
133 |
+
> **默认的 `.workers.dev` 国内已被限制访问,需要使用自定义域才可正常访问。**
|
134 |
+
> 具体方法请[点击此处](https://www.bing.com/search?q=cloudflare+workers+%E6%B7%BB%E5%8A%A0%E8%87%AA%E5%AE%9A%E4%B9%89%E5%9F%9F%E5%90%8D)查找
|
135 |
+
|
136 |
+
|
137 |
+
> **免费自定义域名可以参考这个视频的 3分54秒 后的免费域名部分**
|
138 |
+
> 【精准空降到 03:54】 https://www.bilibili.com/video/BV1Dy41187dv/?share_source=copy_web&vd_source=92a3be464320d250ae4c097a77339ef5&t=234
|
139 |
+
|
140 |
+
13 后续更新
|
141 |
+
|
142 |
+
同步 github 仓库后 Workers 和 Pages 会自动同步更新。
|
143 |
+
|
144 |
+

|
145 |
+
|
146 |
+
|
147 |
+
</details>
|
148 |
+
|
149 |
+
### 手动部署
|
150 |
+
<details>
|
151 |
+
<summary>点击展开</summary>
|
152 |
+
|
153 |
+
### 环境
|
154 |
+
|名称|下载地址|
|
155 |
+
|-|-|
|
156 |
+
|wget|```apt install wget```|
|
157 |
+
|git|https://git-scm.com/download|
|
158 |
+
|nodejs|https://nodejs.org|
|
159 |
+
|
160 |
+
|
161 |
+
### 命令
|
162 |
+
- 1.下载源代码
|
163 |
+
``` shell
|
164 |
+
git clone https://github.com/jianjianai/microsoft-copilot-porxy
|
165 |
+
```
|
166 |
+
- 2.进入源代码目录
|
167 |
+
``` shell
|
168 |
+
cd microsoft-copilot-porxy
|
169 |
+
```
|
170 |
+
- 3.安装依赖包
|
171 |
+
``` shell
|
172 |
+
npm install
|
173 |
+
```
|
174 |
+
- 4.编译部署
|
175 |
+
``` shell
|
176 |
+
npm run deploy
|
177 |
+
```
|
178 |
+
|
179 |
+
<details>
|
180 |
+
|
181 |
+
- [神奇小破站](https://jjaw.cn/)
|
182 |
+
|
183 |
+
</details>
|
184 |
+
|
185 |
+
</details>
|
186 |
+
|
187 |
+
|
188 |
+
## 交流社区
|
189 |
+
- QQ群: 829264603
|
iptest/iiptest.ts
ADDED
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { appendFile,mkdirSync,existsSync } from "fs";
|
2 |
+
(()=>{
|
3 |
+
if(!existsSync(`${__dirname}/iiptest`)){
|
4 |
+
mkdirSync(`${__dirname}/iiptest`)
|
5 |
+
}
|
6 |
+
})();
|
7 |
+
|
8 |
+
const isipok=async (ip:string)=>{
|
9 |
+
const ret = await fetch("https://copilot.microsoft.com/",{
|
10 |
+
headers:{
|
11 |
+
"Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
|
12 |
+
"Accept-Language":"zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
|
13 |
+
"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36 Edg/125.0.0.0",
|
14 |
+
"X-forwarded-for": ip
|
15 |
+
}
|
16 |
+
});
|
17 |
+
if(!ret.ok){
|
18 |
+
console.log(ip,false);
|
19 |
+
return false;
|
20 |
+
}
|
21 |
+
const txt = await ret.text();
|
22 |
+
if(txt.indexOf('<div class="title" role="heading" aria-level="1">登录以体验 Microsoft Copilot</div>')>=0){
|
23 |
+
console.log(ip,"ddddddddddd");
|
24 |
+
return false;
|
25 |
+
}
|
26 |
+
|
27 |
+
const rt = /Region:"(.*?)"/.exec(txt);
|
28 |
+
if(!rt){
|
29 |
+
console.log(ip,false);
|
30 |
+
return false;
|
31 |
+
}
|
32 |
+
const rg = rt[1];
|
33 |
+
if(!rg){
|
34 |
+
console.log(ip,false);
|
35 |
+
return false;
|
36 |
+
}
|
37 |
+
console.log(ip,rg);
|
38 |
+
appendFile(`${__dirname}/iiptest/iiptest.txt`,`${ip} ${rg}\n`,(error)=>{if(error){console.log(error)}});
|
39 |
+
appendFile(`${__dirname}/iiptest/iiptest-${rg}.txt`,`${ip} ${rg}\n`,(error)=>{if(error){console.log(error)}});
|
40 |
+
return true;
|
41 |
+
}
|
42 |
+
|
43 |
+
const testAll = async (i:number,i0:number,i1:number,i2:number)=>{
|
44 |
+
const testNext = async()=>{
|
45 |
+
i2++;
|
46 |
+
if(i2>255){
|
47 |
+
i2 = 1;
|
48 |
+
i1++;
|
49 |
+
}
|
50 |
+
if(i1>255){
|
51 |
+
i1 = 1;
|
52 |
+
i0++;
|
53 |
+
}
|
54 |
+
if(i0>255){
|
55 |
+
i0 = 1;
|
56 |
+
i++;
|
57 |
+
}
|
58 |
+
if(i>255){
|
59 |
+
return false;
|
60 |
+
}
|
61 |
+
const XForwardedForIP = `${i}.${i0}.${i1}.${i2}`;
|
62 |
+
try{
|
63 |
+
await isipok(XForwardedForIP);
|
64 |
+
}catch(error){
|
65 |
+
console.error(error);
|
66 |
+
}
|
67 |
+
return true;
|
68 |
+
}
|
69 |
+
let count = 0;
|
70 |
+
let stop = false;
|
71 |
+
while(true){
|
72 |
+
while(count>=16){
|
73 |
+
await new Promise((t)=>{setTimeout(t,100)});
|
74 |
+
}
|
75 |
+
count++;
|
76 |
+
testNext().then((rt)=>{
|
77 |
+
count--;
|
78 |
+
if(!rt){
|
79 |
+
stop = true;
|
80 |
+
}
|
81 |
+
});
|
82 |
+
if(stop){
|
83 |
+
break;
|
84 |
+
}
|
85 |
+
}
|
86 |
+
}
|
87 |
+
testAll(104,28,1,1);
|
88 |
+
|
89 |
+
|
package-lock.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
package.json
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "microsoft-copilot-porxy",
|
3 |
+
"version": "0.0.0",
|
4 |
+
"private": true,
|
5 |
+
"scripts": {
|
6 |
+
"deploy": "npm run build-worker && wrangler deploy",
|
7 |
+
"dev": "wrangler dev",
|
8 |
+
"build-worker": "rollup --config rollup.config.workers.mjs",
|
9 |
+
"build-page": "rollup --config rollup.config.pages.mjs",
|
10 |
+
"iptest": "npx tsc ./iptest/iiptest.ts && node ./iptest/iiptest.js"
|
11 |
+
},
|
12 |
+
"devDependencies": {
|
13 |
+
"@ampproject/rollup-plugin-closure-compiler": "^0.27.0",
|
14 |
+
"@cloudflare/vitest-pool-workers": "^0.1.0",
|
15 |
+
"@cloudflare/workers-types": "^4.20240524.0",
|
16 |
+
"@rollup/plugin-json": "^6.1.0",
|
17 |
+
"@rollup/plugin-typescript": "^11.1.6",
|
18 |
+
"rollup": "^4.18.0",
|
19 |
+
"rollup-plugin-html": "^0.2.1",
|
20 |
+
"typescript": "^5.0.4",
|
21 |
+
"wrangler": "^3.0.0"
|
22 |
+
}
|
23 |
+
}
|
rollup.config.pages.mjs
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import json from '@rollup/plugin-json';
|
2 |
+
import typescript from '@rollup/plugin-typescript';
|
3 |
+
import html from 'rollup-plugin-html';
|
4 |
+
import compiler from '@ampproject/rollup-plugin-closure-compiler';
|
5 |
+
|
6 |
+
// rollup.config.mjs
|
7 |
+
// ---cut-start---
|
8 |
+
/** @type {import('rollup').RollupOptions} */
|
9 |
+
// ---cut-end---
|
10 |
+
export default {
|
11 |
+
input: 'src/pages.ts',
|
12 |
+
output: [
|
13 |
+
{
|
14 |
+
file: 'functions/_middleware.js',
|
15 |
+
format: 'es'
|
16 |
+
}
|
17 |
+
],
|
18 |
+
plugins:[
|
19 |
+
typescript(),
|
20 |
+
json(),
|
21 |
+
html({
|
22 |
+
include: '**/*.html'
|
23 |
+
}),
|
24 |
+
compiler(),
|
25 |
+
],
|
26 |
+
external:id=>(id.endsWith(".wasm"))
|
27 |
+
};
|
rollup.config.workers.mjs
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import json from '@rollup/plugin-json';
|
2 |
+
import typescript from '@rollup/plugin-typescript';
|
3 |
+
import html from 'rollup-plugin-html';
|
4 |
+
import compiler from '@ampproject/rollup-plugin-closure-compiler';
|
5 |
+
|
6 |
+
// rollup.config.mjs
|
7 |
+
// ---cut-start---
|
8 |
+
/** @type {import('rollup').RollupOptions} */
|
9 |
+
// ---cut-end---
|
10 |
+
export default {
|
11 |
+
input: 'src/workers.ts',
|
12 |
+
output: [
|
13 |
+
{
|
14 |
+
file: 'dist/index.js',
|
15 |
+
format: 'es',
|
16 |
+
}
|
17 |
+
],
|
18 |
+
plugins:[
|
19 |
+
typescript(),
|
20 |
+
json(),
|
21 |
+
html({
|
22 |
+
include: '**/*.html'
|
23 |
+
}),
|
24 |
+
compiler(),
|
25 |
+
],
|
26 |
+
external:id=>(id.endsWith(".wasm"))
|
27 |
+
};
|
src/html/index.html
ADDED
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
|
4 |
+
<head>
|
5 |
+
<meta charset="UTF-8">
|
6 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
7 |
+
<title>ms-copilot-play-app</title>
|
8 |
+
<style>
|
9 |
+
html,
|
10 |
+
body {
|
11 |
+
border: 0;
|
12 |
+
padding: 0;
|
13 |
+
margin: 0;
|
14 |
+
background-color: antiquewhite;
|
15 |
+
overflow: hidden;
|
16 |
+
}
|
17 |
+
|
18 |
+
:root {
|
19 |
+
font-size: 16px;
|
20 |
+
}
|
21 |
+
|
22 |
+
.input-group {
|
23 |
+
margin-bottom: 1rem;
|
24 |
+
display: flex;
|
25 |
+
flex-direction: column;
|
26 |
+
}
|
27 |
+
|
28 |
+
.input-group label {
|
29 |
+
font-weight: bold;
|
30 |
+
margin-bottom: 0.5rem;
|
31 |
+
color: #333;
|
32 |
+
}
|
33 |
+
|
34 |
+
.input-group input {
|
35 |
+
padding: 0.5rem;
|
36 |
+
border: 1px solid #ccc;
|
37 |
+
border-radius: 4px;
|
38 |
+
font-size: 1rem;
|
39 |
+
transition: border-color 0.3s ease;
|
40 |
+
}
|
41 |
+
|
42 |
+
.input-group input:focus {
|
43 |
+
border-color: #007BFF;
|
44 |
+
outline: none;
|
45 |
+
}
|
46 |
+
|
47 |
+
.input-group input::placeholder {
|
48 |
+
color: #aaa;
|
49 |
+
}
|
50 |
+
|
51 |
+
.input-box {
|
52 |
+
position: absolute;
|
53 |
+
top: 50%;
|
54 |
+
left: 50%;
|
55 |
+
transform: translate(-50%, -50%);
|
56 |
+
width: 25rem;
|
57 |
+
height: 30rem;
|
58 |
+
background-color: rgb(255, 255, 255);
|
59 |
+
padding: 1rem;
|
60 |
+
border-radius: 1rem;
|
61 |
+
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1), 0 6px 20px rgba(0, 0, 0, 0.1);
|
62 |
+
display: flex;
|
63 |
+
flex-direction: column;
|
64 |
+
}
|
65 |
+
</style>
|
66 |
+
</head>
|
67 |
+
|
68 |
+
<body>
|
69 |
+
<div class="input-box">
|
70 |
+
<div class="input-group">
|
71 |
+
<label>初始设置</label>
|
72 |
+
</div>
|
73 |
+
<div class="input-group">
|
74 |
+
<label for="proxyHost">PHOST</label>
|
75 |
+
<input id="proxyHost" type="text" placeholder="Enter proxy host" value="${PHOST}" readonly/>
|
76 |
+
</div>
|
77 |
+
<div class="input-group">
|
78 |
+
<label for="proxyFIP">FIP</label>
|
79 |
+
<input id="proxyFIP" type="text" placeholder="Enter proxy FIP" value="${FIP}" readonly/>
|
80 |
+
</div>
|
81 |
+
<div class="input-group" style="flex: 1;height: 100%;"></div>
|
82 |
+
<div class="input-group">
|
83 |
+
<label style="text-align: center;">第一步下载app <a href="https://github.com/jianjianai/ms-copilot-play/releases/" target="_blank">前往下载</a></label>
|
84 |
+
<label style="text-align: center;">第二步输入如上配置</label>
|
85 |
+
<label style="text-align: center;">设置完成开始愉快玩耍!</label>
|
86 |
+
</div>
|
87 |
+
</div>
|
88 |
+
</body>
|
89 |
+
|
90 |
+
</html>
|
src/pages.ts
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { bingPorxyWorker } from "./proxy/bingPorxyWorker";
|
2 |
+
|
3 |
+
export async function onRequest(context:EventContext<Env,string,any>):Promise<Response>{
|
4 |
+
const { request, env } = context;
|
5 |
+
return bingPorxyWorker(request, env);
|
6 |
+
}
|
src/proxy/bingPorxyWorker.ts
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import indexHTML from '../html/index.html'
|
2 |
+
import fips from './usIps.json'
|
3 |
+
|
4 |
+
function getFIP():string{
|
5 |
+
return fips[Math.floor(Math.random() * fips.length)][0];
|
6 |
+
}
|
7 |
+
/** CORS */
|
8 |
+
function handleOptions(request: Request) {
|
9 |
+
const corsHeaders = {
|
10 |
+
// 'Access-Control-Allow-Origin': "*",
|
11 |
+
'Access-Control-Allow-Origin': request.headers.get("Origin") || "",
|
12 |
+
'Access-Control-Allow-Methods': 'GET,HEAD,POST,OPTIONS',
|
13 |
+
'Access-Control-Allow-Headers': request.headers.get('Access-Control-Request-Headers') || '',
|
14 |
+
'Access-Control-Max-Age': '86400',
|
15 |
+
'Access-Control-Allow-Credentials': 'true'
|
16 |
+
};
|
17 |
+
return new Response(null, { headers: corsHeaders });
|
18 |
+
}
|
19 |
+
|
20 |
+
async function notPorxy(req: Request):Promise<Response|undefined>{
|
21 |
+
const url = new URL(req.url);
|
22 |
+
if(url.pathname=="/"){
|
23 |
+
return new Response(
|
24 |
+
indexHTML
|
25 |
+
.replaceAll("${PHOST}",url.host)
|
26 |
+
.replaceAll("${FIP}",getFIP()),
|
27 |
+
{status:200,headers:{"content-type":"text/html; charset=utf-8"}});
|
28 |
+
}
|
29 |
+
return undefined;
|
30 |
+
}
|
31 |
+
|
32 |
+
export const bingPorxyWorker = async (req: Request,env:Env):Promise<Response>=>{
|
33 |
+
// console.log(req.url);
|
34 |
+
if(req.method=="OPTIONS"){
|
35 |
+
return handleOptions(req);
|
36 |
+
}
|
37 |
+
// 开始请求
|
38 |
+
const url = new URL(req.url);
|
39 |
+
const headers = new Headers(req.headers);
|
40 |
+
headers.delete("host");
|
41 |
+
headers.delete("x-forwarded-host")
|
42 |
+
const fip = headers.get("MCPXXX-FIP");
|
43 |
+
headers.delete("MCPXXX-FIP");
|
44 |
+
const toHost = headers.get("MCPXXX-TO-HOST");
|
45 |
+
headers.delete("MCPXXX-TO-HOST");
|
46 |
+
if(!fip){
|
47 |
+
return await notPorxy(req) || new Response("no MCPXXX-FIP",{status:503});
|
48 |
+
}
|
49 |
+
if(!toHost){
|
50 |
+
return await notPorxy(req) || new Response("no MCPXXX-TO-HOST",{status:503});
|
51 |
+
}
|
52 |
+
headers.set("X-forwarded-for",fip);
|
53 |
+
url.host = toHost;
|
54 |
+
return await fetch(url,{
|
55 |
+
headers:headers,
|
56 |
+
body:req.body,
|
57 |
+
method:req.method
|
58 |
+
}) as any;
|
59 |
+
}
|
60 |
+
|
61 |
+
|
src/proxy/usIps.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
src/workers.ts
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { bingPorxyWorker } from './proxy/bingPorxyWorker';
|
2 |
+
|
3 |
+
export default {
|
4 |
+
async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
|
5 |
+
return bingPorxyWorker(request, env);
|
6 |
+
}
|
7 |
+
};
|
8 |
+
|
tsconfig.json
ADDED
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"compilerOptions": {
|
3 |
+
/* Visit https://aka.ms/tsconfig.json to read more about this file */
|
4 |
+
|
5 |
+
/* Projects */
|
6 |
+
// "incremental": true, /* Enable incremental compilation */
|
7 |
+
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
|
8 |
+
// "tsBuildInfoFile": "./", /* Specify the folder for .tsbuildinfo incremental compilation files. */
|
9 |
+
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects */
|
10 |
+
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
|
11 |
+
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
|
12 |
+
|
13 |
+
/* Language and Environment */
|
14 |
+
"target": "es2021" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
|
15 |
+
"lib": ["es2021"] /* Specify a set of bundled library declaration files that describe the target runtime environment. */,
|
16 |
+
"jsx": "react" /* Specify what JSX code is generated. */,
|
17 |
+
// "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
|
18 |
+
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
|
19 |
+
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h' */
|
20 |
+
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
|
21 |
+
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using `jsx: react-jsx*`.` */
|
22 |
+
// "reactNamespace": "", /* Specify the object invoked for `createElement`. This only applies when targeting `react` JSX emit. */
|
23 |
+
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
|
24 |
+
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
|
25 |
+
|
26 |
+
/* Modules */
|
27 |
+
"module": "es2022" /* Specify what module code is generated. */,
|
28 |
+
// "rootDir": "./", /* Specify the root folder within your source files. */
|
29 |
+
"moduleResolution": "Bundler" /* Specify how TypeScript looks up a file from a given module specifier. */,
|
30 |
+
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
31 |
+
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
|
32 |
+
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
|
33 |
+
// "typeRoots": [], /* Specify multiple folders that act like `./node_modules/@types`. */
|
34 |
+
"types": [
|
35 |
+
"@cloudflare/workers-types/2023-07-01"
|
36 |
+
] /* Specify type package names to be included without being referenced in a source file. */,
|
37 |
+
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
38 |
+
"resolveJsonModule": true /* Enable importing .json files */,
|
39 |
+
// "noResolve": true, /* Disallow `import`s, `require`s or `<reference>`s from expanding the number of files TypeScript should add to a project. */
|
40 |
+
|
41 |
+
/* JavaScript Support */
|
42 |
+
"allowJs": true /* Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files. */,
|
43 |
+
"checkJs": false /* Enable error reporting in type-checked JavaScript files. */,
|
44 |
+
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from `node_modules`. Only applicable with `allowJs`. */
|
45 |
+
|
46 |
+
/* Emit */
|
47 |
+
// "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
|
48 |
+
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
|
49 |
+
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
|
50 |
+
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
|
51 |
+
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If `declaration` is true, also designates a file that bundles all .d.ts output. */
|
52 |
+
// "outDir": "./", /* Specify an output folder for all emitted files. */
|
53 |
+
// "removeComments": true, /* Disable emitting comments. */
|
54 |
+
"noEmit": true /* Disable emitting files from a compilation. */,
|
55 |
+
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
|
56 |
+
// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types */
|
57 |
+
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
|
58 |
+
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
|
59 |
+
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
60 |
+
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
|
61 |
+
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
|
62 |
+
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
|
63 |
+
// "newLine": "crlf", /* Set the newline character for emitting files. */
|
64 |
+
// "stripInternal": true, /* Disable emitting declarations that have `@internal` in their JSDoc comments. */
|
65 |
+
// "noEmitHelpers": true, /* Disable generating custom helper functions like `__extends` in compiled output. */
|
66 |
+
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
|
67 |
+
// "preserveConstEnums": true, /* Disable erasing `const enum` declarations in generated code. */
|
68 |
+
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
|
69 |
+
// "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
|
70 |
+
|
71 |
+
/* Interop Constraints */
|
72 |
+
"isolatedModules": true /* Ensure that each file can be safely transpiled without relying on other imports. */,
|
73 |
+
"allowSyntheticDefaultImports": true /* Allow 'import x from y' when a module doesn't have a default export. */,
|
74 |
+
// "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility. */,
|
75 |
+
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
|
76 |
+
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
|
77 |
+
|
78 |
+
/* Type Checking */
|
79 |
+
"strict": true /* Enable all strict type-checking options. */,
|
80 |
+
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied `any` type.. */
|
81 |
+
// "strictNullChecks": true, /* When type checking, take into account `null` and `undefined`. */
|
82 |
+
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
|
83 |
+
// "strictBindCallApply": true, /* Check that the arguments for `bind`, `call`, and `apply` methods match the original function. */
|
84 |
+
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
|
85 |
+
// "noImplicitThis": true, /* Enable error reporting when `this` is given the type `any`. */
|
86 |
+
// "useUnknownInCatchVariables": true, /* Type catch clause variables as 'unknown' instead of 'any'. */
|
87 |
+
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
|
88 |
+
// "noUnusedLocals": true, /* Enable error reporting when a local variables aren't read. */
|
89 |
+
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read */
|
90 |
+
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
|
91 |
+
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
|
92 |
+
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
|
93 |
+
// "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
|
94 |
+
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
|
95 |
+
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type */
|
96 |
+
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
|
97 |
+
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
|
98 |
+
|
99 |
+
/* Completeness */
|
100 |
+
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
|
101 |
+
"skipLibCheck": true /* Skip type checking all .d.ts files. */
|
102 |
+
},
|
103 |
+
"exclude": ["test"]
|
104 |
+
}
|
typings.d.ts
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
declare module "*.html" {
|
2 |
+
const content: string;
|
3 |
+
export default content;
|
4 |
+
}
|
vitest.config.ts
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { defineWorkersConfig } from "@cloudflare/vitest-pool-workers/config";
|
2 |
+
|
3 |
+
export default defineWorkersConfig({
|
4 |
+
test: {
|
5 |
+
poolOptions: {
|
6 |
+
workers: {
|
7 |
+
wrangler: { configPath: "./wrangler.toml" },
|
8 |
+
},
|
9 |
+
},
|
10 |
+
},
|
11 |
+
});
|
worker-configuration.d.ts
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// Generated by Wrangler
|
2 |
+
// After adding bindings to `wrangler.toml`, regenerate this interface via `npm run cf-typegen`
|
3 |
+
interface Env {
|
4 |
+
|
5 |
+
}
|
wrangler.toml
ADDED
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#:schema node_modules/wrangler/config-schema.json
|
2 |
+
name = "microsoft-copilot-porxy"
|
3 |
+
main = "dist/index.js"
|
4 |
+
compatibility_date = "2024-05-24"
|
5 |
+
compatibility_flags = ["nodejs_compat"]
|
6 |
+
|
7 |
+
# Automatically place your workloads in an optimal location to minimize latency.
|
8 |
+
# If you are running back-end logic in a Worker, running it closer to your back-end infrastructure
|
9 |
+
# rather than the end user may result in better performance.
|
10 |
+
# Docs: https://developers.cloudflare.com/workers/configuration/smart-placement/#smart-placement
|
11 |
+
# [placement]
|
12 |
+
# mode = "smart"
|
13 |
+
|
14 |
+
# Variable bindings. These are arbitrary, plaintext strings (similar to environment variables)
|
15 |
+
# Docs:
|
16 |
+
# - https://developers.cloudflare.com/workers/wrangler/configuration/#environment-variables
|
17 |
+
# Note: Use secrets to store sensitive data.
|
18 |
+
# - https://developers.cloudflare.com/workers/configuration/secrets/
|
19 |
+
# [vars]
|
20 |
+
# MY_VARIABLE = "production_value"
|
21 |
+
|
22 |
+
# Bind the Workers AI model catalog. Run machine learning models, powered by serverless GPUs, on Cloudflare’s global network
|
23 |
+
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#workers-ai
|
24 |
+
# [ai]
|
25 |
+
# binding = "AI"
|
26 |
+
|
27 |
+
# Bind an Analytics Engine dataset. Use Analytics Engine to write analytics within your Pages Function.
|
28 |
+
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#analytics-engine-datasets
|
29 |
+
# [[analytics_engine_datasets]]
|
30 |
+
# binding = "MY_DATASET"
|
31 |
+
|
32 |
+
# Bind a headless browser instance running on Cloudflare's global network.
|
33 |
+
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#browser-rendering
|
34 |
+
# [browser]
|
35 |
+
# binding = "MY_BROWSER"
|
36 |
+
|
37 |
+
# Bind a D1 database. D1 is Cloudflare’s native serverless SQL database.
|
38 |
+
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#d1-databases
|
39 |
+
# [[d1_databases]]
|
40 |
+
# binding = "MY_DB"
|
41 |
+
# database_name = "my-database"
|
42 |
+
# database_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
43 |
+
|
44 |
+
# Bind a dispatch namespace. Use Workers for Platforms to deploy serverless functions programmatically on behalf of your customers.
|
45 |
+
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#dispatch-namespace-bindings-workers-for-platforms
|
46 |
+
# [[dispatch_namespaces]]
|
47 |
+
# binding = "MY_DISPATCHER"
|
48 |
+
# namespace = "my-namespace"
|
49 |
+
|
50 |
+
# Bind a Durable Object. Durable objects are a scale-to-zero compute primitive based on the actor model.
|
51 |
+
# Durable Objects can live for as long as needed. Use these when you need a long-running "server", such as in realtime apps.
|
52 |
+
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#durable-objects
|
53 |
+
# [[durable_objects.bindings]]
|
54 |
+
# name = "MY_DURABLE_OBJECT"
|
55 |
+
# class_name = "MyDurableObject"
|
56 |
+
|
57 |
+
# Durable Object migrations.
|
58 |
+
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#migrations
|
59 |
+
# [[migrations]]
|
60 |
+
# tag = "v1"
|
61 |
+
# new_classes = ["MyDurableObject"]
|
62 |
+
|
63 |
+
# Bind a Hyperdrive configuration. Use to accelerate access to your existing databases from Cloudflare Workers.
|
64 |
+
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#hyperdrive
|
65 |
+
# [[hyperdrive]]
|
66 |
+
# binding = "MY_HYPERDRIVE"
|
67 |
+
# id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
68 |
+
|
69 |
+
# Bind a KV Namespace. Use KV as persistent storage for small key-value pairs.
|
70 |
+
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#kv-namespaces
|
71 |
+
# [[kv_namespaces]]
|
72 |
+
# binding = "MY_KV_NAMESPACE"
|
73 |
+
# id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
74 |
+
|
75 |
+
# Bind an mTLS certificate. Use to present a client certificate when communicating with another service.
|
76 |
+
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#mtls-certificates
|
77 |
+
# [[mtls_certificates]]
|
78 |
+
# binding = "MY_CERTIFICATE"
|
79 |
+
# certificate_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
80 |
+
|
81 |
+
# Bind a Queue producer. Use this binding to schedule an arbitrary task that may be processed later by a Queue consumer.
|
82 |
+
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#queues
|
83 |
+
# [[queues.producers]]
|
84 |
+
# binding = "MY_QUEUE"
|
85 |
+
# queue = "my-queue"
|
86 |
+
|
87 |
+
# Bind a Queue consumer. Queue Consumers can retrieve tasks scheduled by Producers to act on them.
|
88 |
+
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#queues
|
89 |
+
# [[queues.consumers]]
|
90 |
+
# queue = "my-queue"
|
91 |
+
|
92 |
+
# Bind an R2 Bucket. Use R2 to store arbitrarily large blobs of data, such as files.
|
93 |
+
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#r2-buckets
|
94 |
+
# [[r2_buckets]]
|
95 |
+
# binding = "MY_BUCKET"
|
96 |
+
# bucket_name = "my-bucket"
|
97 |
+
|
98 |
+
# Bind another Worker service. Use this binding to call another Worker without network overhead.
|
99 |
+
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#service-bindings
|
100 |
+
# [[services]]
|
101 |
+
# binding = "MY_SERVICE"
|
102 |
+
# service = "my-service"
|
103 |
+
|
104 |
+
# Bind a Vectorize index. Use to store and query vector embeddings for semantic search, classification and other vector search use-cases.
|
105 |
+
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#vectorize-indexes
|
106 |
+
# [[vectorize]]
|
107 |
+
# binding = "MY_INDEX"
|
108 |
+
# index_name = "my-index"
|