dsh-github-studio 0.6.6 → 0.6.7
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/README.md +13 -1
- package/lib/client.js +1 -1
- package/lib/core.js +4 -3
- package/lib/core.mjs +4 -3
- package/lib/diagnostics.js +2 -2
- package/lib/diagnostics.mjs +2 -2
- package/lib/gh.js +89 -8
- package/lib/gh.mjs +89 -8
- package/lib/http.js +2 -1
- package/lib/http.mjs +2 -1
- package/lib/index.js +4 -2
- package/lib/network.js +32 -0
- package/lib/network.mjs +32 -0
- package/package.json +5 -1
package/README.md
CHANGED
|
@@ -131,7 +131,7 @@ npm run verify
|
|
|
131
131
|
- ZIP 只读取符合限制的文本,不运行其中的程序;会跳过依赖目录、部分构建产物和明显凭据文件。启发式筛选不能保证发现所有敏感信息。
|
|
132
132
|
- AI 将所选文本发送给 Harness 配置的模型服务,生成结果需审阅,不能视为已验证的软件功能或测试结论。
|
|
133
133
|
- 若写入后网络中断,请先核实 GitHub 上的实际结果,再决定是否重新准备操作。
|
|
134
|
-
-
|
|
134
|
+
- 支持加密保存与自动续期刷新令牌;首次使用旧版凭据或授权已撤销时仍需重新登录。
|
|
135
135
|
|
|
136
136
|
## 常见问题
|
|
137
137
|
|
|
@@ -159,3 +159,15 @@ npm run release:source
|
|
|
159
159
|
|
|
160
160
|
本项目使用 MIT License。第三方依赖遵循各自许可证;不附带或重新分发 DeepSeek Harness 宿主运行时。
|
|
161
161
|
|
|
162
|
+
|
|
163
|
+
## 网络不稳定与 GitHub 加速
|
|
164
|
+
|
|
165
|
+
登录的临时网络错误会自动重试;设备码有效期内轮询失败会保留设备码并退避,界面可取消本次登录。证书错误会立即给出提示,不会通过关闭 HTTPS 校验来绕过。建库、提交、发布和上传不会自动重放。
|
|
166
|
+
|
|
167
|
+
插件网络连接使用 Node 内置 CA、Windows 系统信任证书以及启动时配置的额外 CA,只影响本插件。Steam++ 等证书接管模式需先正确安装其证书,再彻底退出并重开 Harness;线路不可用仍需切换或关闭 GitHub 加速。
|
|
168
|
+
|
|
169
|
+
如需明确指定 HTTP/HTTPS 代理,可在启动 Harness 前设置本机环境变量 `DSH_GITHUB_PROXY`(例如 `http://127.0.0.1:7890`,端口以加速器实际配置为准)。也支持 `HTTP_PROXY`、`HTTPS_PROXY`、`NO_PROXY` 及小写形式;插件专用代理优先。暂不支持 SOCKS 地址、Windows PAC 或自动发现系统代理。不要把含账号密码的代理配置提交到仓库。
|
|
170
|
+
|
|
171
|
+
自定义可信 CA 可通过启动时的 `NODE_EXTRA_CA_CERTS` 指向 PEM 文件;仅加入你确认可信的证书。修改上述启动配置后需完全重启 Harness。
|
|
172
|
+
|
|
173
|
+
新授权会申请 `repo offline_access`,在 GitHub 返回刷新令牌时加密保存并提前续期。旧版只保存访问令牌,无法补回刷新令牌,需要重新授权一次。撤销授权、刷新令牌过期或轮换响应丢失时仍可能需要重新登录。诊断日志只记录固定错误类别,不写令牌、设备码、代理地址或正文。
|
package/lib/client.js
CHANGED
|
@@ -14237,7 +14237,7 @@ function GitHubSettings() {
|
|
|
14237
14237
|
e.preventDefault();
|
|
14238
14238
|
const f = new FormData(e.currentTarget);
|
|
14239
14239
|
act("\u6B63\u5728\u4FDD\u5B58", () => post2("auth/configure", { clientId: f.get("clientId") }));
|
|
14240
|
-
} }, /* @__PURE__ */ import_react8.default.createElement(Field, { label: "OAuth App Client ID" }, /* @__PURE__ */ import_react8.default.createElement("input", { name: "clientId", required: true, defaultValue: state.clientId ?? "", placeholder: "\u586B\u5199\u53D1\u5E03\u8005\u7684 Client ID" })), /* @__PURE__ */ import_react8.default.createElement("button", { disabled: !!busy }, "\u4FDD\u5B58\u5E94\u7528\u914D\u7F6E"))), error && /* @__PURE__ */ import_react8.default.createElement("div", { role: "alert", className: "gh-errorbox" }, error, /* @__PURE__ */ import_react8.default.createElement("button", { "aria-label": "\u5173\u95ED\u63D0\u793A", onClick: () => setError("") }, "\xD7")), state?.user && state.errorKind && state.errorKind !== "auth" && /* @__PURE__ */ import_react8.default.createElement("p", { role: "status", className: "gh-muted" }, "GitHub \u6682\u65F6\u4E0D\u53EF\u7528\uFF08", state.error, "\uFF09\uFF0C\u5DF2\u4FDD\u7559\u5F53\u524D\u754C\u9762\u72B6\u6001\u5E76\u81EA\u52A8\u91CD\u8BD5\u3002"), state?.hasCredential && !logged && /* @__PURE__ */ import_react8.default.createElement("button", { disabled: !!busy, onClick: () => act("\u6B63\u5728\u6E05\u9664\u672C\u5730\u8FDE\u63A5", () => post2("auth/logout")) }, "\u6E05\u9664\u672C\u5730\u8FDE\u63A5"), !state && /* @__PURE__ */ import_react8.default.createElement("p", { role: "status", className: "gh-muted" }, "\u6B63\u5728\u68C0\u67E5\u8FDE\u63A5\u2026"), logged ? /* @__PURE__ */ import_react8.default.createElement("section", { className: "gh-account" }, /* @__PURE__ */ import_react8.default.createElement("img", { src: state.user.avatar_url, alt: "" }), /* @__PURE__ */ import_react8.default.createElement("div", null, /* @__PURE__ */ import_react8.default.createElement("strong", null, state.user.name || state.user.login), /* @__PURE__ */ import_react8.default.createElement("span", null, "@", state.user.login, " ", /* @__PURE__ */ import_react8.default.createElement("i", null), " \u5DF2\u8FDE\u63A5")), /* @__PURE__ */ import_react8.default.createElement("button", { disabled: !!busy, onClick: () => act("\u6B63\u5728\u65AD\u5F00", () => post2("auth/logout")) }, "\u65AD\u5F00\u8FDE\u63A5")) : /* @__PURE__ */ import_react8.default.createElement("section", { className: "gh-connect" }, /* @__PURE__ */ import_react8.default.createElement("strong", null, "\u8FDE\u63A5\u4F60\u7684 GitHub \u8D26\u53F7"), /* @__PURE__ */ import_react8.default.createElement("p", null, "\u70B9\u51FB\u53F3\u4E0A\u65B9\u767B\u5F55\uFF0C\u5728 GitHub \u5B98\u65B9\u9875\u9762\u5B8C\u6210\u6388\u6743\u3002\u8BF7\u5728 GitHub \u5B98\u65B9\u6388\u6743\u9875\u8F93\u5165\u8BBE\u5907\u4EE3\u7801\u3002"), login.state === "waiting" && /* @__PURE__ */ import_react8.default.createElement("div", { className: "gh-device" }, /* @__PURE__ */ import_react8.default.createElement("span", null, "\u5728\u6388\u6743\u9875\u9762\u8F93\u5165\u8BBE\u5907\u4EE3\u7801"), /* @__PURE__ */ import_react8.default.createElement("strong", null, login.code || "\u6B63\u5728\u83B7\u53D6\u2026"), /* @__PURE__ */ import_react8.default.createElement("a", { href: "https://github.com/login/device", target: "_blank", rel: "noreferrer" }, "\u6253\u5F00 GitHub \u6388\u6743\u9875\u9762")), login.state === "preparing" && /* @__PURE__ */ import_react8.default.createElement("p", { role: "status" }, "\u6B63\u5728\u8BF7\u6C42 GitHub \u8BBE\u5907\u6388\u6743\uFF0C\u8BF7\u7A0D\u5019\u2026"), login.state === "error" && /* @__PURE__ */ import_react8.default.createElement("p", { className: "gh-error" }, login.message)), /* @__PURE__ */ import_react8.default.createElement(BrowserSearch, null), pending > 0 && tab2 !== "operations" && /* @__PURE__ */ import_react8.default.createElement("button", { className: "gh-pending", onClick: () => setTab("operations") }, pending, " \u9879\u64CD\u4F5C\u7B49\u5F85\u786E\u8BA4\uFF0C\u70B9\u51FB\u9884\u89C8"), /* @__PURE__ */ import_react8.default.createElement("nav", { className: "gh-tabs", "aria-label": "GitHub \u529F\u80FD" }, [["repos", "\u4ED3\u5E93"], ["releases", "\u7A0B\u5E8F\u53D1\u5E03"], ["operations", `\u64CD\u4F5C\u8BB0\u5F55${pending ? " (" + pending + ")" : ""}`]].map(([id, label]) => /* @__PURE__ */ import_react8.default.createElement("button", { key: id, "aria-current": tab2 === id ? "page" : void 0, onClick: () => {
|
|
14240
|
+
} }, /* @__PURE__ */ import_react8.default.createElement(Field, { label: "OAuth App Client ID" }, /* @__PURE__ */ import_react8.default.createElement("input", { name: "clientId", required: true, defaultValue: state.clientId ?? "", placeholder: "\u586B\u5199\u53D1\u5E03\u8005\u7684 Client ID" })), /* @__PURE__ */ import_react8.default.createElement("button", { disabled: !!busy }, "\u4FDD\u5B58\u5E94\u7528\u914D\u7F6E"))), error && /* @__PURE__ */ import_react8.default.createElement("div", { role: "alert", className: "gh-errorbox" }, error, /* @__PURE__ */ import_react8.default.createElement("button", { "aria-label": "\u5173\u95ED\u63D0\u793A", onClick: () => setError("") }, "\xD7")), state?.user && state.errorKind && state.errorKind !== "auth" && /* @__PURE__ */ import_react8.default.createElement("p", { role: "status", className: "gh-muted" }, "GitHub \u6682\u65F6\u4E0D\u53EF\u7528\uFF08", state.error, "\uFF09\uFF0C\u5DF2\u4FDD\u7559\u5F53\u524D\u754C\u9762\u72B6\u6001\u5E76\u81EA\u52A8\u91CD\u8BD5\u3002"), state?.hasCredential && !logged && /* @__PURE__ */ import_react8.default.createElement("button", { disabled: !!busy, onClick: () => act("\u6B63\u5728\u6E05\u9664\u672C\u5730\u8FDE\u63A5", () => post2("auth/logout")) }, "\u6E05\u9664\u672C\u5730\u8FDE\u63A5"), !state && /* @__PURE__ */ import_react8.default.createElement("p", { role: "status", className: "gh-muted" }, "\u6B63\u5728\u68C0\u67E5\u8FDE\u63A5\u2026"), logged ? /* @__PURE__ */ import_react8.default.createElement("section", { className: "gh-account" }, /* @__PURE__ */ import_react8.default.createElement("img", { src: state.user.avatar_url, alt: "" }), /* @__PURE__ */ import_react8.default.createElement("div", null, /* @__PURE__ */ import_react8.default.createElement("strong", null, state.user.name || state.user.login), /* @__PURE__ */ import_react8.default.createElement("span", null, "@", state.user.login, " ", /* @__PURE__ */ import_react8.default.createElement("i", null), " \u5DF2\u8FDE\u63A5")), /* @__PURE__ */ import_react8.default.createElement("button", { disabled: !!busy, onClick: () => act("\u6B63\u5728\u65AD\u5F00", () => post2("auth/logout")) }, "\u65AD\u5F00\u8FDE\u63A5")) : /* @__PURE__ */ import_react8.default.createElement("section", { className: "gh-connect" }, /* @__PURE__ */ import_react8.default.createElement("strong", null, "\u8FDE\u63A5\u4F60\u7684 GitHub \u8D26\u53F7"), /* @__PURE__ */ import_react8.default.createElement("p", null, "\u70B9\u51FB\u53F3\u4E0A\u65B9\u767B\u5F55\uFF0C\u5728 GitHub \u5B98\u65B9\u9875\u9762\u5B8C\u6210\u6388\u6743\u3002\u8BF7\u5728 GitHub \u5B98\u65B9\u6388\u6743\u9875\u8F93\u5165\u8BBE\u5907\u4EE3\u7801\u3002"), login.state === "waiting" && /* @__PURE__ */ import_react8.default.createElement("div", { className: "gh-device" }, /* @__PURE__ */ import_react8.default.createElement("span", null, "\u5728\u6388\u6743\u9875\u9762\u8F93\u5165\u8BBE\u5907\u4EE3\u7801"), /* @__PURE__ */ import_react8.default.createElement("strong", null, login.code || "\u6B63\u5728\u83B7\u53D6\u2026"), /* @__PURE__ */ import_react8.default.createElement("a", { href: "https://github.com/login/device", target: "_blank", rel: "noreferrer" }, "\u6253\u5F00 GitHub \u6388\u6743\u9875\u9762")), ["preparing", "waiting"].includes(login.state) && /* @__PURE__ */ import_react8.default.createElement(import_react8.default.Fragment, null, /* @__PURE__ */ import_react8.default.createElement("p", { role: "status", className: "gh-muted" }, login.message || "\u6388\u6743\u6709\u6548\u671F\u5185\u9047\u5230\u77ED\u6682\u7F51\u7EDC\u6545\u969C\u4F1A\u81EA\u52A8\u91CD\u8BD5\u3002"), /* @__PURE__ */ import_react8.default.createElement("button", { disabled: !!busy, onClick: () => act("\u6B63\u5728\u53D6\u6D88\u767B\u5F55", () => post2("auth/cancel")) }, "\u53D6\u6D88\u672C\u6B21\u767B\u5F55")), login.state === "preparing" && /* @__PURE__ */ import_react8.default.createElement("p", { role: "status" }, "\u6B63\u5728\u8BF7\u6C42 GitHub \u8BBE\u5907\u6388\u6743\uFF0C\u8BF7\u7A0D\u5019\u2026"), state?.error && !logged && !["preparing", "waiting", "error"].includes(login.state) && /* @__PURE__ */ import_react8.default.createElement("p", { className: "gh-error" }, state.error), login.state === "error" && /* @__PURE__ */ import_react8.default.createElement("p", { className: "gh-error" }, login.message)), /* @__PURE__ */ import_react8.default.createElement(BrowserSearch, null), pending > 0 && tab2 !== "operations" && /* @__PURE__ */ import_react8.default.createElement("button", { className: "gh-pending", onClick: () => setTab("operations") }, pending, " \u9879\u64CD\u4F5C\u7B49\u5F85\u786E\u8BA4\uFF0C\u70B9\u51FB\u9884\u89C8"), /* @__PURE__ */ import_react8.default.createElement("nav", { className: "gh-tabs", "aria-label": "GitHub \u529F\u80FD" }, [["repos", "\u4ED3\u5E93"], ["releases", "\u7A0B\u5E8F\u53D1\u5E03"], ["operations", `\u64CD\u4F5C\u8BB0\u5F55${pending ? " (" + pending + ")" : ""}`]].map(([id, label]) => /* @__PURE__ */ import_react8.default.createElement("button", { key: id, "aria-current": tab2 === id ? "page" : void 0, onClick: () => {
|
|
14241
14241
|
setTab(id);
|
|
14242
14242
|
if (id === "releases" && selected) act("\u6B63\u5728\u8BFB\u53D6\u7248\u672C", () => loadReleases());
|
|
14243
14243
|
} }, label)), /* @__PURE__ */ import_react8.default.createElement("button", { className: "gh-refresh-repos", disabled: !logged || !!busy, onClick: () => act("\u6B63\u5728\u5237\u65B0\u4ED3\u5E93", () => listRepos(1)) }, busy === "\u6B63\u5728\u5237\u65B0\u4ED3\u5E93" ? "\u5237\u65B0\u4E2D\u2026" : "\u5237\u65B0\u5E93")), tab2 === "repos" && (!logged ? /* @__PURE__ */ import_react8.default.createElement(Empty, { title: "\u767B\u5F55\u540E\u67E5\u770B\u4ED3\u5E93" }, "\u9009\u62E9\u4F60\u7684\u9879\u76EE\uFF0C\u8BA9 DeepSeek \u9605\u8BFB\u548C\u5206\u6790\u4EE3\u7801\u3002") : /* @__PURE__ */ import_react8.default.createElement(import_react8.default.Fragment, null, /* @__PURE__ */ import_react8.default.createElement("div", { className: "gh-row gh-section-title" }, /* @__PURE__ */ import_react8.default.createElement("h3", null, selected ? "\u4ED3\u5E93\u6587\u4EF6" : "\u6211\u7684\u4ED3\u5E93"), /* @__PURE__ */ import_react8.default.createElement("div", { className: "gh-actions" }, /* @__PURE__ */ import_react8.default.createElement("button", { disabled: !!busy, onClick: () => act("\u6B63\u5728\u5237\u65B0", () => listRepos()) }, "\u5237\u65B0"), /* @__PURE__ */ import_react8.default.createElement("button", { onClick: () => setCreate(!create2) }, "\u65B0\u5EFA\u4ED3\u5E93"))), create2 && /* @__PURE__ */ import_react8.default.createElement(NewRepositoryForm, { busy: !!busy, apiCall: post2, upload: (file) => call("upload", { method: "POST", body: file, headers: { "x-file-name": encodeURIComponent(file.name), "x-file-purpose": "intro", "Content-Type": "application/octet-stream" } }), onPrepare: (args) => act("\u6B63\u5728\u51C6\u5907\u4ED3\u5E93", () => prepare("create_repository", args)) }), selected ? /* @__PURE__ */ import_react8.default.createElement(import_react8.default.Fragment, null, /* @__PURE__ */ import_react8.default.createElement("button", { className: "gh-back", onClick: () => {
|
package/lib/core.js
CHANGED
|
@@ -14,11 +14,12 @@ const repoPath=a=>`/repos/${enc(segment(a.owner,'账号'))}/${enc(segment(a.repo
|
|
|
14
14
|
const filePath=s=>{if(typeof s!=='string'||s.length>600||s.startsWith('/')||s.includes('\\')||s.split('/').some(p=>!p||p==='.'||p==='..')||/[\x00-\x1f]/.test(s))throw Error('文件路径无效。');return s;};
|
|
15
15
|
export class GitHub {
|
|
16
16
|
constructor({auth,fetchImpl=fetch,base='https://api.github.com',uploadBase='https://uploads.github.com',diagnostics=()=>{}}={}){this.auth=auth;this.fetch=fetchImpl;this.base=base;this.uploadBase=uploadBase;this.diagnostics=diagnostics;}
|
|
17
|
-
async request(route,{method='GET',body,token,signal,raw=false,headers={}}={}){
|
|
17
|
+
async request(route,{method='GET',body,token,signal,raw=false,headers={},reauthenticated=false}={}){
|
|
18
18
|
token??=await this.auth.token();
|
|
19
|
-
let response;try{response=await this.fetch(this.base+route,{method,headers:{Accept:'application/vnd.github+json','X-GitHub-Api-Version':'2022-11-28','User-Agent':'dsh-github-connect',Authorization:`Bearer ${token}`,...(body!==undefined?{'Content-Type':'application/json'}:{}),...headers},body:body===undefined?undefined:JSON.stringify(body),signal:signal??AbortSignal.timeout(45000),redirect:'error'});}catch(e){this.diagnostics('api_failure',{category:requestCategory(route),reason:['TimeoutError','AbortError'].includes(e.name)?'timeout':'network_error'});throw e;}
|
|
19
|
+
let response;try{response=await this.fetch(this.base+route,{method,headers:{Accept:'application/vnd.github+json','X-GitHub-Api-Version':'2022-11-28','User-Agent':'dsh-github-connect',Authorization:`Bearer ${token}`,...(body!==undefined?{'Content-Type':'application/json'}:{}),...headers},body:body===undefined?undefined:JSON.stringify(body),signal:signal??AbortSignal.timeout(45000),redirect:'error'});}catch(e){this.diagnostics('api_failure',{category:requestCategory(route),reason:e.reason??(['TimeoutError','AbortError'].includes(e.name)?'timeout':'network_error')});throw e;}
|
|
20
20
|
this.diagnostics('api_response',{category:requestCategory(route),status:response.status,reason:response.ok?'ok':response.status===401?'invalid_credentials':response.status===429||response.headers.get('x-ratelimit-remaining')==='0'?'rate_limited':response.status===403?'forbidden':response.status>=500?'server_error':undefined});
|
|
21
|
-
if(!response.
|
|
21
|
+
if(!reauthenticated&&response.status===401&&['GET','HEAD'].includes(method)&&token!==undefined&&this.auth.refreshAfter401){const renewed=await this.auth.refreshAfter401(token);if(renewed&&renewed!==token){await response.body?.cancel();return this.request(route,{method,body,token:renewed,signal,raw,headers,reauthenticated:true});}}
|
|
22
|
+
if(!response.ok){let info={};try{info=await response.json();}catch{}const e=Error(`GitHub 请求失败(${response.status}):${String(info.message??'请检查授权和网络').slice(0,400)}`);e.status=response.status;if(response.status===401)e.message='GitHub 登录凭据已失效(401),请点击登录 GitHub 重新授权。';if(response.status===429||(response.status===403&&(response.headers.get('x-ratelimit-remaining')==='0'||/rate limit/i.test(info.message??'')))){const retry=Number(response.headers.get('retry-after')),reset=Number(response.headers.get('x-ratelimit-reset'));const seconds=retry>0?Math.ceil(retry):reset>0?Math.max(1,Math.ceil(reset-Date.now()/1000)):60;e.message='GitHub 请求频率已受限,请等待约 '+seconds+' 秒后重试,不要连续请求。';}throw e;}
|
|
22
23
|
if(response.status===204)return {};
|
|
23
24
|
if(raw)return response;
|
|
24
25
|
return response.json();
|
package/lib/core.mjs
CHANGED
|
@@ -14,11 +14,12 @@ const repoPath=a=>`/repos/${enc(segment(a.owner,'账号'))}/${enc(segment(a.repo
|
|
|
14
14
|
const filePath=s=>{if(typeof s!=='string'||s.length>600||s.startsWith('/')||s.includes('\\')||s.split('/').some(p=>!p||p==='.'||p==='..')||/[\x00-\x1f]/.test(s))throw Error('文件路径无效。');return s;};
|
|
15
15
|
export class GitHub {
|
|
16
16
|
constructor({auth,fetchImpl=fetch,base='https://api.github.com',uploadBase='https://uploads.github.com',diagnostics=()=>{}}={}){this.auth=auth;this.fetch=fetchImpl;this.base=base;this.uploadBase=uploadBase;this.diagnostics=diagnostics;}
|
|
17
|
-
async request(route,{method='GET',body,token,signal,raw=false,headers={}}={}){
|
|
17
|
+
async request(route,{method='GET',body,token,signal,raw=false,headers={},reauthenticated=false}={}){
|
|
18
18
|
token??=await this.auth.token();
|
|
19
|
-
let response;try{response=await this.fetch(this.base+route,{method,headers:{Accept:'application/vnd.github+json','X-GitHub-Api-Version':'2022-11-28','User-Agent':'dsh-github-connect',Authorization:`Bearer ${token}`,...(body!==undefined?{'Content-Type':'application/json'}:{}),...headers},body:body===undefined?undefined:JSON.stringify(body),signal:signal??AbortSignal.timeout(45000),redirect:'error'});}catch(e){this.diagnostics('api_failure',{category:requestCategory(route),reason:['TimeoutError','AbortError'].includes(e.name)?'timeout':'network_error'});throw e;}
|
|
19
|
+
let response;try{response=await this.fetch(this.base+route,{method,headers:{Accept:'application/vnd.github+json','X-GitHub-Api-Version':'2022-11-28','User-Agent':'dsh-github-connect',Authorization:`Bearer ${token}`,...(body!==undefined?{'Content-Type':'application/json'}:{}),...headers},body:body===undefined?undefined:JSON.stringify(body),signal:signal??AbortSignal.timeout(45000),redirect:'error'});}catch(e){this.diagnostics('api_failure',{category:requestCategory(route),reason:e.reason??(['TimeoutError','AbortError'].includes(e.name)?'timeout':'network_error')});throw e;}
|
|
20
20
|
this.diagnostics('api_response',{category:requestCategory(route),status:response.status,reason:response.ok?'ok':response.status===401?'invalid_credentials':response.status===429||response.headers.get('x-ratelimit-remaining')==='0'?'rate_limited':response.status===403?'forbidden':response.status>=500?'server_error':undefined});
|
|
21
|
-
if(!response.
|
|
21
|
+
if(!reauthenticated&&response.status===401&&['GET','HEAD'].includes(method)&&token!==undefined&&this.auth.refreshAfter401){const renewed=await this.auth.refreshAfter401(token);if(renewed&&renewed!==token){await response.body?.cancel();return this.request(route,{method,body,token:renewed,signal,raw,headers,reauthenticated:true});}}
|
|
22
|
+
if(!response.ok){let info={};try{info=await response.json();}catch{}const e=Error(`GitHub 请求失败(${response.status}):${String(info.message??'请检查授权和网络').slice(0,400)}`);e.status=response.status;if(response.status===401)e.message='GitHub 登录凭据已失效(401),请点击登录 GitHub 重新授权。';if(response.status===429||(response.status===403&&(response.headers.get('x-ratelimit-remaining')==='0'||/rate limit/i.test(info.message??'')))){const retry=Number(response.headers.get('retry-after')),reset=Number(response.headers.get('x-ratelimit-reset'));const seconds=retry>0?Math.ceil(retry):reset>0?Math.max(1,Math.ceil(reset-Date.now()/1000)):60;e.message='GitHub 请求频率已受限,请等待约 '+seconds+' 秒后重试,不要连续请求。';}throw e;}
|
|
22
23
|
if(response.status===204)return {};
|
|
23
24
|
if(raw)return response;
|
|
24
25
|
return response.json();
|
package/lib/diagnostics.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {mkdirSync,appendFileSync,statSync,readFileSync,writeFileSync} from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
-
const events=new Set(['plugin_started','plugin_stopped','credential_read','credential_saved','logout','oauth_started','oauth_waiting','oauth_failed','api_response','api_failure']);
|
|
3
|
+
const events=new Set(['plugin_started','plugin_stopped','credential_read','credential_saved','logout','oauth_started','oauth_waiting','oauth_retry','oauth_failed','api_response','api_failure']);
|
|
4
4
|
const categories=new Set(['account','search','repository','upload','authorization']);
|
|
5
|
-
const reasons=new Set(['ok','missing','read_failed','decrypt_failed','invalid_local','invalid_credentials','forbidden','rate_limited','server_error','network_error','timeout','authorization_failed','access_denied','expired_token','device_flow_disabled','incorrect_client_credentials','incorrect_device_code','unsupported_grant_type','oauth_error','local_disconnect']);
|
|
5
|
+
const reasons=new Set(['ok','missing','read_failed','decrypt_failed','invalid_local','invalid_credentials','forbidden','rate_limited','server_error','tls_error','dns_error','connection_error','network_error','timeout','authorization_failed','access_denied','expired_token','device_flow_disabled','incorrect_client_credentials','incorrect_device_code','unsupported_grant_type','oauth_error','local_disconnect']);
|
|
6
6
|
/** Allowlisted metadata only. Never accept messages, URLs, queries or tokens. */
|
|
7
7
|
export function createDiagnostics(root,{now=Date.now}={}){
|
|
8
8
|
const file=path.join(root,'diagnostics.jsonl'),last=new Map();
|
package/lib/diagnostics.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {mkdirSync,appendFileSync,statSync,readFileSync,writeFileSync} from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
-
const events=new Set(['plugin_started','plugin_stopped','credential_read','credential_saved','logout','oauth_started','oauth_waiting','oauth_failed','api_response','api_failure']);
|
|
3
|
+
const events=new Set(['plugin_started','plugin_stopped','credential_read','credential_saved','logout','oauth_started','oauth_waiting','oauth_retry','oauth_failed','api_response','api_failure']);
|
|
4
4
|
const categories=new Set(['account','search','repository','upload','authorization']);
|
|
5
|
-
const reasons=new Set(['ok','missing','read_failed','decrypt_failed','invalid_local','invalid_credentials','forbidden','rate_limited','server_error','network_error','timeout','authorization_failed','access_denied','expired_token','device_flow_disabled','incorrect_client_credentials','incorrect_device_code','unsupported_grant_type','oauth_error','local_disconnect']);
|
|
5
|
+
const reasons=new Set(['ok','missing','read_failed','decrypt_failed','invalid_local','invalid_credentials','forbidden','rate_limited','server_error','tls_error','dns_error','connection_error','network_error','timeout','authorization_failed','access_denied','expired_token','device_flow_disabled','incorrect_client_credentials','incorrect_device_code','unsupported_grant_type','oauth_error','local_disconnect']);
|
|
6
6
|
/** Allowlisted metadata only. Never accept messages, URLs, queries or tokens. */
|
|
7
7
|
export function createDiagnostics(root,{now=Date.now}={}){
|
|
8
8
|
const file=path.join(root,'diagnostics.jsonl'),last=new Map();
|
package/lib/gh.js
CHANGED
|
@@ -1,17 +1,98 @@
|
|
|
1
|
+
import {setTimeout as delay} from 'node:timers/promises';
|
|
2
|
+
import {randomUUID} from 'node:crypto';
|
|
3
|
+
import {networkFailure} from './network.mjs';
|
|
1
4
|
import {spawn} from 'node:child_process';
|
|
2
|
-
import {mkdir,readFile,writeFile,unlink} from 'node:fs/promises';
|
|
5
|
+
import {mkdir,readFile,writeFile,unlink,rename} from 'node:fs/promises';
|
|
3
6
|
import path from 'node:path';
|
|
4
7
|
export function command(exe,args,{input='',timeout=30000}={}){return new Promise((resolve,reject)=>{const child=spawn(exe,args,{windowsHide:true,stdio:['pipe','pipe','pipe']});let stdout='';const timer=setTimeout(()=>{child.kill();reject(Error('凭据操作超时。'));},timeout);child.on('error',e=>{clearTimeout(timer);reject(e);});child.stdout.on('data',b=>stdout+=b);child.stderr.resume();child.on('close',code=>{clearTimeout(timer);resolve({code,stdout});});child.stdin.on('error',()=>{});child.stdin.end(input);});}
|
|
5
8
|
export async function windowsSeal(action,value){if(process.platform!=='win32')throw Error('本版凭据保护仅支持 Windows。');const operation=action==='protect'?'Protect':'Unprotect';const script=`Add-Type -AssemblyName System.Security; $b=[Convert]::FromBase64String([Console]::In.ReadToEnd().Trim()); $r=[Security.Cryptography.ProtectedData]::${operation}($b,$null,[Security.Cryptography.DataProtectionScope]::CurrentUser); [Console]::Write([Convert]::ToBase64String($r))`;const r=await command('powershell.exe',['-NoProfile','-NonInteractive','-Command',script],{input:action==='protect'?Buffer.from(value,'utf8').toString('base64'):value});if(r.code!==0)throw Error('Windows 凭据加密失败。');return action==='protect'?r.stdout.trim():Buffer.from(r.stdout.trim(),'base64').toString('utf8');}
|
|
9
|
+
|
|
6
10
|
export class GhAuth{
|
|
7
|
-
constructor(root,{fetchImpl=fetch,seal=windowsSeal,sleep=ms=>
|
|
11
|
+
constructor(root,{fetchImpl=fetch,seal=windowsSeal,sleep=(ms,signal)=>delay(ms,undefined,{signal}),diagnostics=()=>{},now=Date.now}={}){
|
|
12
|
+
Object.assign(this,{root,fetch:fetchImpl,seal,sleep,diagnostics,now});this.login={state:'idle'};this.epoch=0;
|
|
13
|
+
}
|
|
8
14
|
async clientId(){try{return JSON.parse(await readFile(path.join(this.root,'oauth.json'),'utf8')).clientId;}catch{if(process.env.DSH_GITHUB_CLIENT_ID)return process.env.DSH_GITHUB_CLIENT_ID;try{return JSON.parse(await readFile(new URL('./publisher.json',import.meta.url),'utf8')).clientId??'';}catch{return '';}}}
|
|
9
|
-
async configure(clientId){if(!/^[A-Za-z0-9_.-]{5,120}$/.test(clientId))throw Error('请输入有效的 OAuth App Client ID。');if(['preparing','waiting'].includes(this.login.state))throw Error('
|
|
15
|
+
async configure(clientId){if(!/^[A-Za-z0-9_.-]{5,120}$/.test(clientId))throw Error('请输入有效的 OAuth App Client ID。');if(['preparing','waiting'].includes(this.login.state))throw Error('请先完成或取消当前登录。');await mkdir(this.root,{recursive:true});await writeFile(path.join(this.root,'oauth.json'),JSON.stringify({clientId}));}
|
|
10
16
|
async hasCredential(){try{await readFile(path.join(this.root,'credential.dpapi'));return true;}catch{return false;}}
|
|
11
|
-
async
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
17
|
+
async credential(){
|
|
18
|
+
let encrypted;try{encrypted=await readFile(path.join(this.root,'credential.dpapi'),'utf8');}catch(e){this.diagnostics('credential_read',{reason:e.code==='ENOENT'?'missing':'read_failed',hasCredential:false});throw Object.assign(Error('请先在设置 → GitHub 中登录。'),{status:401});}
|
|
19
|
+
let plain;try{plain=await this.seal('unprotect',encrypted);}catch{this.diagnostics('credential_read',{reason:'decrypt_failed',hasCredential:true});throw Object.assign(Error('本机 GitHub 凭据无法解密,请重新连接。'),{status:401});}
|
|
20
|
+
if(typeof plain!=='string'||!plain.trim()){this.diagnostics('credential_read',{reason:'invalid_local',hasCredential:true});throw Object.assign(Error('本机 GitHub 凭据为空,请重新连接。'),{status:401});}
|
|
21
|
+
let data;if(plain.startsWith('{')){try{data=JSON.parse(plain);}catch{throw Object.assign(Error('本机 GitHub 凭据损坏,请重新连接。'),{status:401});}}else data={access_token:plain};
|
|
22
|
+
if(typeof data.access_token!=='string'||!data.access_token.trim())throw Object.assign(Error('本机 GitHub 凭据无效,请重新连接。'),{status:401});
|
|
23
|
+
this.diagnostics('credential_read',{reason:'ok',hasCredential:true});return data;
|
|
24
|
+
}
|
|
25
|
+
async save(r,epoch,clientId){
|
|
26
|
+
if(typeof r.access_token!=='string'||!r.access_token.trim())throw Error('GitHub 未返回有效凭据,请重新授权。');
|
|
27
|
+
const data={access_token:r.access_token,clientId,...(typeof r.refresh_token==='string'?{refresh_token:r.refresh_token}:{}),
|
|
28
|
+
...(Number(r.expires_in)>0?{expiresAt:this.now()+Number(r.expires_in)*1000}:{}),
|
|
29
|
+
...(Number(r.refresh_token_expires_in)>0?{refreshExpiresAt:this.now()+Number(r.refresh_token_expires_in)*1000}:{})};
|
|
30
|
+
await mkdir(this.root,{recursive:true});const temp=path.join(this.root,'credential-'+randomUUID()+'.tmp');
|
|
31
|
+
try{await writeFile(temp,await this.seal('protect',JSON.stringify(data)),{mode:0o600});await this.mutate(async()=>{if(epoch!==this.epoch)throw new DOMException('登录已取消。','AbortError');await rename(temp,path.join(this.root,'credential.dpapi'));});}finally{await unlink(temp).catch(()=>{});}
|
|
32
|
+
this.diagnostics('credential_saved',{reason:'ok',hasCredential:true});return data.access_token;
|
|
33
|
+
}
|
|
34
|
+
async token(){const d=await this.credential();if(!['preparing','waiting'].includes(this.login.state)&&d.refresh_token&&d.expiresAt&&this.now()>=d.expiresAt-60000)return this.refresh(d);return d.access_token;}
|
|
35
|
+
async refreshAfter401(rejected){if(['preparing','waiting'].includes(this.login.state))return null;const d=await this.credential();if(d.access_token!==rejected)return d.access_token;if(!d.refresh_token)return null;return this.refresh(d);}
|
|
36
|
+
async refresh(d){
|
|
37
|
+
if(this.refreshing)return this.refreshing;
|
|
38
|
+
const epoch=this.epoch,signal=this.refreshController=new AbortController();
|
|
39
|
+
this.refreshing=(async()=>{if(d.refreshExpiresAt&&this.now()>=d.refreshExpiresAt)throw Object.assign(Error('GitHub 续期凭据已过期,请重新登录。'),{status:401});
|
|
40
|
+
// Rotation can succeed before a response is lost. Never blindly replay refresh requests.
|
|
41
|
+
const r=await this.request('https://github.com/login/oauth/access_token',{client_id:d.clientId??await this.clientId(),grant_type:'refresh_token',refresh_token:d.refresh_token},{signal:signal.signal,attempts:1});
|
|
42
|
+
if(r.error||!r.refresh_token)throw Object.assign(Error('GitHub 登录已失效或续期响应不完整,请重新授权。'),{status:401});
|
|
43
|
+
return this.save(r,epoch,d.clientId??await this.clientId());
|
|
44
|
+
})();try{return await this.refreshing;}finally{this.refreshing=null;this.refreshController=null;}
|
|
45
|
+
}
|
|
46
|
+
async request(url,fields,{signal,attempts=3,deadline=Infinity,onRetry=()=>{}}={}){
|
|
47
|
+
for(let attempt=0;;attempt++){
|
|
48
|
+
signal?.throwIfAborted();const remaining=deadline-this.now();if(remaining<=0)throw Object.assign(Error('设备授权已过期,请重新登录。'),{reason:'expired_token'});
|
|
49
|
+
try{
|
|
50
|
+
const timeout=AbortSignal.timeout(Math.max(1,Math.min(30000,Math.ceil(remaining))));
|
|
51
|
+
const r=await this.fetch(url,{method:'POST',headers:{Accept:'application/json','Content-Type':'application/x-www-form-urlencoded'},body:new URLSearchParams(fields),signal:signal?AbortSignal.any([signal,timeout]):timeout,redirect:'error'});
|
|
52
|
+
if(!r.ok){await r.body?.cancel();throw Object.assign(Error('GitHub 授权服务暂时不可用('+r.status+')。'),{status:r.status,retryable:r.status===429||r.status>=500,retryAfter:Number(r.headers.get('retry-after'))||0,reason:'server_error'});}
|
|
53
|
+
try{return await r.json();}catch{throw Object.assign(Error('GitHub 返回的授权数据不完整,请检查加速线路。'),{retryable:true,reason:'network_error'});}
|
|
54
|
+
}catch(error){
|
|
55
|
+
if(signal?.aborted)throw signal.reason;
|
|
56
|
+
const e=error.reason||error.status?error:networkFailure(error);
|
|
57
|
+
if(!e.retryable||attempt+1>=attempts)throw e;
|
|
58
|
+
const wait=Math.max(1000*2**Math.min(attempt,4),(e.retryAfter??0)*1000);
|
|
59
|
+
if(this.now()+wait>=deadline)throw Object.assign(Error('设备授权已过期,请重新登录。'),{reason:'expired_token'});
|
|
60
|
+
onRetry(e);await this.sleep(wait,signal);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
async start(){
|
|
65
|
+
if(['preparing','waiting'].includes(this.login.state))return this.login;
|
|
66
|
+
const epoch=++this.epoch,controller=this.controller=new AbortController(),signal=controller.signal;
|
|
67
|
+
this.refreshController?.abort();this.login={state:'preparing'};let clientId;
|
|
68
|
+
try{clientId=await this.clientId();if(!clientId)throw Error('请先配置 GitHub OAuth App Client ID,并启用 Device Flow。');}
|
|
69
|
+
catch(e){this.login={state:'error',message:e.message};throw e;}
|
|
70
|
+
if(epoch!==this.epoch)return this.login;
|
|
71
|
+
this.diagnostics('oauth_started',{category:'authorization'});
|
|
72
|
+
this.task=(async()=>{try{
|
|
73
|
+
const notify=e=>{if(epoch===this.epoch){this.login={...this.login,message:e.message+' 正在自动重试…'};this.diagnostics('oauth_retry',{category:'authorization',reason:e.reason});}};
|
|
74
|
+
const d=await this.request('https://github.com/login/device/code',{client_id:clientId,scope:'repo offline_access'},{signal,onRetry:notify});
|
|
75
|
+
if(d.error||!d.device_code||!d.user_code)throw Object.assign(Error('无法开始 GitHub 授权,请检查 Client ID 及 Device Flow 配置。'),{reason:d.error});
|
|
76
|
+
signal.throwIfAborted();this.login={state:'waiting',code:d.user_code,url:'https://github.com/login/device'};
|
|
77
|
+
this.diagnostics('oauth_waiting',{category:'authorization'});
|
|
78
|
+
let interval=Math.max(5,Number(d.interval)||5),failures=0;const deadline=this.now()+Math.min(900,Number(d.expires_in)||900)*1000;
|
|
79
|
+
while(this.now()<deadline){
|
|
80
|
+
const wait=Math.max(interval,Math.min(60,interval*2**Math.min(failures,4)))*1000;
|
|
81
|
+
if(this.now()+wait>=deadline)break;await this.sleep(wait,signal);signal.throwIfAborted();if(this.now()>=deadline)break;
|
|
82
|
+
let r;try{r=await this.request('https://github.com/login/oauth/access_token',{client_id:clientId,device_code:d.device_code,grant_type:'urn:ietf:params:oauth:grant-type:device_code'},{signal,attempts:1,deadline});}
|
|
83
|
+
catch(e){if(signal.aborted||!e.retryable)throw e;failures++;interval=Math.max(interval,e.retryAfter??0);notify(e);continue;}
|
|
84
|
+
failures=0;this.login={...this.login,message:undefined};
|
|
85
|
+
if(r.access_token){await this.save(r,epoch,clientId);signal.throwIfAborted();this.login={state:'complete'};return;}
|
|
86
|
+
if(r.error==='authorization_pending')continue;
|
|
87
|
+
if(r.error==='slow_down'){interval=Math.max(interval+5,Number(r.interval)||0);continue;}
|
|
88
|
+
throw Object.assign(Error(r.error==='access_denied'?'你已取消 GitHub 授权。':'GitHub 授权已过期或被拒绝,请重新登录。'),{reason:r.error});
|
|
89
|
+
}
|
|
90
|
+
throw Object.assign(Error('设备授权已过期,请重新登录。'),{reason:'expired_token'});
|
|
91
|
+
}catch(e){if(epoch!==this.epoch)return;this.diagnostics('oauth_failed',{category:'authorization',reason:e.reason??'authorization_failed'});this.login={state:'error',message:e.message};}})();return this.login;
|
|
92
|
+
}
|
|
93
|
+
cancel(){++this.epoch;this.controller?.abort();this.refreshController?.abort();this.login={state:'idle'};}
|
|
94
|
+
mutate(fn){const task=(this.mutation??Promise.resolve()).catch(()=>{}).then(fn);this.mutation=task;return task;}
|
|
95
|
+
async logout(){this.cancel();await this.mutate(()=>unlink(path.join(this.root,'credential.dpapi')).catch(e=>{if(e.code!=='ENOENT')throw e;}));this.diagnostics('logout',{reason:'local_disconnect',hasCredential:false});}
|
|
96
|
+
dispose(){this.cancel();}
|
|
16
97
|
}
|
|
17
98
|
|
package/lib/gh.mjs
CHANGED
|
@@ -1,17 +1,98 @@
|
|
|
1
|
+
import {setTimeout as delay} from 'node:timers/promises';
|
|
2
|
+
import {randomUUID} from 'node:crypto';
|
|
3
|
+
import {networkFailure} from './network.mjs';
|
|
1
4
|
import {spawn} from 'node:child_process';
|
|
2
|
-
import {mkdir,readFile,writeFile,unlink} from 'node:fs/promises';
|
|
5
|
+
import {mkdir,readFile,writeFile,unlink,rename} from 'node:fs/promises';
|
|
3
6
|
import path from 'node:path';
|
|
4
7
|
export function command(exe,args,{input='',timeout=30000}={}){return new Promise((resolve,reject)=>{const child=spawn(exe,args,{windowsHide:true,stdio:['pipe','pipe','pipe']});let stdout='';const timer=setTimeout(()=>{child.kill();reject(Error('凭据操作超时。'));},timeout);child.on('error',e=>{clearTimeout(timer);reject(e);});child.stdout.on('data',b=>stdout+=b);child.stderr.resume();child.on('close',code=>{clearTimeout(timer);resolve({code,stdout});});child.stdin.on('error',()=>{});child.stdin.end(input);});}
|
|
5
8
|
export async function windowsSeal(action,value){if(process.platform!=='win32')throw Error('本版凭据保护仅支持 Windows。');const operation=action==='protect'?'Protect':'Unprotect';const script=`Add-Type -AssemblyName System.Security; $b=[Convert]::FromBase64String([Console]::In.ReadToEnd().Trim()); $r=[Security.Cryptography.ProtectedData]::${operation}($b,$null,[Security.Cryptography.DataProtectionScope]::CurrentUser); [Console]::Write([Convert]::ToBase64String($r))`;const r=await command('powershell.exe',['-NoProfile','-NonInteractive','-Command',script],{input:action==='protect'?Buffer.from(value,'utf8').toString('base64'):value});if(r.code!==0)throw Error('Windows 凭据加密失败。');return action==='protect'?r.stdout.trim():Buffer.from(r.stdout.trim(),'base64').toString('utf8');}
|
|
9
|
+
|
|
6
10
|
export class GhAuth{
|
|
7
|
-
constructor(root,{fetchImpl=fetch,seal=windowsSeal,sleep=ms=>
|
|
11
|
+
constructor(root,{fetchImpl=fetch,seal=windowsSeal,sleep=(ms,signal)=>delay(ms,undefined,{signal}),diagnostics=()=>{},now=Date.now}={}){
|
|
12
|
+
Object.assign(this,{root,fetch:fetchImpl,seal,sleep,diagnostics,now});this.login={state:'idle'};this.epoch=0;
|
|
13
|
+
}
|
|
8
14
|
async clientId(){try{return JSON.parse(await readFile(path.join(this.root,'oauth.json'),'utf8')).clientId;}catch{if(process.env.DSH_GITHUB_CLIENT_ID)return process.env.DSH_GITHUB_CLIENT_ID;try{return JSON.parse(await readFile(new URL('./publisher.json',import.meta.url),'utf8')).clientId??'';}catch{return '';}}}
|
|
9
|
-
async configure(clientId){if(!/^[A-Za-z0-9_.-]{5,120}$/.test(clientId))throw Error('请输入有效的 OAuth App Client ID。');if(['preparing','waiting'].includes(this.login.state))throw Error('
|
|
15
|
+
async configure(clientId){if(!/^[A-Za-z0-9_.-]{5,120}$/.test(clientId))throw Error('请输入有效的 OAuth App Client ID。');if(['preparing','waiting'].includes(this.login.state))throw Error('请先完成或取消当前登录。');await mkdir(this.root,{recursive:true});await writeFile(path.join(this.root,'oauth.json'),JSON.stringify({clientId}));}
|
|
10
16
|
async hasCredential(){try{await readFile(path.join(this.root,'credential.dpapi'));return true;}catch{return false;}}
|
|
11
|
-
async
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
17
|
+
async credential(){
|
|
18
|
+
let encrypted;try{encrypted=await readFile(path.join(this.root,'credential.dpapi'),'utf8');}catch(e){this.diagnostics('credential_read',{reason:e.code==='ENOENT'?'missing':'read_failed',hasCredential:false});throw Object.assign(Error('请先在设置 → GitHub 中登录。'),{status:401});}
|
|
19
|
+
let plain;try{plain=await this.seal('unprotect',encrypted);}catch{this.diagnostics('credential_read',{reason:'decrypt_failed',hasCredential:true});throw Object.assign(Error('本机 GitHub 凭据无法解密,请重新连接。'),{status:401});}
|
|
20
|
+
if(typeof plain!=='string'||!plain.trim()){this.diagnostics('credential_read',{reason:'invalid_local',hasCredential:true});throw Object.assign(Error('本机 GitHub 凭据为空,请重新连接。'),{status:401});}
|
|
21
|
+
let data;if(plain.startsWith('{')){try{data=JSON.parse(plain);}catch{throw Object.assign(Error('本机 GitHub 凭据损坏,请重新连接。'),{status:401});}}else data={access_token:plain};
|
|
22
|
+
if(typeof data.access_token!=='string'||!data.access_token.trim())throw Object.assign(Error('本机 GitHub 凭据无效,请重新连接。'),{status:401});
|
|
23
|
+
this.diagnostics('credential_read',{reason:'ok',hasCredential:true});return data;
|
|
24
|
+
}
|
|
25
|
+
async save(r,epoch,clientId){
|
|
26
|
+
if(typeof r.access_token!=='string'||!r.access_token.trim())throw Error('GitHub 未返回有效凭据,请重新授权。');
|
|
27
|
+
const data={access_token:r.access_token,clientId,...(typeof r.refresh_token==='string'?{refresh_token:r.refresh_token}:{}),
|
|
28
|
+
...(Number(r.expires_in)>0?{expiresAt:this.now()+Number(r.expires_in)*1000}:{}),
|
|
29
|
+
...(Number(r.refresh_token_expires_in)>0?{refreshExpiresAt:this.now()+Number(r.refresh_token_expires_in)*1000}:{})};
|
|
30
|
+
await mkdir(this.root,{recursive:true});const temp=path.join(this.root,'credential-'+randomUUID()+'.tmp');
|
|
31
|
+
try{await writeFile(temp,await this.seal('protect',JSON.stringify(data)),{mode:0o600});await this.mutate(async()=>{if(epoch!==this.epoch)throw new DOMException('登录已取消。','AbortError');await rename(temp,path.join(this.root,'credential.dpapi'));});}finally{await unlink(temp).catch(()=>{});}
|
|
32
|
+
this.diagnostics('credential_saved',{reason:'ok',hasCredential:true});return data.access_token;
|
|
33
|
+
}
|
|
34
|
+
async token(){const d=await this.credential();if(!['preparing','waiting'].includes(this.login.state)&&d.refresh_token&&d.expiresAt&&this.now()>=d.expiresAt-60000)return this.refresh(d);return d.access_token;}
|
|
35
|
+
async refreshAfter401(rejected){if(['preparing','waiting'].includes(this.login.state))return null;const d=await this.credential();if(d.access_token!==rejected)return d.access_token;if(!d.refresh_token)return null;return this.refresh(d);}
|
|
36
|
+
async refresh(d){
|
|
37
|
+
if(this.refreshing)return this.refreshing;
|
|
38
|
+
const epoch=this.epoch,signal=this.refreshController=new AbortController();
|
|
39
|
+
this.refreshing=(async()=>{if(d.refreshExpiresAt&&this.now()>=d.refreshExpiresAt)throw Object.assign(Error('GitHub 续期凭据已过期,请重新登录。'),{status:401});
|
|
40
|
+
// Rotation can succeed before a response is lost. Never blindly replay refresh requests.
|
|
41
|
+
const r=await this.request('https://github.com/login/oauth/access_token',{client_id:d.clientId??await this.clientId(),grant_type:'refresh_token',refresh_token:d.refresh_token},{signal:signal.signal,attempts:1});
|
|
42
|
+
if(r.error||!r.refresh_token)throw Object.assign(Error('GitHub 登录已失效或续期响应不完整,请重新授权。'),{status:401});
|
|
43
|
+
return this.save(r,epoch,d.clientId??await this.clientId());
|
|
44
|
+
})();try{return await this.refreshing;}finally{this.refreshing=null;this.refreshController=null;}
|
|
45
|
+
}
|
|
46
|
+
async request(url,fields,{signal,attempts=3,deadline=Infinity,onRetry=()=>{}}={}){
|
|
47
|
+
for(let attempt=0;;attempt++){
|
|
48
|
+
signal?.throwIfAborted();const remaining=deadline-this.now();if(remaining<=0)throw Object.assign(Error('设备授权已过期,请重新登录。'),{reason:'expired_token'});
|
|
49
|
+
try{
|
|
50
|
+
const timeout=AbortSignal.timeout(Math.max(1,Math.min(30000,Math.ceil(remaining))));
|
|
51
|
+
const r=await this.fetch(url,{method:'POST',headers:{Accept:'application/json','Content-Type':'application/x-www-form-urlencoded'},body:new URLSearchParams(fields),signal:signal?AbortSignal.any([signal,timeout]):timeout,redirect:'error'});
|
|
52
|
+
if(!r.ok){await r.body?.cancel();throw Object.assign(Error('GitHub 授权服务暂时不可用('+r.status+')。'),{status:r.status,retryable:r.status===429||r.status>=500,retryAfter:Number(r.headers.get('retry-after'))||0,reason:'server_error'});}
|
|
53
|
+
try{return await r.json();}catch{throw Object.assign(Error('GitHub 返回的授权数据不完整,请检查加速线路。'),{retryable:true,reason:'network_error'});}
|
|
54
|
+
}catch(error){
|
|
55
|
+
if(signal?.aborted)throw signal.reason;
|
|
56
|
+
const e=error.reason||error.status?error:networkFailure(error);
|
|
57
|
+
if(!e.retryable||attempt+1>=attempts)throw e;
|
|
58
|
+
const wait=Math.max(1000*2**Math.min(attempt,4),(e.retryAfter??0)*1000);
|
|
59
|
+
if(this.now()+wait>=deadline)throw Object.assign(Error('设备授权已过期,请重新登录。'),{reason:'expired_token'});
|
|
60
|
+
onRetry(e);await this.sleep(wait,signal);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
async start(){
|
|
65
|
+
if(['preparing','waiting'].includes(this.login.state))return this.login;
|
|
66
|
+
const epoch=++this.epoch,controller=this.controller=new AbortController(),signal=controller.signal;
|
|
67
|
+
this.refreshController?.abort();this.login={state:'preparing'};let clientId;
|
|
68
|
+
try{clientId=await this.clientId();if(!clientId)throw Error('请先配置 GitHub OAuth App Client ID,并启用 Device Flow。');}
|
|
69
|
+
catch(e){this.login={state:'error',message:e.message};throw e;}
|
|
70
|
+
if(epoch!==this.epoch)return this.login;
|
|
71
|
+
this.diagnostics('oauth_started',{category:'authorization'});
|
|
72
|
+
this.task=(async()=>{try{
|
|
73
|
+
const notify=e=>{if(epoch===this.epoch){this.login={...this.login,message:e.message+' 正在自动重试…'};this.diagnostics('oauth_retry',{category:'authorization',reason:e.reason});}};
|
|
74
|
+
const d=await this.request('https://github.com/login/device/code',{client_id:clientId,scope:'repo offline_access'},{signal,onRetry:notify});
|
|
75
|
+
if(d.error||!d.device_code||!d.user_code)throw Object.assign(Error('无法开始 GitHub 授权,请检查 Client ID 及 Device Flow 配置。'),{reason:d.error});
|
|
76
|
+
signal.throwIfAborted();this.login={state:'waiting',code:d.user_code,url:'https://github.com/login/device'};
|
|
77
|
+
this.diagnostics('oauth_waiting',{category:'authorization'});
|
|
78
|
+
let interval=Math.max(5,Number(d.interval)||5),failures=0;const deadline=this.now()+Math.min(900,Number(d.expires_in)||900)*1000;
|
|
79
|
+
while(this.now()<deadline){
|
|
80
|
+
const wait=Math.max(interval,Math.min(60,interval*2**Math.min(failures,4)))*1000;
|
|
81
|
+
if(this.now()+wait>=deadline)break;await this.sleep(wait,signal);signal.throwIfAborted();if(this.now()>=deadline)break;
|
|
82
|
+
let r;try{r=await this.request('https://github.com/login/oauth/access_token',{client_id:clientId,device_code:d.device_code,grant_type:'urn:ietf:params:oauth:grant-type:device_code'},{signal,attempts:1,deadline});}
|
|
83
|
+
catch(e){if(signal.aborted||!e.retryable)throw e;failures++;interval=Math.max(interval,e.retryAfter??0);notify(e);continue;}
|
|
84
|
+
failures=0;this.login={...this.login,message:undefined};
|
|
85
|
+
if(r.access_token){await this.save(r,epoch,clientId);signal.throwIfAborted();this.login={state:'complete'};return;}
|
|
86
|
+
if(r.error==='authorization_pending')continue;
|
|
87
|
+
if(r.error==='slow_down'){interval=Math.max(interval+5,Number(r.interval)||0);continue;}
|
|
88
|
+
throw Object.assign(Error(r.error==='access_denied'?'你已取消 GitHub 授权。':'GitHub 授权已过期或被拒绝,请重新登录。'),{reason:r.error});
|
|
89
|
+
}
|
|
90
|
+
throw Object.assign(Error('设备授权已过期,请重新登录。'),{reason:'expired_token'});
|
|
91
|
+
}catch(e){if(epoch!==this.epoch)return;this.diagnostics('oauth_failed',{category:'authorization',reason:e.reason??'authorization_failed'});this.login={state:'error',message:e.message};}})();return this.login;
|
|
92
|
+
}
|
|
93
|
+
cancel(){++this.epoch;this.controller?.abort();this.refreshController?.abort();this.login={state:'idle'};}
|
|
94
|
+
mutate(fn){const task=(this.mutation??Promise.resolve()).catch(()=>{}).then(fn);this.mutation=task;return task;}
|
|
95
|
+
async logout(){this.cancel();await this.mutate(()=>unlink(path.join(this.root,'credential.dpapi')).catch(e=>{if(e.code!=='ENOENT')throw e;}));this.diagnostics('logout',{reason:'local_disconnect',hasCredential:false});}
|
|
96
|
+
dispose(){this.cancel();}
|
|
16
97
|
}
|
|
17
98
|
|
package/lib/http.js
CHANGED
|
@@ -6,7 +6,7 @@ import {Transform} from 'node:stream';
|
|
|
6
6
|
import path from 'node:path';
|
|
7
7
|
|
|
8
8
|
export const API='/dsh-github/api/';
|
|
9
|
-
const ROUTES={state:'GET',repos:'GET',contents:'GET',releases:'GET','auth/start':'POST','auth/configure':'POST','auth/logout':'POST',prepare:'POST',confirm:'POST',reject:'POST',upload:'POST','attachment/remove':'POST','ai/copy':'POST','ai/program':'POST','draft/get':'POST','draft/save':'POST','draft/clear':'POST'};
|
|
9
|
+
const ROUTES={state:'GET',repos:'GET',contents:'GET',releases:'GET','auth/start':'POST','auth/cancel':'POST','auth/configure':'POST','auth/logout':'POST',prepare:'POST',confirm:'POST',reject:'POST',upload:'POST','attachment/remove':'POST','ai/copy':'POST','ai/program':'POST','draft/get':'POST','draft/save':'POST','draft/clear':'POST'};
|
|
10
10
|
const json=(res,status,value)=>{res.writeHead(status,{'Content-Type':'application/json; charset=utf-8','Cache-Control':'no-store','X-Content-Type-Options':'nosniff'});res.end(JSON.stringify(value));};
|
|
11
11
|
async function body(req){let size=0;const parts=[];for await(const b of req){size+=b.length;if(size>3*1024*1024)throw Error('请求内容过大。');parts.push(b);}return JSON.parse(Buffer.concat(parts).toString('utf8')||'{}');}
|
|
12
12
|
export function admitted(req,connection){
|
|
@@ -35,6 +35,7 @@ export function routes({api,ops,auth,root,connection,releaseCopy,drafts}){
|
|
|
35
35
|
else if(name==='ai/program'){if(!releaseCopy)throw Error('AI介绍服务未就绪。');result=await releaseCopy.describeProgram(a);}
|
|
36
36
|
else if(name==='ai/copy'){if(!releaseCopy)throw Error('AI文案服务尚未就绪。');result=await releaseCopy.create(a);}
|
|
37
37
|
else if(name==='auth/start')result=await auth.start();
|
|
38
|
+
else if(name==='auth/cancel'){auth.cancel();result={ok:true};}
|
|
38
39
|
else if(name==='auth/configure'){await auth.configure(a.clientId);result={ok:true};}
|
|
39
40
|
else if(name==='auth/logout'){await auth.logout();ops.clearPending();result={ok:true};}
|
|
40
41
|
else if(name==='prepare'){result=await ops.prepare(a.kind,a.args);if(drafts&&a.kind==='create_repository')await drafts.clear({kind:'repository'});if(drafts&&a.kind==='create_release')await drafts.clear({kind:'release',owner:a.args.owner,repo:a.args.repo});}
|
package/lib/http.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import {Transform} from 'node:stream';
|
|
|
6
6
|
import path from 'node:path';
|
|
7
7
|
|
|
8
8
|
export const API='/dsh-github/api/';
|
|
9
|
-
const ROUTES={state:'GET',repos:'GET',contents:'GET',releases:'GET','auth/start':'POST','auth/configure':'POST','auth/logout':'POST',prepare:'POST',confirm:'POST',reject:'POST',upload:'POST','attachment/remove':'POST','ai/copy':'POST','ai/program':'POST','draft/get':'POST','draft/save':'POST','draft/clear':'POST'};
|
|
9
|
+
const ROUTES={state:'GET',repos:'GET',contents:'GET',releases:'GET','auth/start':'POST','auth/cancel':'POST','auth/configure':'POST','auth/logout':'POST',prepare:'POST',confirm:'POST',reject:'POST',upload:'POST','attachment/remove':'POST','ai/copy':'POST','ai/program':'POST','draft/get':'POST','draft/save':'POST','draft/clear':'POST'};
|
|
10
10
|
const json=(res,status,value)=>{res.writeHead(status,{'Content-Type':'application/json; charset=utf-8','Cache-Control':'no-store','X-Content-Type-Options':'nosniff'});res.end(JSON.stringify(value));};
|
|
11
11
|
async function body(req){let size=0;const parts=[];for await(const b of req){size+=b.length;if(size>3*1024*1024)throw Error('请求内容过大。');parts.push(b);}return JSON.parse(Buffer.concat(parts).toString('utf8')||'{}');}
|
|
12
12
|
export function admitted(req,connection){
|
|
@@ -35,6 +35,7 @@ export function routes({api,ops,auth,root,connection,releaseCopy,drafts}){
|
|
|
35
35
|
else if(name==='ai/program'){if(!releaseCopy)throw Error('AI介绍服务未就绪。');result=await releaseCopy.describeProgram(a);}
|
|
36
36
|
else if(name==='ai/copy'){if(!releaseCopy)throw Error('AI文案服务尚未就绪。');result=await releaseCopy.create(a);}
|
|
37
37
|
else if(name==='auth/start')result=await auth.start();
|
|
38
|
+
else if(name==='auth/cancel'){auth.cancel();result={ok:true};}
|
|
38
39
|
else if(name==='auth/configure'){await auth.configure(a.clientId);result={ok:true};}
|
|
39
40
|
else if(name==='auth/logout'){await auth.logout();ops.clearPending();result={ok:true};}
|
|
40
41
|
else if(name==='prepare'){result=await ops.prepare(a.kind,a.args);if(drafts&&a.kind==='create_repository')await drafts.clear({kind:'repository'});if(drafts&&a.kind==='create_release')await drafts.clear({kind:'release',owner:a.args.owner,repo:a.args.repo});}
|
package/lib/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import os from 'node:os';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
+
import {createTransport} from './network.mjs';
|
|
3
4
|
import {GhAuth} from './gh.mjs';
|
|
4
5
|
import {GitHub,Operations} from './core.mjs';
|
|
5
6
|
import {routes} from './http.mjs';
|
|
@@ -13,12 +14,13 @@ export function apply(ctx){
|
|
|
13
14
|
ctx.inject(['webServer','tools','connection'],async host=>{
|
|
14
15
|
const root=path.join(process.env.DSH_HOME??path.join(os.homedir(),'.dsh'),'github-connect');
|
|
15
16
|
const diagnostics=createDiagnostics(root);diagnostics('plugin_started');
|
|
16
|
-
const
|
|
17
|
+
const transport=createTransport();
|
|
18
|
+
const auth=new GhAuth(root,{diagnostics,fetchImpl:transport.fetch}),api=new GitHub({auth,diagnostics,fetchImpl:transport.fetch}),ops=new Operations(api,{root});await ops.init();
|
|
17
19
|
const releaseCopy=new ReleaseCopy({api,ctx:host,root,ops});
|
|
18
20
|
const drafts=new Drafts({root});
|
|
19
21
|
for(const route of routes({api,ops,auth,root,releaseCopy,drafts,connection:()=>host.get('connection')}))host.effect(()=>host.webServer.register(route));
|
|
20
22
|
for(const definition of definitions(api,ops))host.effect(()=>host.tools.register(definition,{when:({agent})=>localAgent(agent)}));
|
|
21
|
-
host.on('dispose',()=>{diagnostics('plugin_stopped');ops.clearPending();});
|
|
23
|
+
host.on('dispose',()=>{diagnostics('plugin_stopped');auth.dispose();transport.close().catch(()=>{});ops.clearPending();});
|
|
22
24
|
});
|
|
23
25
|
}
|
|
24
26
|
|
package/lib/network.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import tls from 'node:tls';
|
|
2
|
+
import {EnvHttpProxyAgent,fetch as undiciFetch} from 'undici';
|
|
3
|
+
|
|
4
|
+
const messages={
|
|
5
|
+
tls_error:'GitHub HTTPS 证书校验失败。请检查加速器证书是否已正确安装到 Windows 信任证书库,或暂时关闭 GitHub 加速。',
|
|
6
|
+
dns_error:'无法解析 GitHub 地址,请检查 DNS 或加速器的域名接管。',
|
|
7
|
+
timeout:'连接 GitHub 超时,请检查网络或代理线路。',
|
|
8
|
+
connection_error:'GitHub 连接中断或代理端口不可用,请检查加速器和代理设置。',
|
|
9
|
+
network_error:'无法连接 GitHub,请检查网络与代理设置。'
|
|
10
|
+
};
|
|
11
|
+
export function networkFailure(error){
|
|
12
|
+
if(error?.reason&&messages[error.reason])return error;
|
|
13
|
+
const errors=[error,error?.cause,...(error?.cause?.errors??[])];
|
|
14
|
+
const codes=errors.map(e=>e?.code??e?.name??'');
|
|
15
|
+
const reason=codes.some(c=>/CERT|SELF_SIGNED|TLS|SSL/.test(c))?'tls_error':
|
|
16
|
+
codes.some(c=>/ENOTFOUND|EAI_AGAIN/.test(c))?'dns_error':
|
|
17
|
+
codes.some(c=>/TIMEOUT|TimeoutError|ETIMEDOUT/.test(c))?'timeout':
|
|
18
|
+
codes.some(c=>/ECONN|EHOST|ENET|UND_ERR_SOCKET/.test(c))?'connection_error':'network_error';
|
|
19
|
+
return Object.assign(Error(messages[reason]),{reason,retryable:reason!=='tls_error',cause:error});
|
|
20
|
+
}
|
|
21
|
+
export function createTransport({env=process.env,fetchImpl=undiciFetch}={}){
|
|
22
|
+
const ca=[...new Set([...(tls.getCACertificates?.('default')??tls.rootCertificates),...(tls.getCACertificates?.('system')??[])])];
|
|
23
|
+
const explicit=env.DSH_GITHUB_PROXY;
|
|
24
|
+
const httpProxy=explicit??env.http_proxy??env.HTTP_PROXY??'';
|
|
25
|
+
const httpsProxy=explicit??env.https_proxy??env.HTTPS_PROXY??httpProxy;
|
|
26
|
+
for(const address of [httpProxy,httpsProxy])if(address){let url;try{url=new URL(address);}catch{throw Error('GitHub 代理地址无效,请设置 HTTP 或 HTTPS 代理地址。');}if(!['http:','https:'].includes(url.protocol))throw Error('GitHub 代理目前仅支持 HTTP/HTTPS;请使用加速器的 HTTP 代理端口。');}
|
|
27
|
+
const dispatcher=new EnvHttpProxyAgent({httpProxy,httpsProxy,noProxy:env.no_proxy??env.NO_PROXY??'',connect:{ca,autoSelectFamily:true},requestTls:{ca},proxyTls:{ca}});
|
|
28
|
+
return {
|
|
29
|
+
async fetch(url,options){try{return await fetchImpl(url,{...options,dispatcher});}catch(e){if(options?.signal?.aborted&&options.signal.reason?.name==='AbortError')throw options.signal.reason;throw networkFailure(e);}},
|
|
30
|
+
close:()=>dispatcher.destroy()
|
|
31
|
+
};
|
|
32
|
+
}
|
package/lib/network.mjs
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import tls from 'node:tls';
|
|
2
|
+
import {EnvHttpProxyAgent,fetch as undiciFetch} from 'undici';
|
|
3
|
+
|
|
4
|
+
const messages={
|
|
5
|
+
tls_error:'GitHub HTTPS 证书校验失败。请检查加速器证书是否已正确安装到 Windows 信任证书库,或暂时关闭 GitHub 加速。',
|
|
6
|
+
dns_error:'无法解析 GitHub 地址,请检查 DNS 或加速器的域名接管。',
|
|
7
|
+
timeout:'连接 GitHub 超时,请检查网络或代理线路。',
|
|
8
|
+
connection_error:'GitHub 连接中断或代理端口不可用,请检查加速器和代理设置。',
|
|
9
|
+
network_error:'无法连接 GitHub,请检查网络与代理设置。'
|
|
10
|
+
};
|
|
11
|
+
export function networkFailure(error){
|
|
12
|
+
if(error?.reason&&messages[error.reason])return error;
|
|
13
|
+
const errors=[error,error?.cause,...(error?.cause?.errors??[])];
|
|
14
|
+
const codes=errors.map(e=>e?.code??e?.name??'');
|
|
15
|
+
const reason=codes.some(c=>/CERT|SELF_SIGNED|TLS|SSL/.test(c))?'tls_error':
|
|
16
|
+
codes.some(c=>/ENOTFOUND|EAI_AGAIN/.test(c))?'dns_error':
|
|
17
|
+
codes.some(c=>/TIMEOUT|TimeoutError|ETIMEDOUT/.test(c))?'timeout':
|
|
18
|
+
codes.some(c=>/ECONN|EHOST|ENET|UND_ERR_SOCKET/.test(c))?'connection_error':'network_error';
|
|
19
|
+
return Object.assign(Error(messages[reason]),{reason,retryable:reason!=='tls_error',cause:error});
|
|
20
|
+
}
|
|
21
|
+
export function createTransport({env=process.env,fetchImpl=undiciFetch}={}){
|
|
22
|
+
const ca=[...new Set([...(tls.getCACertificates?.('default')??tls.rootCertificates),...(tls.getCACertificates?.('system')??[])])];
|
|
23
|
+
const explicit=env.DSH_GITHUB_PROXY;
|
|
24
|
+
const httpProxy=explicit??env.http_proxy??env.HTTP_PROXY??'';
|
|
25
|
+
const httpsProxy=explicit??env.https_proxy??env.HTTPS_PROXY??httpProxy;
|
|
26
|
+
for(const address of [httpProxy,httpsProxy])if(address){let url;try{url=new URL(address);}catch{throw Error('GitHub 代理地址无效,请设置 HTTP 或 HTTPS 代理地址。');}if(!['http:','https:'].includes(url.protocol))throw Error('GitHub 代理目前仅支持 HTTP/HTTPS;请使用加速器的 HTTP 代理端口。');}
|
|
27
|
+
const dispatcher=new EnvHttpProxyAgent({httpProxy,httpsProxy,noProxy:env.no_proxy??env.NO_PROXY??'',connect:{ca,autoSelectFamily:true},requestTls:{ca},proxyTls:{ca}});
|
|
28
|
+
return {
|
|
29
|
+
async fetch(url,options){try{return await fetchImpl(url,{...options,dispatcher});}catch(e){if(options?.signal?.aborted&&options.signal.reason?.name==='AbortError')throw options.signal.reason;throw networkFailure(e);}},
|
|
30
|
+
close:()=>dispatcher.destroy()
|
|
31
|
+
};
|
|
32
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-github-studio",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.7",
|
|
4
4
|
"description": "DeepSeek Harness GitHub 工作台:账号连接、仓库工具、AI 项目介绍与 Release 发布",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -67,6 +67,10 @@
|
|
|
67
67
|
"remark-gfm": "^4.0.1"
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
|
+
"undici": "^7.30.2",
|
|
70
71
|
"yauzl": "^3.4.0"
|
|
72
|
+
},
|
|
73
|
+
"engines": {
|
|
74
|
+
"node": ">=24"
|
|
71
75
|
}
|
|
72
76
|
}
|