@morehao/dsh-github-trending 0.8.0 → 0.8.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/README.md +10 -0
- package/lib/{chunk-6PVBPJXO.js → chunk-LLTW4YHJ.js} +15 -4
- package/lib/index.js +1 -1
- package/lib/internal.d.ts +14 -1
- package/lib/internal.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -55,6 +55,16 @@ GitHub 趋势榜的 **DeepSeek Harness 插件**:按日 / 周 / 月周期定时
|
|
|
55
55
|
|
|
56
56
|

|
|
57
57
|
|
|
58
|
+
### GitHub 认证
|
|
59
|
+
|
|
60
|
+
认证分区支持三种方式(可随时切换):
|
|
61
|
+
|
|
62
|
+
- **浏览器登录(默认推荐)**:点「用 GitHub 登录」在浏览器完成授权,无需手工粘贴 token。走 OAuth PKCE + 本机回环回调(或设备码),token 由 DSH 凭据记录安全保存,不落 `settings.json`。插件内置了公开的 OAuth App client_id(client_id 属公开标识、非机密;纯 PKCE 不使用 client_secret),开箱即用。
|
|
63
|
+
- **本机 gh**:复用你终端里 `gh auth login` 的登录态。
|
|
64
|
+
- **PAT**:手工填 Personal Access Token(存到凭据引用 / 环境变量)。
|
|
65
|
+
|
|
66
|
+
> 浏览器登录需要核心提供 `authorization` 服务;若当前核心版本不含该能力,「浏览器登录」会提示不可用并引导改用 gh / PAT。
|
|
67
|
+
|
|
58
68
|
### 订阅
|
|
59
69
|
|
|
60
70
|
(可选)订阅一组仓库,每周把每个仓库当周新增的 Release 合成一段中文摘要,与榜单同分支、同 PR 一起提交;订阅列表随数据仓版本化,可审计、可复现。
|
|
@@ -3530,6 +3530,7 @@ async function probeGithubAuth(options) {
|
|
|
3530
3530
|
var github_auth_exports = {};
|
|
3531
3531
|
__export(github_auth_exports, {
|
|
3532
3532
|
CALLBACK_PATH: () => CALLBACK_PATH,
|
|
3533
|
+
DEFAULT_GITHUB_CLIENT_ID: () => DEFAULT_GITHUB_CLIENT_ID,
|
|
3533
3534
|
DEFAULT_SCOPE: () => DEFAULT_SCOPE,
|
|
3534
3535
|
GITHUB_RECORD_KEY: () => GITHUB_RECORD_KEY2,
|
|
3535
3536
|
attemptView: () => attemptView,
|
|
@@ -3539,11 +3540,17 @@ __export(github_auth_exports, {
|
|
|
3539
3540
|
createPkce: () => createPkce,
|
|
3540
3541
|
registerGithubFlow: () => registerGithubFlow,
|
|
3541
3542
|
resetAttemptForTest: () => resetAttemptForTest,
|
|
3543
|
+
resolveClientId: () => resolveClientId,
|
|
3542
3544
|
verifyState: () => verifyState
|
|
3543
3545
|
});
|
|
3544
3546
|
import { createHash as createHash3, randomBytes as randomBytes2, timingSafeEqual as timingSafeEqual2 } from "crypto";
|
|
3545
3547
|
var GITHUB_RECORD_KEY2 = "github/default";
|
|
3546
3548
|
var CALLBACK_PATH = "/api/morehao/github-trending/oauth/github/callback";
|
|
3549
|
+
var DEFAULT_GITHUB_CLIENT_ID = "Ov23li7rhp0EKoqbkJKY";
|
|
3550
|
+
function resolveClientId(deps) {
|
|
3551
|
+
const fromConfig = deps.clientId;
|
|
3552
|
+
return fromConfig !== void 0 && fromConfig !== "" ? fromConfig : DEFAULT_GITHUB_CLIENT_ID;
|
|
3553
|
+
}
|
|
3547
3554
|
var AUTHORIZE_URL = "https://github.com/login/oauth/authorize";
|
|
3548
3555
|
var ACCESS_TOKEN_URL = "https://github.com/login/oauth/access_token";
|
|
3549
3556
|
var DEVICE_CODE_URL = "https://github.com/login/device/code";
|
|
@@ -3620,7 +3627,7 @@ async function runBrowser(deps, session) {
|
|
|
3620
3627
|
if (webServer === void 0 || typeof webServer.register !== "function") {
|
|
3621
3628
|
throw new Error("webServer \u670D\u52A1\u4E0D\u53EF\u7528\uFF1A\u6D4F\u89C8\u5668\u767B\u5F55\u9700\u8981\u5B83\u627F\u8F7D OAuth \u56DE\u8C03");
|
|
3622
3629
|
}
|
|
3623
|
-
const clientId = deps
|
|
3630
|
+
const clientId = resolveClientId(deps);
|
|
3624
3631
|
if (clientId === void 0 || clientId === "") throw new Error("\u7F3A\u5C11 GitHub OAuth client_id");
|
|
3625
3632
|
const fetchImpl = deps.fetchImpl ?? fetch;
|
|
3626
3633
|
const endpoints = normalizeEndpoints(deps.endpoints);
|
|
@@ -3688,7 +3695,7 @@ async function runBrowser(deps, session) {
|
|
|
3688
3695
|
}
|
|
3689
3696
|
}
|
|
3690
3697
|
async function runDevice(deps, session) {
|
|
3691
|
-
const clientId = deps
|
|
3698
|
+
const clientId = resolveClientId(deps);
|
|
3692
3699
|
if (clientId === void 0 || clientId === "") throw new Error("\u7F3A\u5C11 GitHub OAuth client_id");
|
|
3693
3700
|
const fetchImpl = deps.fetchImpl ?? fetch;
|
|
3694
3701
|
const endpoints = normalizeEndpoints(deps.endpoints);
|
|
@@ -4381,6 +4388,10 @@ import { PluginUpdateError } from "@morehao/dsh-plugin-kit/update";
|
|
|
4381
4388
|
var ROUTE_PREFIX = "/api/morehao/github-trending";
|
|
4382
4389
|
var HEADER = "x-dsh-github-trending";
|
|
4383
4390
|
var MAX_BODY2 = 512 * 1024;
|
|
4391
|
+
function isAuthorizationAvailable(get) {
|
|
4392
|
+
const authorization = get("authorization");
|
|
4393
|
+
return authorization !== void 0 && typeof authorization.begin === "function";
|
|
4394
|
+
}
|
|
4384
4395
|
function githubAuthDeps(deps) {
|
|
4385
4396
|
return {
|
|
4386
4397
|
get: deps.get,
|
|
@@ -4722,8 +4733,8 @@ async function statePayload(deps, settings) {
|
|
|
4722
4733
|
source: github.source,
|
|
4723
4734
|
/** 浏览器登录 attempt 视图(idle / waiting-browser / waiting-device / exchanging / done / error)。 */
|
|
4724
4735
|
attempt: attemptView(),
|
|
4725
|
-
/**
|
|
4726
|
-
browserAvailable: deps.
|
|
4736
|
+
/** 浏览器登录是否可用:核心提供了 authorization 服务即可(client_id 有内置默认)。 */
|
|
4737
|
+
browserAvailable: isAuthorizationAvailable(deps.get)
|
|
4727
4738
|
}
|
|
4728
4739
|
};
|
|
4729
4740
|
}
|
package/lib/index.js
CHANGED
package/lib/internal.d.ts
CHANGED
|
@@ -1161,6 +1161,17 @@ declare namespace github {
|
|
|
1161
1161
|
declare const GITHUB_RECORD_KEY = "github/default";
|
|
1162
1162
|
/** 本地回调路径(带集成前缀,避免多 provider 撞 webServer 的 `(kind,path)` 唯一约束)。 */
|
|
1163
1163
|
declare const CALLBACK_PATH = "/api/morehao/github-trending/oauth/github/callback";
|
|
1164
|
+
/**
|
|
1165
|
+
* 内置的 GitHub OAuth App 公开 client_id(**非机密**:OAuth 的 client_id 设计上就是公开的,
|
|
1166
|
+
* 会出现在授权 URL 里,与 `gh`/VS Code 内置自己的 client_id 同理)。
|
|
1167
|
+
* 纯 PKCE public client,无需 client_secret。用户/部署可在 `apply(config.githubClientId)` 覆盖。
|
|
1168
|
+
*
|
|
1169
|
+
* OAuth App 侧登记的回调:`http://127.0.0.1/api/morehao/github-trending/oauth/github/callback`
|
|
1170
|
+
* (loopback 按 RFC 8252 忽略端口,运行时随机端口可正常回跳)。
|
|
1171
|
+
*/
|
|
1172
|
+
declare const DEFAULT_GITHUB_CLIENT_ID = "Ov23li7rhp0EKoqbkJKY";
|
|
1173
|
+
/** 解析生效的 client_id:显式 config 优先,否则用内置默认。 */
|
|
1174
|
+
declare function resolveClientId(deps: GithubAuthDeps): string | undefined;
|
|
1164
1175
|
/** 本插件运行需要 push / 建 PR,`read:user` 不够;一次授权到 `repo`。 */
|
|
1165
1176
|
declare const DEFAULT_SCOPE = "repo";
|
|
1166
1177
|
interface AuthorizationFlow {
|
|
@@ -1272,6 +1283,7 @@ type githubAuth_AuthorizationFlow = AuthorizationFlow;
|
|
|
1272
1283
|
type githubAuth_AuthorizationLike = AuthorizationLike;
|
|
1273
1284
|
type githubAuth_AuthorizationSessionLike = AuthorizationSessionLike;
|
|
1274
1285
|
declare const githubAuth_CALLBACK_PATH: typeof CALLBACK_PATH;
|
|
1286
|
+
declare const githubAuth_DEFAULT_GITHUB_CLIENT_ID: typeof DEFAULT_GITHUB_CLIENT_ID;
|
|
1275
1287
|
declare const githubAuth_DEFAULT_SCOPE: typeof DEFAULT_SCOPE;
|
|
1276
1288
|
declare const githubAuth_GITHUB_RECORD_KEY: typeof GITHUB_RECORD_KEY;
|
|
1277
1289
|
type githubAuth_GithubAttemptPhase = GithubAttemptPhase;
|
|
@@ -1286,9 +1298,10 @@ declare const githubAuth_cancelGithubSignIn: typeof cancelGithubSignIn;
|
|
|
1286
1298
|
declare const githubAuth_createPkce: typeof createPkce;
|
|
1287
1299
|
declare const githubAuth_registerGithubFlow: typeof registerGithubFlow;
|
|
1288
1300
|
declare const githubAuth_resetAttemptForTest: typeof resetAttemptForTest;
|
|
1301
|
+
declare const githubAuth_resolveClientId: typeof resolveClientId;
|
|
1289
1302
|
declare const githubAuth_verifyState: typeof verifyState;
|
|
1290
1303
|
declare namespace githubAuth {
|
|
1291
|
-
export { type githubAuth_AuthorizationFlow as AuthorizationFlow, type githubAuth_AuthorizationLike as AuthorizationLike, type githubAuth_AuthorizationSessionLike as AuthorizationSessionLike, githubAuth_CALLBACK_PATH as CALLBACK_PATH, githubAuth_DEFAULT_SCOPE as DEFAULT_SCOPE, githubAuth_GITHUB_RECORD_KEY as GITHUB_RECORD_KEY, type githubAuth_GithubAttemptPhase as GithubAttemptPhase, type githubAuth_GithubAttemptView as GithubAttemptView, type githubAuth_GithubAuthDeps as GithubAuthDeps, type githubAuth_GithubGrantPayload as GithubGrantPayload, type githubAuth_WebServerLike as WebServerLike, githubAuth_attemptView as attemptView, githubAuth_beginGithubSignIn as beginGithubSignIn, githubAuth_buildAuthorizeUrl as buildAuthorizeUrl, githubAuth_cancelGithubSignIn as cancelGithubSignIn, githubAuth_createPkce as createPkce, githubAuth_registerGithubFlow as registerGithubFlow, githubAuth_resetAttemptForTest as resetAttemptForTest, githubAuth_verifyState as verifyState };
|
|
1304
|
+
export { type githubAuth_AuthorizationFlow as AuthorizationFlow, type githubAuth_AuthorizationLike as AuthorizationLike, type githubAuth_AuthorizationSessionLike as AuthorizationSessionLike, githubAuth_CALLBACK_PATH as CALLBACK_PATH, githubAuth_DEFAULT_GITHUB_CLIENT_ID as DEFAULT_GITHUB_CLIENT_ID, githubAuth_DEFAULT_SCOPE as DEFAULT_SCOPE, githubAuth_GITHUB_RECORD_KEY as GITHUB_RECORD_KEY, type githubAuth_GithubAttemptPhase as GithubAttemptPhase, type githubAuth_GithubAttemptView as GithubAttemptView, type githubAuth_GithubAuthDeps as GithubAuthDeps, type githubAuth_GithubGrantPayload as GithubGrantPayload, type githubAuth_WebServerLike as WebServerLike, githubAuth_attemptView as attemptView, githubAuth_beginGithubSignIn as beginGithubSignIn, githubAuth_buildAuthorizeUrl as buildAuthorizeUrl, githubAuth_cancelGithubSignIn as cancelGithubSignIn, githubAuth_createPkce as createPkce, githubAuth_registerGithubFlow as registerGithubFlow, githubAuth_resetAttemptForTest as resetAttemptForTest, githubAuth_resolveClientId as resolveClientId, githubAuth_verifyState as verifyState };
|
|
1292
1305
|
}
|
|
1293
1306
|
|
|
1294
1307
|
interface DefaultBranchResult {
|
package/lib/internal.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@morehao/dsh-github-trending",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.1",
|
|
4
4
|
"description": "GitHub 趋势日报的 DeepSeek Harness 插件:按日 / 周 / 月周期定时 spawn 本地 trendradar 核心,抓取 Trending、生成中文简介与周期总结,并可选把订阅仓库的新 Release 合成中文摘要,一起提交到你的仓库、自动开 PR 合并;内置概览 / 榜单 / 运行记录 / 订阅 / 设置工作台。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|