@brain-toolkit/issue-forge 0.1.0 → 0.1.1
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/CHANGELOG.md +29 -0
- package/LICENSE +15 -0
- package/README.md +1 -2
- package/dist/chunk-MQ7IDBIZ.js +4 -0
- package/dist/{chunk-RQKDVDLH.js.map → chunk-MQ7IDBIZ.js.map} +1 -1
- package/dist/feedback/index.cjs +4 -871
- package/dist/feedback/index.cjs.map +1 -1
- package/dist/feedback/index.js +4 -527
- package/dist/feedback/index.js.map +1 -1
- package/dist/index.cjs +3 -514
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -22
- package/package.json +19 -33
- package/dist/chunk-RQKDVDLH.js +0 -471
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
#### ✨ Features
|
|
8
|
+
|
|
9
|
+
- **pam:** 截图发布幂等、本地清理与按钮文案 ([63adcd7](https://github.com/qlover/brain-toolkit/commit/63adcd7e4f2f566c951b479a59777e855044c696)) ([#226](https://github.com/qlover/brain-toolkit/pull/226))
|
|
10
|
+
|
|
11
|
+
发评前按 Issue 评论查重,避免超时重试重复挂图;成功后落库 GitHub URL 并清理 Supabase。
|
|
12
|
+
Admin 改为「发布截图」,仅本地仍有图时显示;手动发布强制重置 count。
|
|
13
|
+
|
|
14
|
+
- **issue-forge:** 新增 Issue 网关与 feedback 编排包 ([b94486e](https://github.com/qlover/brain-toolkit/commit/b94486e8c662a9f79f1a5f35e189d9cbefc54ecd)) ([#217](https://github.com/qlover/brain-toolkit/pull/217))
|
|
15
|
+
|
|
16
|
+
GitHub App 网关/验签;feedback 子路径提供 Host 端口、模板渲染与同步引擎。
|
|
17
|
+
|
|
18
|
+
#### 🐞 Bug Fixes
|
|
19
|
+
|
|
20
|
+
- **issue-forge:** 入口改为 dist,并补充发版相关规则 ([f185cd7](https://github.com/qlover/brain-toolkit/commit/f185cd7b95c0394739308d27d45075695422ab11)) ([#227](https://github.com/qlover/brain-toolkit/pull/227))
|
|
21
|
+
|
|
22
|
+
顶层 main/exports 直接指向 dist,publishConfig 仅 access。同步:禁止手改 version/CHANGELOG/changeset;禁止外力绕过、改动须成比例。
|
|
23
|
+
|
|
24
|
+
- **pam:** 修复反馈截图漏同步并增加 Admin 详情抽屉 ([edb1c96](https://github.com/qlover/brain-toolkit/commit/edb1c966889698560f2cd3d7500903ac580fe2ab)) ([#226](https://github.com/qlover/brain-toolkit/pull/226))
|
|
25
|
+
|
|
26
|
+
消除建 Issue 与传截图竞态;评论改用 raw URL;Admin 可补同步截图并点行看详情。
|
|
27
|
+
|
|
28
|
+
- **issue-forge:** 修复截图同步单测在根 type-check 下的类型错误 ([936ef9c](https://github.com/qlover/brain-toolkit/commit/936ef9cfcb77e194a4e988c285fc6556f7138d01)) ([#226](https://github.com/qlover/brain-toolkit/pull/226))
|
|
29
|
+
|
|
30
|
+
根 tsconfig.test 会检查 packages/\*\*/**tests**;避免对 mock.calls 元组做不安全下标断言。
|
|
31
|
+
|
|
3
32
|
## 0.1.0
|
|
4
33
|
|
|
5
34
|
- 初版:GitHub App Issue 网关 + `/feedback` 同步编排(建 Issue、截图评论、webhook 关单回写)
|
package/LICENSE
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
ISC License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024, brain-toolkit contributors
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
+
copyright notice and this permission notice appear in all copies.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
10
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
11
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
12
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
13
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
14
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
15
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
package/README.md
CHANGED
|
@@ -8,8 +8,7 @@ Forge 无关的 Issue 网关;**GitHub App** 为第一个实现。可选子路
|
|
|
8
8
|
pnpm --filter @brain-toolkit/issue-forge build
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
-
|
|
12
|
-
- npm 发布:`publishConfig` 指向 `dist`(esm / cjs / dts)
|
|
11
|
+
- `main` / `module` / `types` / `exports` 均指向 `dist`(与 `brain-user` 等包一致);使用前先 `build`
|
|
13
12
|
|
|
14
13
|
## `@brain-toolkit/issue-forge`(协议)
|
|
15
14
|
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var a=class extends Error{code="ISSUE_FORGE_FAILED";status;constructor(e,t){super(e),this.name="IssueForgeError",this.status=t}};import f from"jsonwebtoken";var d="https://api.github.com",y="2022-11-28",I="brain-toolkit-issue-forge",b=6e4,w=540,T=60,C=120*1e3,c=class{cache;userAgent;constructor(e){this.cache=e.cache,this.userAgent=e.userAgent?.trim()||I}async request(e,t,o){let r=await this.getInstallationToken(e),s=this.headers(`Bearer ${r}`);o.accept&&(s.Accept=o.accept),o.body!==void 0&&(s["Content-Type"]="application/json");let n=await this.send(`${d}${t}`,{method:o.method,headers:s,...o.body!==void 0?{body:JSON.stringify(o.body)}:{}});return(n.status===401||n.status===403)&&await this.cache.removeItem(this.tokenCacheKey(e)),n}async toError(e,t){let o="";try{let r=await t.json();o=typeof r.message=="string"?r.message:""}catch{o=""}return new a(`${e}: HTTP ${String(t.status)}${o?` ${o}`:""}`,t.status)}async getInstallationToken(e){let t=this.tokenCacheKey(e),o=await this.cache.getItem(t);if(o?.token)return o.token;let r=await this.send(`${d}/app/installations/${encodeURIComponent(e.installationId)}/access_tokens`,{method:"POST",headers:this.headers(`Bearer ${this.signAppJwt(e)}`)});if(!r.ok)throw await this.toError("installation token",r);let s=await r.json();if(typeof s.token!="string"||!s.token)throw new a("installation token: empty token",r.status);let n=typeof s.expires_at=="string"?Date.parse(s.expires_at):Number.NaN,l=Number.isFinite(n)?n-Date.now()-C:0;return l>0&&await this.cache.setItem(t,{token:s.token},{ttlMs:l}),s.token}signAppJwt(e){let t=Math.floor(Date.now()/1e3);try{return f.sign({iat:t-T,exp:t+w,iss:e.appId},this.normalizePrivateKey(e.privateKey),{algorithm:"RS256"})}catch(o){throw new a(`invalid GitHub App private key: ${o instanceof Error?o.message:String(o)}`,null)}}normalizePrivateKey(e){return e.replace(/\\n/g,`
|
|
2
|
+
`).replace(/\r\n/g,`
|
|
3
|
+
`).trim()}async send(e,t){try{return await fetch(e,{...t,signal:AbortSignal.timeout(b)})}catch(o){throw new a(`GitHub request failed: ${o instanceof Error?o.message:String(o)}`,null)}}headers(e){return{Accept:"application/vnd.github+json",Authorization:e,"User-Agent":this.userAgent,"X-GitHub-Api-Version":y}}tokenCacheKey(e){return`issue-forge:github:installation-token:${e.appId}:${e.installationId}`}};var A="application/vnd.github.raw+json",p=class{constructor(e,t){this.client=e;this.config=t}async readTextFile(e){let t=await this.client.request(this.config,this.contentsPath(e),{method:"GET",accept:A});if(t.status===404)return null;if(!t.ok)throw await this.client.toError("read file",t);return t.text()}async hasFile(e,t){let o=await this.client.request(this.config,`${this.contentsPath(e)}?ref=${encodeURIComponent(t)}`,{method:"GET"});if(o.status===404)return!1;if(!o.ok)throw await this.client.toError("has file",o);return!0}async ensureBranch(e,t){let o=await this.client.request(this.config,`${this.repoPath()}/git/ref/heads/${this.encodePath(e)}`,{method:"GET"});if(o.ok)return;if(o.status!==404)throw await this.client.toError("get branch",o);let r=await this.postForSha("create tree","/git/trees",{tree:[{path:t.path,mode:"100644",type:"blob",content:t.content}]}),s=await this.postForSha("create commit","/git/commits",{message:`chore: \u521D\u59CB\u5316 ${e} \u5206\u652F`,tree:r,parents:[]}),n=await this.client.request(this.config,`${this.repoPath()}/git/refs`,{method:"POST",body:{ref:`refs/heads/${e}`,sha:s}});if(!n.ok&&n.status!==422)throw await this.client.toError("create branch",n)}async uploadFile(e){let t=await this.client.request(this.config,this.contentsPath(e.path),{method:"PUT",body:{message:e.message,content:e.contentBase64,branch:e.branch}});if(t.ok){let o=await t.json();return{url:this.requireHtmlUrl(o.content?.html_url,t)}}if(t.status===422)return this.readExisting(e);throw await this.client.toError("upload file",t)}async readExisting(e){let t=await this.client.request(this.config,`${this.contentsPath(e.path)}?ref=${encodeURIComponent(e.branch)}`,{method:"GET"});if(!t.ok)throw await this.client.toError("upload file",t);let o=await t.json();return{url:this.requireHtmlUrl(o.html_url,t)}}async postForSha(e,t,o){let r=await this.client.request(this.config,`${this.repoPath()}${t}`,{method:"POST",body:o});if(!r.ok)throw await this.client.toError(e,r);let s=await r.json();if(typeof s.sha!="string"||!s.sha)throw new a(`${e}: unexpected response`,r.status);return s.sha}requireHtmlUrl(e,t){if(typeof e!="string"||!e)throw new a("upload file: unexpected response",t.status);return e}contentsPath(e){return`${this.repoPath()}/contents/${this.encodePath(e)}`}encodePath(e){return e.split("/").filter(t=>t.length>0).map(t=>encodeURIComponent(t)).join("/")}repoPath(){return`/repos/${encodeURIComponent(this.config.owner)}/${encodeURIComponent(this.config.repo)}`}};var g=100,u=class{constructor(e,t){this.client=e;this.config=t;this.assets=new p(e,t)}assets;async createIssue(e){let t=await this.postIssue(e,e.labels);if(t.ok)return this.readCreated(t);if(t.status===422&&e.labels.length>0){let o=await this.postIssue(e,[]);if(o.ok)return this.readCreated(o);throw await this.client.toError("create issue",o)}throw await this.client.toError("create issue",t)}async createComment(e,t){let o=await this.client.request(this.config,`${this.repoPath()}/issues/${String(e.issueNumber)}/comments`,{method:"POST",body:{body:t}});if(!o.ok)throw await this.client.toError("create comment",o)}async listComments(e){let t=[],o=1;for(;;){let r=await this.client.request(this.config,`${this.repoPath()}/issues/${String(e.issueNumber)}/comments?per_page=${String(g)}&page=${String(o)}`,{method:"GET"});if(!r.ok)throw await this.client.toError("list comments",r);let s=await r.json();for(let n of s)typeof n.body=="string"&&t.push({body:n.body});if(s.length<g)break;o+=1}return t}async uploadAsset(e){let t=e.branch?.trim()||"feedback-assets";await this.assets.uploadFile({path:e.path,contentBase64:e.contentBase64,branch:t,message:e.message?.trim()||`chore(feedback): upload ${e.path}`});let o=e.path.split("/").filter(r=>r.length>0).map(r=>encodeURIComponent(r)).join("/");return{url:`https://github.com/${encodeURIComponent(this.config.owner)}/${encodeURIComponent(this.config.repo)}/raw/${encodeURIComponent(t)}/${o}`}}postIssue(e,t){return this.client.request(this.config,`${this.repoPath()}/issues`,{method:"POST",body:{title:e.title,body:e.body,...t.length>0?{labels:[...t]}:{}}})}async readCreated(e){let t=await e.json();if(typeof t.number!="number"||typeof t.html_url!="string")throw new a("create issue: unexpected response",e.status);return{issueNumber:t.number,issueUrl:t.html_url,...typeof t.node_id=="string"?{resourceKey:t.node_id}:{}}}repoPath(){return`/repos/${encodeURIComponent(this.config.owner)}/${encodeURIComponent(this.config.repo)}`}};import{createHmac as k,timingSafeEqual as F}from"crypto";var m="sha256=",h=class{constructor(e){this.secret=e}async verify(e,t){if(t==null||t.trim()==="")return{ok:!1,reason:"signature_header_missing"};if(!t.startsWith(m))return{ok:!1,reason:"signature_header_invalid"};let o=this.secret.trim();if(!o)return{ok:!1,reason:"secret_not_configured"};let r=Buffer.from(m+k("sha256",o).update(e,"utf8").digest("hex"),"utf8"),s=Buffer.from(t,"utf8");return r.length!==s.length||!F(r,s)?{ok:!1,reason:"digest_mismatch"}:{ok:!0}}};function K(i){return new c(i)}function V(i,e){return new u(i,e)}function B(i,e){return new p(i,e)}function H(i){return new h(i)}export{a,c as b,p as c,u as d,h as e,K as f,V as g,B as h,H as i};
|
|
4
|
+
//# sourceMappingURL=chunk-MQ7IDBIZ.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/errors/IssueForgeError.ts","../src/github/GithubAppClient.ts","../src/github/GithubAppRepoContentGateway.ts","../src/github/GithubAppIssueForgeGateway.ts","../src/github/GithubWebhookVerifier.ts","../src/github/createGithubAppForge.ts"],"sourcesContent":["/**\n * Forge API 调用失败(换票、建 Issue、上传等)。\n */\nexport class IssueForgeError extends Error {\n public readonly code = 'ISSUE_FORGE_FAILED' as const;\n /** HTTP 状态码;网络错误等无响应时为 null */\n public readonly status: number | null;\n\n constructor(message: string, status: number | null) {\n super(message);\n this.name = 'IssueForgeError';\n this.status = status;\n }\n}\n","import jwt from 'jsonwebtoken';\nimport { IssueForgeError } from '../errors/IssueForgeError';\nimport type {\n GithubAppAuthConfigType,\n IssueForgeTokenCacheInterface\n} from '../types/IssueForgeTypes';\n\nconst GITHUB_API = 'https://api.github.com';\nconst GITHUB_API_VERSION = '2022-11-28';\nconst DEFAULT_USER_AGENT = 'brain-toolkit-issue-forge';\n/** Contents 大图 PUT / 弱网下 10s 易超时;评论与普通 GET 也共用此上限 */\nconst REQUEST_TIMEOUT_MS = 60_000;\nconst APP_JWT_TTL_SEC = 9 * 60;\nconst APP_JWT_CLOCK_SKEW_SEC = 60;\nconst TOKEN_REFRESH_MARGIN_MS = 2 * 60 * 1000;\n\ntype CachedTokenType = {\n readonly token: string;\n};\n\nexport type GithubAppRequestType = {\n readonly method: 'GET' | 'POST' | 'PUT' | 'PATCH';\n readonly body?: unknown;\n readonly accept?: string;\n};\n\nexport type GithubAppClientOptionsType = {\n readonly cache: IssueForgeTokenCacheInterface;\n readonly userAgent?: string;\n};\n\n/**\n * 以 GitHub App installation 身份调用 REST API(低层;config 仍按次传入以便多仓复用同一 client)。\n */\nexport class GithubAppClient {\n protected readonly cache: IssueForgeTokenCacheInterface;\n protected readonly userAgent: string;\n\n constructor(options: GithubAppClientOptionsType) {\n this.cache = options.cache;\n this.userAgent = options.userAgent?.trim() || DEFAULT_USER_AGENT;\n }\n\n public async request(\n config: GithubAppAuthConfigType,\n path: string,\n init: GithubAppRequestType\n ): Promise<Response> {\n const token = await this.getInstallationToken(config);\n const headers: Record<string, string> = this.headers(`Bearer ${token}`);\n if (init.accept) {\n headers.Accept = init.accept;\n }\n if (init.body !== undefined) {\n headers['Content-Type'] = 'application/json';\n }\n const response = await this.send(`${GITHUB_API}${path}`, {\n method: init.method,\n headers,\n ...(init.body !== undefined ? { body: JSON.stringify(init.body) } : {})\n });\n if (response.status === 401 || response.status === 403) {\n await this.cache.removeItem(this.tokenCacheKey(config));\n }\n return response;\n }\n\n public async toError(\n stage: string,\n response: Response\n ): Promise<IssueForgeError> {\n let detail = '';\n try {\n const json = (await response.json()) as { readonly message?: unknown };\n detail = typeof json.message === 'string' ? json.message : '';\n } catch {\n detail = '';\n }\n return new IssueForgeError(\n `${stage}: HTTP ${String(response.status)}${detail ? ` ${detail}` : ''}`,\n response.status\n );\n }\n\n protected async getInstallationToken(\n config: GithubAppAuthConfigType\n ): Promise<string> {\n const cacheKey = this.tokenCacheKey(config);\n const cached = await this.cache.getItem<CachedTokenType>(cacheKey);\n if (cached?.token) {\n return cached.token;\n }\n\n const response = await this.send(\n `${GITHUB_API}/app/installations/${encodeURIComponent(config.installationId)}/access_tokens`,\n {\n method: 'POST',\n headers: this.headers(`Bearer ${this.signAppJwt(config)}`)\n }\n );\n if (!response.ok) {\n throw await this.toError('installation token', response);\n }\n const json = (await response.json()) as {\n readonly token?: unknown;\n readonly expires_at?: unknown;\n };\n if (typeof json.token !== 'string' || !json.token) {\n throw new IssueForgeError(\n 'installation token: empty token',\n response.status\n );\n }\n const expiresAtMs =\n typeof json.expires_at === 'string'\n ? Date.parse(json.expires_at)\n : Number.NaN;\n const ttlMs = Number.isFinite(expiresAtMs)\n ? expiresAtMs - Date.now() - TOKEN_REFRESH_MARGIN_MS\n : 0;\n if (ttlMs > 0) {\n await this.cache.setItem<CachedTokenType>(\n cacheKey,\n { token: json.token },\n { ttlMs }\n );\n }\n return json.token;\n }\n\n protected signAppJwt(config: GithubAppAuthConfigType): string {\n const nowSec = Math.floor(Date.now() / 1000);\n try {\n return jwt.sign(\n {\n iat: nowSec - APP_JWT_CLOCK_SKEW_SEC,\n exp: nowSec + APP_JWT_TTL_SEC,\n iss: config.appId\n },\n this.normalizePrivateKey(config.privateKey),\n { algorithm: 'RS256' }\n );\n } catch (error) {\n throw new IssueForgeError(\n `invalid GitHub App private key: ${error instanceof Error ? error.message : String(error)}`,\n null\n );\n }\n }\n\n protected normalizePrivateKey(raw: string): string {\n return raw.replace(/\\\\n/g, '\\n').replace(/\\r\\n/g, '\\n').trim();\n }\n\n protected async send(url: string, init: RequestInit): Promise<Response> {\n try {\n return await fetch(url, {\n ...init,\n signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS)\n });\n } catch (error) {\n throw new IssueForgeError(\n `GitHub request failed: ${error instanceof Error ? error.message : String(error)}`,\n null\n );\n }\n }\n\n protected headers(authorization: string): Record<string, string> {\n return {\n Accept: 'application/vnd.github+json',\n Authorization: authorization,\n 'User-Agent': this.userAgent,\n 'X-GitHub-Api-Version': GITHUB_API_VERSION\n };\n }\n\n protected tokenCacheKey(config: GithubAppAuthConfigType): string {\n return `issue-forge:github:installation-token:${config.appId}:${config.installationId}`;\n }\n}\n","import { IssueForgeError } from '../errors/IssueForgeError';\nimport type {\n IssueForgeRepoContentInterface,\n IssueForgeRepoFileType,\n IssueForgeRepoFileUploadedType,\n IssueForgeRepoFileUploadInputType\n} from '../interfaces/IssueForgeRepoContentInterface';\nimport type { GithubAppAuthConfigType } from '../types/IssueForgeTypes';\nimport type { GithubAppClient } from './GithubAppClient';\n\nconst ACCEPT_RAW = 'application/vnd.github.raw+json';\n\n/**\n * GitHub App 仓库内容网关(形态 B:构造时绑定 auth/config)。\n */\nexport class GithubAppRepoContentGateway\n implements IssueForgeRepoContentInterface\n{\n constructor(\n protected readonly client: GithubAppClient,\n protected readonly config: GithubAppAuthConfigType\n ) {}\n\n /**\n * @override\n */\n public async readTextFile(path: string): Promise<string | null> {\n const response = await this.client.request(\n this.config,\n this.contentsPath(path),\n { method: 'GET', accept: ACCEPT_RAW }\n );\n if (response.status === 404) {\n return null;\n }\n if (!response.ok) {\n throw await this.client.toError('read file', response);\n }\n return response.text();\n }\n\n /**\n * @override\n */\n public async hasFile(path: string, branch: string): Promise<boolean> {\n const response = await this.client.request(\n this.config,\n `${this.contentsPath(path)}?ref=${encodeURIComponent(branch)}`,\n { method: 'GET' }\n );\n if (response.status === 404) {\n return false;\n }\n if (!response.ok) {\n throw await this.client.toError('has file', response);\n }\n return true;\n }\n\n /**\n * @override\n */\n public async ensureBranch(\n branch: string,\n initialFile: IssueForgeRepoFileType\n ): Promise<void> {\n const found = await this.client.request(\n this.config,\n `${this.repoPath()}/git/ref/heads/${this.encodePath(branch)}`,\n { method: 'GET' }\n );\n if (found.ok) {\n return;\n }\n if (found.status !== 404) {\n throw await this.client.toError('get branch', found);\n }\n\n const treeSha = await this.postForSha('create tree', '/git/trees', {\n tree: [\n {\n path: initialFile.path,\n mode: '100644',\n type: 'blob',\n content: initialFile.content\n }\n ]\n });\n const commitSha = await this.postForSha('create commit', '/git/commits', {\n message: `chore: 初始化 ${branch} 分支`,\n tree: treeSha,\n parents: []\n });\n const created = await this.client.request(\n this.config,\n `${this.repoPath()}/git/refs`,\n {\n method: 'POST',\n body: { ref: `refs/heads/${branch}`, sha: commitSha }\n }\n );\n if (!created.ok && created.status !== 422) {\n throw await this.client.toError('create branch', created);\n }\n }\n\n /**\n * @override\n */\n public async uploadFile(\n input: IssueForgeRepoFileUploadInputType\n ): Promise<IssueForgeRepoFileUploadedType> {\n const response = await this.client.request(\n this.config,\n this.contentsPath(input.path),\n {\n method: 'PUT',\n body: {\n message: input.message,\n content: input.contentBase64,\n branch: input.branch\n }\n }\n );\n if (response.ok) {\n const json = (await response.json()) as {\n readonly content?: { readonly html_url?: unknown };\n };\n return { url: this.requireHtmlUrl(json.content?.html_url, response) };\n }\n if (response.status === 422) {\n return this.readExisting(input);\n }\n throw await this.client.toError('upload file', response);\n }\n\n protected async readExisting(\n input: IssueForgeRepoFileUploadInputType\n ): Promise<IssueForgeRepoFileUploadedType> {\n const response = await this.client.request(\n this.config,\n `${this.contentsPath(input.path)}?ref=${encodeURIComponent(input.branch)}`,\n { method: 'GET' }\n );\n if (!response.ok) {\n throw await this.client.toError('upload file', response);\n }\n const json = (await response.json()) as { readonly html_url?: unknown };\n return { url: this.requireHtmlUrl(json.html_url, response) };\n }\n\n protected async postForSha(\n stage: string,\n path: string,\n body: unknown\n ): Promise<string> {\n const response = await this.client.request(\n this.config,\n `${this.repoPath()}${path}`,\n { method: 'POST', body }\n );\n if (!response.ok) {\n throw await this.client.toError(stage, response);\n }\n const json = (await response.json()) as { readonly sha?: unknown };\n if (typeof json.sha !== 'string' || !json.sha) {\n throw new IssueForgeError(\n `${stage}: unexpected response`,\n response.status\n );\n }\n return json.sha;\n }\n\n protected requireHtmlUrl(value: unknown, response: Response): string {\n if (typeof value !== 'string' || !value) {\n throw new IssueForgeError(\n 'upload file: unexpected response',\n response.status\n );\n }\n return value;\n }\n\n protected contentsPath(path: string): string {\n return `${this.repoPath()}/contents/${this.encodePath(path)}`;\n }\n\n protected encodePath(path: string): string {\n return path\n .split('/')\n .filter((segment) => segment.length > 0)\n .map((segment) => encodeURIComponent(segment))\n .join('/');\n }\n\n protected repoPath(): string {\n return `/repos/${encodeURIComponent(this.config.owner)}/${encodeURIComponent(this.config.repo)}`;\n }\n}\n","import { IssueForgeError } from '../errors/IssueForgeError';\nimport type {\n ForgeIssueCommentType,\n IssueForgeGatewayInterface\n} from '../interfaces/IssueForgeGatewayInterface';\nimport type {\n ForgeAssetUploadedType,\n ForgeAssetUploadInputType,\n ForgeIssueCreatedType,\n ForgeIssueCreateInputType,\n ForgeIssueRefType,\n GithubAppAuthConfigType\n} from '../types/IssueForgeTypes';\nimport type { GithubAppClient } from './GithubAppClient';\nimport { GithubAppRepoContentGateway } from './GithubAppRepoContentGateway';\n\nconst COMMENTS_PAGE_SIZE = 100;\n\n/**\n * GitHub App Issue 网关(形态 B:构造时绑定 auth/config)。\n */\nexport class GithubAppIssueForgeGateway implements IssueForgeGatewayInterface {\n protected readonly assets: GithubAppRepoContentGateway;\n\n constructor(\n protected readonly client: GithubAppClient,\n protected readonly config: GithubAppAuthConfigType\n ) {\n this.assets = new GithubAppRepoContentGateway(client, config);\n }\n\n /**\n * @override\n */\n public async createIssue(\n input: ForgeIssueCreateInputType\n ): Promise<ForgeIssueCreatedType> {\n const first = await this.postIssue(input, input.labels);\n if (first.ok) {\n return this.readCreated(first);\n }\n if (first.status === 422 && input.labels.length > 0) {\n const retry = await this.postIssue(input, []);\n if (retry.ok) {\n return this.readCreated(retry);\n }\n throw await this.client.toError('create issue', retry);\n }\n throw await this.client.toError('create issue', first);\n }\n\n /**\n * @override\n */\n public async createComment(\n issue: ForgeIssueRefType,\n body: string\n ): Promise<void> {\n const response = await this.client.request(\n this.config,\n `${this.repoPath()}/issues/${String(issue.issueNumber)}/comments`,\n { method: 'POST', body: { body } }\n );\n if (!response.ok) {\n throw await this.client.toError('create comment', response);\n }\n }\n\n /**\n * @override\n */\n public async listComments(\n issue: ForgeIssueRefType\n ): Promise<readonly ForgeIssueCommentType[]> {\n const comments: ForgeIssueCommentType[] = [];\n let page = 1;\n for (;;) {\n const response = await this.client.request(\n this.config,\n `${this.repoPath()}/issues/${String(issue.issueNumber)}/comments?per_page=${String(COMMENTS_PAGE_SIZE)}&page=${String(page)}`,\n { method: 'GET' }\n );\n if (!response.ok) {\n throw await this.client.toError('list comments', response);\n }\n const json = (await response.json()) as ReadonlyArray<{\n readonly body?: unknown;\n }>;\n for (const item of json) {\n if (typeof item.body === 'string') {\n comments.push({ body: item.body });\n }\n }\n if (json.length < COMMENTS_PAGE_SIZE) {\n break;\n }\n page += 1;\n }\n return comments;\n }\n\n /**\n * @override\n */\n public async uploadAsset(\n input: ForgeAssetUploadInputType\n ): Promise<ForgeAssetUploadedType> {\n const branch = input.branch?.trim() || 'feedback-assets';\n await this.assets.uploadFile({\n path: input.path,\n contentBase64: input.contentBase64,\n branch,\n message: input.message?.trim() || `chore(feedback): upload ${input.path}`\n });\n const encodedPath = input.path\n .split('/')\n .filter((segment) => segment.length > 0)\n .map((segment) => encodeURIComponent(segment))\n .join('/');\n return {\n url: `https://github.com/${encodeURIComponent(this.config.owner)}/${encodeURIComponent(this.config.repo)}/raw/${encodeURIComponent(branch)}/${encodedPath}`\n };\n }\n\n protected postIssue(\n input: ForgeIssueCreateInputType,\n labels: readonly string[]\n ): Promise<Response> {\n return this.client.request(this.config, `${this.repoPath()}/issues`, {\n method: 'POST',\n body: {\n title: input.title,\n body: input.body,\n ...(labels.length > 0 ? { labels: [...labels] } : {})\n }\n });\n }\n\n protected async readCreated(\n response: Response\n ): Promise<ForgeIssueCreatedType> {\n const json = (await response.json()) as {\n readonly number?: unknown;\n readonly html_url?: unknown;\n readonly node_id?: unknown;\n };\n if (typeof json.number !== 'number' || typeof json.html_url !== 'string') {\n throw new IssueForgeError(\n 'create issue: unexpected response',\n response.status\n );\n }\n return {\n issueNumber: json.number,\n issueUrl: json.html_url,\n ...(typeof json.node_id === 'string'\n ? { resourceKey: json.node_id }\n : {})\n };\n }\n\n protected repoPath(): string {\n return `/repos/${encodeURIComponent(this.config.owner)}/${encodeURIComponent(this.config.repo)}`;\n }\n}\n","import { createHmac, timingSafeEqual } from 'crypto';\nimport type { IssueWebhookVerifierInterface } from '../interfaces/IssueWebhookVerifierInterface';\nimport type { IssueWebhookVerifyResultType } from '../types/IssueForgeTypes';\n\nconst SIGNATURE_PREFIX = 'sha256=';\n\n/**\n * GitHub Webhook HMAC-SHA256 验签(形态 B:构造时绑定 secret)。\n */\nexport class GithubWebhookVerifier implements IssueWebhookVerifierInterface {\n constructor(protected readonly secret: string) {}\n\n /**\n * @override\n */\n public async verify(\n rawBody: string,\n signatureHeader: string | null\n ): Promise<IssueWebhookVerifyResultType> {\n if (signatureHeader == null || signatureHeader.trim() === '') {\n return { ok: false, reason: 'signature_header_missing' };\n }\n if (!signatureHeader.startsWith(SIGNATURE_PREFIX)) {\n return { ok: false, reason: 'signature_header_invalid' };\n }\n const secret = this.secret.trim();\n if (!secret) {\n return { ok: false, reason: 'secret_not_configured' };\n }\n\n const expected = Buffer.from(\n SIGNATURE_PREFIX +\n createHmac('sha256', secret).update(rawBody, 'utf8').digest('hex'),\n 'utf8'\n );\n const received = Buffer.from(signatureHeader, 'utf8');\n if (\n expected.length !== received.length ||\n !timingSafeEqual(expected, received)\n ) {\n return { ok: false, reason: 'digest_mismatch' };\n }\n return { ok: true };\n }\n}\n","import type { IssueForgeGatewayInterface } from '../interfaces/IssueForgeGatewayInterface';\nimport type { IssueForgeRepoContentInterface } from '../interfaces/IssueForgeRepoContentInterface';\nimport type { IssueWebhookVerifierInterface } from '../interfaces/IssueWebhookVerifierInterface';\nimport type {\n GithubAppAuthConfigType,\n IssueForgeTokenCacheInterface\n} from '../types/IssueForgeTypes';\nimport { GithubAppClient } from './GithubAppClient';\nimport { GithubAppIssueForgeGateway } from './GithubAppIssueForgeGateway';\nimport { GithubAppRepoContentGateway } from './GithubAppRepoContentGateway';\nimport { GithubWebhookVerifier } from './GithubWebhookVerifier';\n\nexport type CreateGithubAppClientOptionsType = {\n readonly cache: IssueForgeTokenCacheInterface;\n readonly userAgent?: string;\n};\n\n/**\n * 创建可复用的 GitHub App HTTP 客户端(多仓可共用,按次传 config)。\n */\nexport function createGithubAppClient(\n options: CreateGithubAppClientOptionsType\n): GithubAppClient {\n return new GithubAppClient(options);\n}\n\n/**\n * 绑定 config 的 Issue 网关(形态 B)。\n */\nexport function createGithubAppIssueForge(\n client: GithubAppClient,\n config: GithubAppAuthConfigType\n): IssueForgeGatewayInterface {\n return new GithubAppIssueForgeGateway(client, config);\n}\n\n/**\n * 绑定 config 的仓库内容网关(形态 B)。\n */\nexport function createGithubAppRepoContent(\n client: GithubAppClient,\n config: GithubAppAuthConfigType\n): IssueForgeRepoContentInterface {\n return new GithubAppRepoContentGateway(client, config);\n}\n\n/**\n * 绑定 webhook secret 的验签器(形态 B)。\n */\nexport function createGithubWebhookVerifier(\n secret: string\n): IssueWebhookVerifierInterface {\n return new GithubWebhookVerifier(secret);\n}\n"],"mappings":";AAGO,IAAM,kBAAN,cAA8B,MAAM;AAAA,EACzB,OAAO;AAAA;AAAA,EAEP;AAAA,EAEhB,YAAY,SAAiB,QAAuB;AAClD,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,SAAS;AAAA,EAChB;AACF;;;ACbA,OAAO,SAAS;AAOhB,IAAM,aAAa;AACnB,IAAM,qBAAqB;AAC3B,IAAM,qBAAqB;AAE3B,IAAM,qBAAqB;AAC3B,IAAM,kBAAkB,IAAI;AAC5B,IAAM,yBAAyB;AAC/B,IAAM,0BAA0B,IAAI,KAAK;AAoBlC,IAAM,kBAAN,MAAsB;AAAA,EACR;AAAA,EACA;AAAA,EAEnB,YAAY,SAAqC;AAC/C,SAAK,QAAQ,QAAQ;AACrB,SAAK,YAAY,QAAQ,WAAW,KAAK,KAAK;AAAA,EAChD;AAAA,EAEA,MAAa,QACX,QACA,MACA,MACmB;AACnB,UAAM,QAAQ,MAAM,KAAK,qBAAqB,MAAM;AACpD,UAAM,UAAkC,KAAK,QAAQ,UAAU,KAAK,EAAE;AACtE,QAAI,KAAK,QAAQ;AACf,cAAQ,SAAS,KAAK;AAAA,IACxB;AACA,QAAI,KAAK,SAAS,QAAW;AAC3B,cAAQ,cAAc,IAAI;AAAA,IAC5B;AACA,UAAM,WAAW,MAAM,KAAK,KAAK,GAAG,UAAU,GAAG,IAAI,IAAI;AAAA,MACvD,QAAQ,KAAK;AAAA,MACb;AAAA,MACA,GAAI,KAAK,SAAS,SAAY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AACjD,aAAO,EAAE,IAAI,OAAO,QAAQ,2BAA2B;AAAA,IACzD;AACA,UAAM,SAAS,KAAK,OAAO,KAAK;AAChC,QAAI,CAAC,QAAQ;AACX,aAAO,EAAE,IAAI,OAAO,QAAQ,wBAAwB;AAAA,IACtD;AAEA,UAAM,WAAW,OAAO;AAAA,MACtB,mBACE,WAAW,UAAU,MAAM,EAAE,OAAO,SAAS,MAAM,EAAE,OAAO,KAAK;AAAA,MACnE;AAAA,IACF;AACA,UAAM,WAAW,OAAO,KAAK,iBAAiB,MAAM;AACpD,QACE,SAAS,WAAW,SAAS,UAC7B,CAAC,gBAAgB,UAAU,QAAQ,GACnC;AACA,aAAO,EAAE,IAAI,OAAO,QAAQ,kBAAkB;AAAA,IAChD;AACA,WAAO,EAAE,IAAI,KAAK;AAAA,EACpB;AACF;;;ACxBO,SAAS,sBACd,SACiB;AACjB,SAAO,IAAI,gBAAgB,OAAO;AACpC;AAKO,SAAS,0BACd,QACA,QAC4B;AAC5B,SAAO,IAAI,2BAA2B,QAAQ,MAAM;AACtD;AAKO,SAAS,2BACd,QACA,QACgC;AAChC,SAAO,IAAI,4BAA4B,QAAQ,MAAM;AACvD;AAKO,SAAS,4BACd,QAC+B;AAC/B,SAAO,IAAI,sBAAsB,MAAM;AACzC;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/errors/IssueForgeError.ts","../src/github/GithubAppClient.ts","../src/github/GithubAppRepoContentGateway.ts","../src/github/GithubAppIssueForgeGateway.ts","../src/github/GithubWebhookVerifier.ts","../src/github/createGithubAppForge.ts"],"sourcesContent":["/**\n * Forge API 调用失败(换票、建 Issue、上传等)。\n */\nexport class IssueForgeError extends Error {\n public readonly code = 'ISSUE_FORGE_FAILED' as const;\n /** HTTP 状态码;网络错误等无响应时为 null */\n public readonly status: number | null;\n\n constructor(message: string, status: number | null) {\n super(message);\n this.name = 'IssueForgeError';\n this.status = status;\n }\n}\n","import jwt from 'jsonwebtoken';\nimport { IssueForgeError } from '../errors/IssueForgeError';\nimport type {\n GithubAppAuthConfigType,\n IssueForgeTokenCacheInterface\n} from '../types/IssueForgeTypes';\n\nconst GITHUB_API = 'https://api.github.com';\nconst GITHUB_API_VERSION = '2022-11-28';\nconst DEFAULT_USER_AGENT = 'brain-toolkit-issue-forge';\n/** Contents 大图 PUT / 弱网下 10s 易超时;评论与普通 GET 也共用此上限 */\nconst REQUEST_TIMEOUT_MS = 60_000;\nconst APP_JWT_TTL_SEC = 9 * 60;\nconst APP_JWT_CLOCK_SKEW_SEC = 60;\nconst TOKEN_REFRESH_MARGIN_MS = 2 * 60 * 1000;\n\ntype CachedTokenType = {\n readonly token: string;\n};\n\nexport type GithubAppRequestType = {\n readonly method: 'GET' | 'POST' | 'PUT' | 'PATCH';\n readonly body?: unknown;\n readonly accept?: string;\n};\n\nexport type GithubAppClientOptionsType = {\n readonly cache: IssueForgeTokenCacheInterface;\n readonly userAgent?: string;\n};\n\n/**\n * 以 GitHub App installation 身份调用 REST API(低层;config 仍按次传入以便多仓复用同一 client)。\n */\nexport class GithubAppClient {\n protected readonly cache: IssueForgeTokenCacheInterface;\n protected readonly userAgent: string;\n\n constructor(options: GithubAppClientOptionsType) {\n this.cache = options.cache;\n this.userAgent = options.userAgent?.trim() || DEFAULT_USER_AGENT;\n }\n\n public async request(\n config: GithubAppAuthConfigType,\n path: string,\n init: GithubAppRequestType\n ): Promise<Response> {\n const token = await this.getInstallationToken(config);\n const headers: Record<string, string> = this.headers(`Bearer ${token}`);\n if (init.accept) {\n headers.Accept = init.accept;\n }\n if (init.body !== undefined) {\n headers['Content-Type'] = 'application/json';\n }\n const response = await this.send(`${GITHUB_API}${path}`, {\n method: init.method,\n headers,\n ...(init.body !== undefined ? { body: JSON.stringify(init.body) } : {})\n });\n if (response.status === 401 || response.status === 403) {\n await this.cache.removeItem(this.tokenCacheKey(config));\n }\n return response;\n }\n\n public async toError(\n stage: string,\n response: Response\n ): Promise<IssueForgeError> {\n let detail = '';\n try {\n const json = (await response.json()) as { readonly message?: unknown };\n detail = typeof json.message === 'string' ? json.message : '';\n } catch {\n detail = '';\n }\n return new IssueForgeError(\n `${stage}: HTTP ${String(response.status)}${detail ? ` ${detail}` : ''}`,\n response.status\n );\n }\n\n protected async getInstallationToken(\n config: GithubAppAuthConfigType\n ): Promise<string> {\n const cacheKey = this.tokenCacheKey(config);\n const cached = await this.cache.getItem<CachedTokenType>(cacheKey);\n if (cached?.token) {\n return cached.token;\n }\n\n const response = await this.send(\n `${GITHUB_API}/app/installations/${encodeURIComponent(config.installationId)}/access_tokens`,\n {\n method: 'POST',\n headers: this.headers(`Bearer ${this.signAppJwt(config)}`)\n }\n );\n if (!response.ok) {\n throw await this.toError('installation token', response);\n }\n const json = (await response.json()) as {\n readonly token?: unknown;\n readonly expires_at?: unknown;\n };\n if (typeof json.token !== 'string' || !json.token) {\n throw new IssueForgeError(\n 'installation token: empty token',\n response.status\n );\n }\n const expiresAtMs =\n typeof json.expires_at === 'string'\n ? Date.parse(json.expires_at)\n : Number.NaN;\n const ttlMs = Number.isFinite(expiresAtMs)\n ? expiresAtMs - Date.now() - TOKEN_REFRESH_MARGIN_MS\n : 0;\n if (ttlMs > 0) {\n await this.cache.setItem<CachedTokenType>(\n cacheKey,\n { token: json.token },\n { ttlMs }\n );\n }\n return json.token;\n }\n\n protected signAppJwt(config: GithubAppAuthConfigType): string {\n const nowSec = Math.floor(Date.now() / 1000);\n try {\n return jwt.sign(\n {\n iat: nowSec - APP_JWT_CLOCK_SKEW_SEC,\n exp: nowSec + APP_JWT_TTL_SEC,\n iss: config.appId\n },\n this.normalizePrivateKey(config.privateKey),\n { algorithm: 'RS256' }\n );\n } catch (error) {\n throw new IssueForgeError(\n `invalid GitHub App private key: ${error instanceof Error ? error.message : String(error)}`,\n null\n );\n }\n }\n\n protected normalizePrivateKey(raw: string): string {\n return raw.replace(/\\\\n/g, '\\n').replace(/\\r\\n/g, '\\n').trim();\n }\n\n protected async send(url: string, init: RequestInit): Promise<Response> {\n try {\n return await fetch(url, {\n ...init,\n signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS)\n });\n } catch (error) {\n throw new IssueForgeError(\n `GitHub request failed: ${error instanceof Error ? error.message : String(error)}`,\n null\n );\n }\n }\n\n protected headers(authorization: string): Record<string, string> {\n return {\n Accept: 'application/vnd.github+json',\n Authorization: authorization,\n 'User-Agent': this.userAgent,\n 'X-GitHub-Api-Version': GITHUB_API_VERSION\n };\n }\n\n protected tokenCacheKey(config: GithubAppAuthConfigType): string {\n return `issue-forge:github:installation-token:${config.appId}:${config.installationId}`;\n }\n}\n","import { IssueForgeError } from '../errors/IssueForgeError';\nimport type {\n IssueForgeRepoContentInterface,\n IssueForgeRepoFileType,\n IssueForgeRepoFileUploadedType,\n IssueForgeRepoFileUploadInputType\n} from '../interfaces/IssueForgeRepoContentInterface';\nimport type { GithubAppAuthConfigType } from '../types/IssueForgeTypes';\nimport type { GithubAppClient } from './GithubAppClient';\n\nconst ACCEPT_RAW = 'application/vnd.github.raw+json';\n\n/**\n * GitHub App 仓库内容网关(形态 B:构造时绑定 auth/config)。\n */\nexport class GithubAppRepoContentGateway\n implements IssueForgeRepoContentInterface\n{\n constructor(\n protected readonly client: GithubAppClient,\n protected readonly config: GithubAppAuthConfigType\n ) {}\n\n /**\n * @override\n */\n public async readTextFile(path: string): Promise<string | null> {\n const response = await this.client.request(\n this.config,\n this.contentsPath(path),\n { method: 'GET', accept: ACCEPT_RAW }\n );\n if (response.status === 404) {\n return null;\n }\n if (!response.ok) {\n throw await this.client.toError('read file', response);\n }\n return response.text();\n }\n\n /**\n * @override\n */\n public async hasFile(path: string, branch: string): Promise<boolean> {\n const response = await this.client.request(\n this.config,\n `${this.contentsPath(path)}?ref=${encodeURIComponent(branch)}`,\n { method: 'GET' }\n );\n if (response.status === 404) {\n return false;\n }\n if (!response.ok) {\n throw await this.client.toError('has file', response);\n }\n return true;\n }\n\n /**\n * @override\n */\n public async ensureBranch(\n branch: string,\n initialFile: IssueForgeRepoFileType\n ): Promise<void> {\n const found = await this.client.request(\n this.config,\n `${this.repoPath()}/git/ref/heads/${this.encodePath(branch)}`,\n { method: 'GET' }\n );\n if (found.ok) {\n return;\n }\n if (found.status !== 404) {\n throw await this.client.toError('get branch', found);\n }\n\n const treeSha = await this.postForSha('create tree', '/git/trees', {\n tree: [\n {\n path: initialFile.path,\n mode: '100644',\n type: 'blob',\n content: initialFile.content\n }\n ]\n });\n const commitSha = await this.postForSha('create commit', '/git/commits', {\n message: `chore: 初始化 ${branch} 分支`,\n tree: treeSha,\n parents: []\n });\n const created = await this.client.request(\n this.config,\n `${this.repoPath()}/git/refs`,\n {\n method: 'POST',\n body: { ref: `refs/heads/${branch}`, sha: commitSha }\n }\n );\n if (!created.ok && created.status !== 422) {\n throw await this.client.toError('create branch', created);\n }\n }\n\n /**\n * @override\n */\n public async uploadFile(\n input: IssueForgeRepoFileUploadInputType\n ): Promise<IssueForgeRepoFileUploadedType> {\n const response = await this.client.request(\n this.config,\n this.contentsPath(input.path),\n {\n method: 'PUT',\n body: {\n message: input.message,\n content: input.contentBase64,\n branch: input.branch\n }\n }\n );\n if (response.ok) {\n const json = (await response.json()) as {\n readonly content?: { readonly html_url?: unknown };\n };\n return { url: this.requireHtmlUrl(json.content?.html_url, response) };\n }\n if (response.status === 422) {\n return this.readExisting(input);\n }\n throw await this.client.toError('upload file', response);\n }\n\n protected async readExisting(\n input: IssueForgeRepoFileUploadInputType\n ): Promise<IssueForgeRepoFileUploadedType> {\n const response = await this.client.request(\n this.config,\n `${this.contentsPath(input.path)}?ref=${encodeURIComponent(input.branch)}`,\n { method: 'GET' }\n );\n if (!response.ok) {\n throw await this.client.toError('upload file', response);\n }\n const json = (await response.json()) as { readonly html_url?: unknown };\n return { url: this.requireHtmlUrl(json.html_url, response) };\n }\n\n protected async postForSha(\n stage: string,\n path: string,\n body: unknown\n ): Promise<string> {\n const response = await this.client.request(\n this.config,\n `${this.repoPath()}${path}`,\n { method: 'POST', body }\n );\n if (!response.ok) {\n throw await this.client.toError(stage, response);\n }\n const json = (await response.json()) as { readonly sha?: unknown };\n if (typeof json.sha !== 'string' || !json.sha) {\n throw new IssueForgeError(\n `${stage}: unexpected response`,\n response.status\n );\n }\n return json.sha;\n }\n\n protected requireHtmlUrl(value: unknown, response: Response): string {\n if (typeof value !== 'string' || !value) {\n throw new IssueForgeError(\n 'upload file: unexpected response',\n response.status\n );\n }\n return value;\n }\n\n protected contentsPath(path: string): string {\n return `${this.repoPath()}/contents/${this.encodePath(path)}`;\n }\n\n protected encodePath(path: string): string {\n return path\n .split('/')\n .filter((segment) => segment.length > 0)\n .map((segment) => encodeURIComponent(segment))\n .join('/');\n }\n\n protected repoPath(): string {\n return `/repos/${encodeURIComponent(this.config.owner)}/${encodeURIComponent(this.config.repo)}`;\n }\n}\n","import { IssueForgeError } from '../errors/IssueForgeError';\nimport type {\n ForgeIssueCommentType,\n IssueForgeGatewayInterface\n} from '../interfaces/IssueForgeGatewayInterface';\nimport type {\n ForgeAssetUploadedType,\n ForgeAssetUploadInputType,\n ForgeIssueCreatedType,\n ForgeIssueCreateInputType,\n ForgeIssueRefType,\n GithubAppAuthConfigType\n} from '../types/IssueForgeTypes';\nimport type { GithubAppClient } from './GithubAppClient';\nimport { GithubAppRepoContentGateway } from './GithubAppRepoContentGateway';\n\nconst COMMENTS_PAGE_SIZE = 100;\n\n/**\n * GitHub App Issue 网关(形态 B:构造时绑定 auth/config)。\n */\nexport class GithubAppIssueForgeGateway implements IssueForgeGatewayInterface {\n protected readonly assets: GithubAppRepoContentGateway;\n\n constructor(\n protected readonly client: GithubAppClient,\n protected readonly config: GithubAppAuthConfigType\n ) {\n this.assets = new GithubAppRepoContentGateway(client, config);\n }\n\n /**\n * @override\n */\n public async createIssue(\n input: ForgeIssueCreateInputType\n ): Promise<ForgeIssueCreatedType> {\n const first = await this.postIssue(input, input.labels);\n if (first.ok) {\n return this.readCreated(first);\n }\n if (first.status === 422 && input.labels.length > 0) {\n const retry = await this.postIssue(input, []);\n if (retry.ok) {\n return this.readCreated(retry);\n }\n throw await this.client.toError('create issue', retry);\n }\n throw await this.client.toError('create issue', first);\n }\n\n /**\n * @override\n */\n public async createComment(\n issue: ForgeIssueRefType,\n body: string\n ): Promise<void> {\n const response = await this.client.request(\n this.config,\n `${this.repoPath()}/issues/${String(issue.issueNumber)}/comments`,\n { method: 'POST', body: { body } }\n );\n if (!response.ok) {\n throw await this.client.toError('create comment', response);\n }\n }\n\n /**\n * @override\n */\n public async listComments(\n issue: ForgeIssueRefType\n ): Promise<readonly ForgeIssueCommentType[]> {\n const comments: ForgeIssueCommentType[] = [];\n let page = 1;\n for (;;) {\n const response = await this.client.request(\n this.config,\n `${this.repoPath()}/issues/${String(issue.issueNumber)}/comments?per_page=${String(COMMENTS_PAGE_SIZE)}&page=${String(page)}`,\n { method: 'GET' }\n );\n if (!response.ok) {\n throw await this.client.toError('list comments', response);\n }\n const json = (await response.json()) as ReadonlyArray<{\n readonly body?: unknown;\n }>;\n for (const item of json) {\n if (typeof item.body === 'string') {\n comments.push({ body: item.body });\n }\n }\n if (json.length < COMMENTS_PAGE_SIZE) {\n break;\n }\n page += 1;\n }\n return comments;\n }\n\n /**\n * @override\n */\n public async uploadAsset(\n input: ForgeAssetUploadInputType\n ): Promise<ForgeAssetUploadedType> {\n const branch = input.branch?.trim() || 'feedback-assets';\n await this.assets.uploadFile({\n path: input.path,\n contentBase64: input.contentBase64,\n branch,\n message: input.message?.trim() || `chore(feedback): upload ${input.path}`\n });\n const encodedPath = input.path\n .split('/')\n .filter((segment) => segment.length > 0)\n .map((segment) => encodeURIComponent(segment))\n .join('/');\n return {\n url: `https://github.com/${encodeURIComponent(this.config.owner)}/${encodeURIComponent(this.config.repo)}/raw/${encodeURIComponent(branch)}/${encodedPath}`\n };\n }\n\n protected postIssue(\n input: ForgeIssueCreateInputType,\n labels: readonly string[]\n ): Promise<Response> {\n return this.client.request(this.config, `${this.repoPath()}/issues`, {\n method: 'POST',\n body: {\n title: input.title,\n body: input.body,\n ...(labels.length > 0 ? { labels: [...labels] } : {})\n }\n });\n }\n\n protected async readCreated(\n response: Response\n ): Promise<ForgeIssueCreatedType> {\n const json = (await response.json()) as {\n readonly number?: unknown;\n readonly html_url?: unknown;\n readonly node_id?: unknown;\n };\n if (typeof json.number !== 'number' || typeof json.html_url !== 'string') {\n throw new IssueForgeError(\n 'create issue: unexpected response',\n response.status\n );\n }\n return {\n issueNumber: json.number,\n issueUrl: json.html_url,\n ...(typeof json.node_id === 'string'\n ? { resourceKey: json.node_id }\n : {})\n };\n }\n\n protected repoPath(): string {\n return `/repos/${encodeURIComponent(this.config.owner)}/${encodeURIComponent(this.config.repo)}`;\n }\n}\n","import { createHmac, timingSafeEqual } from 'crypto';\nimport type { IssueWebhookVerifierInterface } from '../interfaces/IssueWebhookVerifierInterface';\nimport type { IssueWebhookVerifyResultType } from '../types/IssueForgeTypes';\n\nconst SIGNATURE_PREFIX = 'sha256=';\n\n/**\n * GitHub Webhook HMAC-SHA256 验签(形态 B:构造时绑定 secret)。\n */\nexport class GithubWebhookVerifier implements IssueWebhookVerifierInterface {\n constructor(protected readonly secret: string) {}\n\n /**\n * @override\n */\n public async verify(\n rawBody: string,\n signatureHeader: string | null\n ): Promise<IssueWebhookVerifyResultType> {\n if (signatureHeader == null || signatureHeader.trim() === '') {\n return { ok: false, reason: 'signature_header_missing' };\n }\n if (!signatureHeader.startsWith(SIGNATURE_PREFIX)) {\n return { ok: false, reason: 'signature_header_invalid' };\n }\n const secret = this.secret.trim();\n if (!secret) {\n return { ok: false, reason: 'secret_not_configured' };\n }\n\n const expected = Buffer.from(\n SIGNATURE_PREFIX +\n createHmac('sha256', secret).update(rawBody, 'utf8').digest('hex'),\n 'utf8'\n );\n const received = Buffer.from(signatureHeader, 'utf8');\n if (\n expected.length !== received.length ||\n !timingSafeEqual(expected, received)\n ) {\n return { ok: false, reason: 'digest_mismatch' };\n }\n return { ok: true };\n }\n}\n","import type { IssueForgeGatewayInterface } from '../interfaces/IssueForgeGatewayInterface';\nimport type { IssueForgeRepoContentInterface } from '../interfaces/IssueForgeRepoContentInterface';\nimport type { IssueWebhookVerifierInterface } from '../interfaces/IssueWebhookVerifierInterface';\nimport type {\n GithubAppAuthConfigType,\n IssueForgeTokenCacheInterface\n} from '../types/IssueForgeTypes';\nimport { GithubAppClient } from './GithubAppClient';\nimport { GithubAppIssueForgeGateway } from './GithubAppIssueForgeGateway';\nimport { GithubAppRepoContentGateway } from './GithubAppRepoContentGateway';\nimport { GithubWebhookVerifier } from './GithubWebhookVerifier';\n\nexport type CreateGithubAppClientOptionsType = {\n readonly cache: IssueForgeTokenCacheInterface;\n readonly userAgent?: string;\n};\n\n/**\n * 创建可复用的 GitHub App HTTP 客户端(多仓可共用,按次传 config)。\n */\nexport function createGithubAppClient(\n options: CreateGithubAppClientOptionsType\n): GithubAppClient {\n return new GithubAppClient(options);\n}\n\n/**\n * 绑定 config 的 Issue 网关(形态 B)。\n */\nexport function createGithubAppIssueForge(\n client: GithubAppClient,\n config: GithubAppAuthConfigType\n): IssueForgeGatewayInterface {\n return new GithubAppIssueForgeGateway(client, config);\n}\n\n/**\n * 绑定 config 的仓库内容网关(形态 B)。\n */\nexport function createGithubAppRepoContent(\n client: GithubAppClient,\n config: GithubAppAuthConfigType\n): IssueForgeRepoContentInterface {\n return new GithubAppRepoContentGateway(client, config);\n}\n\n/**\n * 绑定 webhook secret 的验签器(形态 B)。\n */\nexport function createGithubWebhookVerifier(\n secret: string\n): IssueWebhookVerifierInterface {\n return new GithubWebhookVerifier(secret);\n}\n"],"mappings":"AAGO,IAAMA,EAAN,cAA8B,KAAM,CACzB,KAAO,qBAEP,OAEhB,YAAYC,EAAiBC,EAAuB,CAClD,MAAMD,CAAO,EACb,KAAK,KAAO,kBACZ,KAAK,OAASC,CAChB,CACF,ECbA,OAAOC,MAAS,eAOhB,IAAMC,EAAa,yBACbC,EAAqB,aACrBC,EAAqB,4BAErBC,EAAqB,IACrBC,EAAkB,IAClBC,EAAyB,GACzBC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SAI5C,IAAMC,EAAmB,UAKZC,EAAN,KAAqE,CAC1E,YAA+BC,EAAgB,CAAhB,YAAAA,CAAiB,CAKhD,MAAa,OACXC,EACAC,EACuC,CACvC,GAAIA,GAAmB,MAAQA,EAAgB,KAAK,IAAM,GACxD,MAAO,CAAE,GAAI,GAAO,OAAQ,0BAA2B,EAEzD,GAAI,CAACA,EAAgB,WAAWJ,CAAgB,EAC9C,MAAO,CAAE,GAAI,GAAO,OAAQ,0BAA2B,EAEzD,IAAME,EAAS,KAAK,OAAO,KAAK,EAChC,GAAI,CAACA,EACH,MAAO,CAAE,GAAI,GAAO,OAAQ,uBAAwB,EAGtD,IAAMG,EAAW,OAAO,KACtBL,EACEF,EAAW,SAAUI,CAAM,EAAE,OAAOC,EAAS,MAAM,EAAE,OAAO,KAAK,EACnE,MACF,EACMG,EAAW,OAAO,KAAKF,EAAiB,MAAM,EACpD,OACEC,EAAS,SAAWC,EAAS,QAC7B,CAACP,EAAgBM,EAAUC,CAAQ,EAE5B,CAAE,GAAI,GAAO,OAAQ,iBAAkB,EAEzC,CAAE,GAAI,EAAK,CACpB,CACF,ECxBO,SAASC,EACdC,EACiB,CACjB,OAAO,IAAIC,EAAgBD,CAAO,CACpC,CAKO,SAASE,EACdC,EACAC,EAC4B,CAC5B,OAAO,IAAIC,EAA2BF,EAAQC,CAAM,CACtD,CAKO,SAASE,EACdH,EACAC,EACgC,CAChC,OAAO,IAAIG,EAA4BJ,EAAQC,CAAM,CACvD,CAKO,SAASI,EACdC,EAC+B,CAC/B,OAAO,IAAIC,EAAsBD,CAAM,CACzC","names":["IssueForgeError","message","status","jwt","GITHUB_API","GITHUB_API_VERSION","DEFAULT_USER_AGENT","REQUEST_TIMEOUT_MS","APP_JWT_TTL_SEC","APP_JWT_CLOCK_SKEW_SEC","TOKEN_REFRESH_MARGIN_MS","GithubAppClient","options","config","path","init","token","headers","response","stage","detail","json","IssueForgeError","cacheKey","cached","expiresAtMs","ttlMs","nowSec","jwt","error","raw","url","authorization","ACCEPT_RAW","GithubAppRepoContentGateway","client","config","path","response","branch","initialFile","found","treeSha","commitSha","created","input","json","stage","body","IssueForgeError","value","segment","COMMENTS_PAGE_SIZE","GithubAppIssueForgeGateway","client","config","GithubAppRepoContentGateway","input","first","retry","issue","body","response","comments","page","json","item","branch","encodedPath","segment","labels","IssueForgeError","createHmac","timingSafeEqual","SIGNATURE_PREFIX","GithubWebhookVerifier","secret","rawBody","signatureHeader","expected","received","createGithubAppClient","options","GithubAppClient","createGithubAppIssueForge","client","config","GithubAppIssueForgeGateway","createGithubAppRepoContent","GithubAppRepoContentGateway","createGithubWebhookVerifier","secret","GithubWebhookVerifier"]}
|