@morehao/dsh-github-trending 0.8.1 → 0.8.2
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 +8 -0
- package/README.md +3 -1
- package/client.js +35 -7
- package/lib/{chunk-LLTW4YHJ.js → chunk-5D2VRWPJ.js} +88 -28
- package/lib/index.d.ts +2 -0
- package/lib/index.js +15 -5
- package/lib/internal.d.ts +28 -3
- package/lib/internal.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [v0.8.2] - 2026-11-02
|
|
4
|
+
|
|
5
|
+
### Fixes
|
|
6
|
+
|
|
7
|
+
- **auth**: register github flow after service is ready (#72)
|
|
8
|
+
|
|
9
|
+
**Full Changelog**: https://github.com/morehao/dsh-github-trending/compare/v0.8.1...v0.8.2
|
|
10
|
+
|
|
3
11
|
## [v0.7.11] - 2026-11-01
|
|
4
12
|
|
|
5
13
|
### Refactors
|
package/README.md
CHANGED
|
@@ -63,7 +63,9 @@ GitHub 趋势榜的 **DeepSeek Harness 插件**:按日 / 周 / 月周期定时
|
|
|
63
63
|
- **本机 gh**:复用你终端里 `gh auth login` 的登录态。
|
|
64
64
|
- **PAT**:手工填 Personal Access Token(存到凭据引用 / 环境变量)。
|
|
65
65
|
|
|
66
|
-
> 浏览器登录需要核心提供 `authorization`
|
|
66
|
+
> 浏览器登录需要核心提供 `authorization` 服务,并且 GitHub flow 注册成功才算可用;两者任一不满足时,设置页直接提示不可用并引导改用 gh / PAT,而不是给一个点了没反应的按钮。宿主启动时服务可能晚于插件就绪,插件会等服务就绪再注册,并在读状态时再兜底一次。
|
|
67
|
+
>
|
|
68
|
+
> 授权页默认尝试自动打开;若被浏览器的弹窗拦截,状态行里始终有可点的「打开授权页」链接与「复制链接」。
|
|
67
69
|
|
|
68
70
|
### 订阅
|
|
69
71
|
|
package/client.js
CHANGED
|
@@ -132,10 +132,14 @@ var DICT = {
|
|
|
132
132
|
"auth.browser.cancel": "取消",
|
|
133
133
|
"auth.browser.done": "已登录",
|
|
134
134
|
"auth.browser.device": "用设备码登录",
|
|
135
|
-
"auth.browser.unavailable": "
|
|
136
|
-
"auth.browser.openHint": "
|
|
135
|
+
"auth.browser.unavailable": "宿主的 authorization 服务不可用(或 GitHub 授权流程没注册成功):请重试一次;仍不行就改用「本机 gh」或 PAT。",
|
|
136
|
+
"auth.browser.openHint": "若浏览器没有自动打开,点下面的链接完成授权,或复制链接:",
|
|
137
|
+
"auth.browser.open": "打开授权页",
|
|
137
138
|
"auth.browser.copy": "复制链接",
|
|
138
139
|
"auth.browser.copied": "授权链接已复制",
|
|
140
|
+
"auth.browser.failed": "登录失败",
|
|
141
|
+
"auth.browser.failed.detail": "登录失败:{message}",
|
|
142
|
+
"auth.browser.failed.hint": "宿主没有完成 GitHub 授权流程的注册,请重试;仍失败请改用「本机 gh」或 PAT。",
|
|
139
143
|
"auth.pat.hint": "在 GitHub → Settings → Developer settings 生成 Personal Access Token(勾选 public_repo),填到下方引用或环境变量。",
|
|
140
144
|
"auth.tokenRef": "凭据引用",
|
|
141
145
|
"auth.tokenRef.hint": "凭据引用名 / 环境变量名",
|
|
@@ -673,10 +677,14 @@ var DICT = {
|
|
|
673
677
|
"auth.browser.cancel": "Cancel",
|
|
674
678
|
"auth.browser.done": "Signed in",
|
|
675
679
|
"auth.browser.device": "Use a device code",
|
|
676
|
-
"auth.browser.unavailable": "
|
|
677
|
-
"auth.browser.openHint": "If the browser did not open,
|
|
680
|
+
"auth.browser.unavailable": "The host authorization service is unavailable (or the GitHub flow did not register): retry once, then fall back to Local gh or a PAT.",
|
|
681
|
+
"auth.browser.openHint": "If the browser did not open, use the link below to finish signing in, or copy the link:",
|
|
682
|
+
"auth.browser.open": "Open authorization page",
|
|
678
683
|
"auth.browser.copy": "Copy link",
|
|
679
684
|
"auth.browser.copied": "Authorization link copied",
|
|
685
|
+
"auth.browser.failed": "Sign-in failed",
|
|
686
|
+
"auth.browser.failed.detail": "Sign-in failed: {message}",
|
|
687
|
+
"auth.browser.failed.hint": "The host did not register the GitHub authorization flow. Retry, or use Local gh / a PAT instead.",
|
|
680
688
|
"auth.pat.hint": "Create a Personal Access Token under GitHub → Settings → Developer settings (scope public_repo) and put it in the ref below or an env var.",
|
|
681
689
|
"auth.tokenRef": "Credential ref",
|
|
682
690
|
"auth.tokenRef.hint": "credential ref / env var name",
|
|
@@ -1340,6 +1348,8 @@ var CSS = `
|
|
|
1340
1348
|
.dshgt-ready-extra{color:var(--gt-muted);font-size:12px;margin-left:7px;}
|
|
1341
1349
|
.dshgt-linkbtn{border:0;background:none;color:var(--gt-accent);font-family:inherit;font-size:12.5px;padding:6px 2px;border-radius:4px;cursor:pointer;}
|
|
1342
1350
|
.dshgt-linkbtn:hover{text-decoration:underline;}
|
|
1351
|
+
.dshgt-link{color:var(--gt-accent);text-decoration:none;font-size:12.5px;word-break:break-all;}
|
|
1352
|
+
.dshgt-link:hover{text-decoration:underline;}
|
|
1343
1353
|
.dshgt-week{display:flex;gap:6px;align-items:stretch;}
|
|
1344
1354
|
.dshgt-day{flex:1;min-width:0;border:1px solid var(--gt-border);border-radius:8px;padding:8px;background:var(--gt-card);display:flex;flex-direction:column;gap:5px;text-align:left;font-family:inherit;color:inherit;}
|
|
1345
1355
|
.dshgt-day-clickable{cursor:pointer;}
|
|
@@ -2249,8 +2259,13 @@ function SettingsView(props) {
|
|
|
2249
2259
|
};
|
|
2250
2260
|
const startSignIn = async (method) => {
|
|
2251
2261
|
try {
|
|
2252
|
-
|
|
2262
|
+
let view = await beginGithubSignIn(method);
|
|
2263
|
+
if (view.phase === "idle") view = await getGithubSignInStatus();
|
|
2253
2264
|
setSignIn(view);
|
|
2265
|
+
if (view.phase === "error") {
|
|
2266
|
+
notify("err", t("auth.browser.failed.detail", { message: view.error ?? "" }));
|
|
2267
|
+
return;
|
|
2268
|
+
}
|
|
2254
2269
|
if (view.phase === "waiting-browser" && view.authorizeUrl !== void 0) {
|
|
2255
2270
|
try {
|
|
2256
2271
|
window.open(view.authorizeUrl, "_blank", "noopener,noreferrer");
|
|
@@ -2542,8 +2557,10 @@ function SettingsView(props) {
|
|
|
2542
2557
|
}) }),
|
|
2543
2558
|
h("span", { className: "dshgt-hint" }, t("auth.tokenRef.hint"))
|
|
2544
2559
|
),
|
|
2545
|
-
//
|
|
2546
|
-
isBrowser && signIn.phase
|
|
2560
|
+
// 浏览器登录失败:必须显式说出来,否则「点了没反应」又回来了。
|
|
2561
|
+
isBrowser && signIn.phase === "error" ? h(Alert, { kind: "err", title: t("auth.browser.failed") }, signIn.error ?? t("auth.browser.failed.hint")) : null,
|
|
2562
|
+
// 浏览器登录进行中的状态行:可点的授权页链接 + 复制兜底 + 设备码。
|
|
2563
|
+
isBrowser && (signIn.phase === "waiting-browser" || signIn.phase === "waiting-device" || signIn.phase === "exchanging") ? h(
|
|
2547
2564
|
"div",
|
|
2548
2565
|
{ className: "dshgt-hint" },
|
|
2549
2566
|
signIn.authorizeUrl !== void 0 ? h(
|
|
@@ -2551,8 +2568,19 @@ function SettingsView(props) {
|
|
|
2551
2568
|
{ className: "dshgt-desc" },
|
|
2552
2569
|
h("span", null, t("auth.browser.openHint")),
|
|
2553
2570
|
" ",
|
|
2571
|
+
h(
|
|
2572
|
+
"a",
|
|
2573
|
+
{ className: "dshgt-link", href: signIn.authorizeUrl, target: "_blank", rel: "noreferrer" },
|
|
2574
|
+
t("auth.browser.open")
|
|
2575
|
+
),
|
|
2576
|
+
" ",
|
|
2554
2577
|
h(Btn, { small: true, variant: "ghost", onClick: () => copyAuthorizeLink() }, t("auth.browser.copy"))
|
|
2555
2578
|
) : null,
|
|
2579
|
+
signIn.verificationUri !== void 0 ? h(
|
|
2580
|
+
"div",
|
|
2581
|
+
{ className: "dshgt-desc" },
|
|
2582
|
+
h("a", { className: "dshgt-link", href: signIn.verificationUri, target: "_blank", rel: "noreferrer" }, signIn.verificationUri)
|
|
2583
|
+
) : null,
|
|
2556
2584
|
signIn.userCode !== void 0 ? h("div", { className: "dshgt-mono" }, `${t("auth.browser.code")} ${signIn.userCode}`) : null
|
|
2557
2585
|
) : null,
|
|
2558
2586
|
h(
|
|
@@ -3538,6 +3538,8 @@ __export(github_auth_exports, {
|
|
|
3538
3538
|
buildAuthorizeUrl: () => buildAuthorizeUrl,
|
|
3539
3539
|
cancelGithubSignIn: () => cancelGithubSignIn,
|
|
3540
3540
|
createPkce: () => createPkce,
|
|
3541
|
+
ensureGithubFlow: () => ensureGithubFlow,
|
|
3542
|
+
isGithubFlowRegistered: () => isGithubFlowRegistered,
|
|
3541
3543
|
registerGithubFlow: () => registerGithubFlow,
|
|
3542
3544
|
resetAttemptForTest: () => resetAttemptForTest,
|
|
3543
3545
|
resolveClientId: () => resolveClientId,
|
|
@@ -3764,13 +3766,8 @@ async function runDevice(deps, session) {
|
|
|
3764
3766
|
}
|
|
3765
3767
|
throw new Error("GitHub device flow \u8D85\u65F6");
|
|
3766
3768
|
}
|
|
3767
|
-
function
|
|
3768
|
-
|
|
3769
|
-
if (authorization === void 0 || typeof authorization.registerFlow !== "function") {
|
|
3770
|
-
deps.logger?.("auth.flow.skipped", { reason: "no-authorization-service" });
|
|
3771
|
-
return;
|
|
3772
|
-
}
|
|
3773
|
-
authorization.registerFlow({
|
|
3769
|
+
function flowDefinition(deps) {
|
|
3770
|
+
return {
|
|
3774
3771
|
key: GITHUB_RECORD_KEY2,
|
|
3775
3772
|
label: "GitHub",
|
|
3776
3773
|
methods: [
|
|
@@ -3778,14 +3775,57 @@ function registerGithubFlow(deps) {
|
|
|
3778
3775
|
{ id: "device", label: "Use a device code" }
|
|
3779
3776
|
],
|
|
3780
3777
|
run: (session) => session.method === "device" ? runDevice(deps, session) : runBrowser(deps, session)
|
|
3781
|
-
}
|
|
3778
|
+
};
|
|
3779
|
+
}
|
|
3780
|
+
var registeredOn = /* @__PURE__ */ new WeakSet();
|
|
3781
|
+
var failedOn = /* @__PURE__ */ new WeakSet();
|
|
3782
|
+
function isGithubFlowRegistered(deps) {
|
|
3783
|
+
const authorization = deps.get("authorization");
|
|
3784
|
+
if (authorization === void 0) return false;
|
|
3785
|
+
if (typeof authorization.describe === "function") {
|
|
3786
|
+
try {
|
|
3787
|
+
return authorization.describe(GITHUB_RECORD_KEY2) !== void 0;
|
|
3788
|
+
} catch {
|
|
3789
|
+
return registeredOn.has(authorization);
|
|
3790
|
+
}
|
|
3791
|
+
}
|
|
3792
|
+
return registeredOn.has(authorization);
|
|
3793
|
+
}
|
|
3794
|
+
function ensureGithubFlow(deps) {
|
|
3795
|
+
const authorization = deps.get("authorization");
|
|
3796
|
+
if (authorization === void 0 || typeof authorization.registerFlow !== "function") return false;
|
|
3797
|
+
if (isGithubFlowRegistered(deps)) {
|
|
3798
|
+
registeredOn.add(authorization);
|
|
3799
|
+
return true;
|
|
3800
|
+
}
|
|
3801
|
+
if (failedOn.has(authorization)) return false;
|
|
3802
|
+
try {
|
|
3803
|
+
authorization.registerFlow(flowDefinition(deps));
|
|
3804
|
+
} catch (error) {
|
|
3805
|
+
failedOn.add(authorization);
|
|
3806
|
+
deps.logger?.("auth.flow.failed", {
|
|
3807
|
+
key: GITHUB_RECORD_KEY2,
|
|
3808
|
+
message: error instanceof Error ? error.message : String(error)
|
|
3809
|
+
});
|
|
3810
|
+
return isGithubFlowRegistered(deps);
|
|
3811
|
+
}
|
|
3812
|
+
registeredOn.add(authorization);
|
|
3782
3813
|
deps.logger?.("auth.flow.registered", { key: GITHUB_RECORD_KEY2 });
|
|
3814
|
+
return true;
|
|
3815
|
+
}
|
|
3816
|
+
function registerGithubFlow(deps) {
|
|
3817
|
+
if (!ensureGithubFlow(deps)) deps.logger?.("auth.flow.skipped", { reason: "no-authorization-service" });
|
|
3783
3818
|
}
|
|
3819
|
+
var START_TIMEOUT_MS = 1500;
|
|
3820
|
+
var START_POLL_MS = 10;
|
|
3784
3821
|
async function beginGithubSignIn(deps, method = "browser") {
|
|
3785
3822
|
const authorization = deps.get("authorization");
|
|
3786
3823
|
if (authorization === void 0 || typeof authorization.begin !== "function") {
|
|
3787
3824
|
throw new Error("authorization \u670D\u52A1\u4E0D\u53EF\u7528\uFF1A\u65E0\u6CD5\u8FDB\u884C\u6D4F\u89C8\u5668\u767B\u5F55");
|
|
3788
3825
|
}
|
|
3826
|
+
if (!ensureGithubFlow(deps)) {
|
|
3827
|
+
throw new Error("authorization \u670D\u52A1\u5C1A\u672A\u5C31\u7EEA\uFF0CGitHub \u6388\u6743\u6D41\u7A0B\u6CA1\u6709\u6CE8\u518C\u6210\u529F\uFF1A\u8BF7\u7A0D\u540E\u91CD\u8BD5");
|
|
3828
|
+
}
|
|
3789
3829
|
if (current !== void 0 && (current.phase === "waiting-browser" || current.phase === "waiting-device" || current.phase === "exchanging")) {
|
|
3790
3830
|
throw new Error("already-in-flight");
|
|
3791
3831
|
}
|
|
@@ -3793,29 +3833,43 @@ async function beginGithubSignIn(deps, method = "browser") {
|
|
|
3793
3833
|
const timer = setTimeout(() => controller.abort(), attemptTimeout(deps));
|
|
3794
3834
|
const attempt = { phase: "idle", controller, done: Promise.resolve() };
|
|
3795
3835
|
current = attempt;
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
notify
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3836
|
+
let started;
|
|
3837
|
+
try {
|
|
3838
|
+
started = authorization.begin({
|
|
3839
|
+
key: GITHUB_RECORD_KEY2,
|
|
3840
|
+
method,
|
|
3841
|
+
signal: controller.signal,
|
|
3842
|
+
// 浏览器往返靠 authorizeUrl + 回调;notify 只更新内存视图,prompt 不支持(拒绝)。
|
|
3843
|
+
interaction: {
|
|
3844
|
+
notify: (notice) => {
|
|
3845
|
+
if (notice.code !== void 0 && notice.url !== void 0) {
|
|
3846
|
+
updateCurrent({ phase: "waiting-device", verificationUri: notice.url, userCode: notice.code });
|
|
3847
|
+
} else if (notice.url !== void 0) {
|
|
3848
|
+
updateCurrent({ phase: "waiting-browser", authorizeUrl: notice.url });
|
|
3849
|
+
}
|
|
3850
|
+
},
|
|
3851
|
+
prompt: () => Promise.reject(new Error("interactive prompt unsupported in this surface"))
|
|
3852
|
+
}
|
|
3853
|
+
});
|
|
3854
|
+
} catch (error) {
|
|
3855
|
+
clearTimeout(timer);
|
|
3856
|
+
updateCurrent({ phase: "error", error: error instanceof Error ? error.message : String(error) });
|
|
3857
|
+
return attemptView();
|
|
3858
|
+
}
|
|
3859
|
+
attempt.done = started.then((outcome) => {
|
|
3812
3860
|
if (outcome.status === "cancelled") updateCurrent({ phase: "idle" });
|
|
3813
3861
|
}).catch((error) => {
|
|
3814
3862
|
updateCurrent({ phase: "error", error: error instanceof Error ? error.message : String(error) });
|
|
3815
3863
|
}).finally(() => clearTimeout(timer));
|
|
3816
|
-
await
|
|
3864
|
+
await waitForStart(attempt);
|
|
3817
3865
|
return attemptView();
|
|
3818
3866
|
}
|
|
3867
|
+
async function waitForStart(attempt, timeoutMs = START_TIMEOUT_MS) {
|
|
3868
|
+
const deadline = Date.now() + timeoutMs;
|
|
3869
|
+
while (attempt.phase === "idle" && Date.now() < deadline) {
|
|
3870
|
+
await new Promise((resolve) => setTimeout(resolve, START_POLL_MS));
|
|
3871
|
+
}
|
|
3872
|
+
}
|
|
3819
3873
|
function cancelGithubSignIn(deps) {
|
|
3820
3874
|
const authorization = deps.get("authorization");
|
|
3821
3875
|
if (authorization !== void 0 && typeof authorization.cancel === "function") {
|
|
@@ -4392,6 +4446,10 @@ function isAuthorizationAvailable(get) {
|
|
|
4392
4446
|
const authorization = get("authorization");
|
|
4393
4447
|
return authorization !== void 0 && typeof authorization.begin === "function";
|
|
4394
4448
|
}
|
|
4449
|
+
function browserSignInAvailable(deps) {
|
|
4450
|
+
if (!isAuthorizationAvailable(deps.get)) return false;
|
|
4451
|
+
return ensureGithubFlow(githubAuthDeps(deps));
|
|
4452
|
+
}
|
|
4395
4453
|
function githubAuthDeps(deps) {
|
|
4396
4454
|
return {
|
|
4397
4455
|
get: deps.get,
|
|
@@ -4586,8 +4644,10 @@ async function dispatch(method, pathname, url, body, deps) {
|
|
|
4586
4644
|
const method2 = body.method === "device" ? "device" : "browser";
|
|
4587
4645
|
try {
|
|
4588
4646
|
const view = await beginGithubSignIn(githubAuthDeps(deps), method2);
|
|
4647
|
+
if (view.phase === "error") throw new IpcError("GITHUB_AUTH_UNAVAILABLE", redact(view.error ?? "GitHub \u767B\u5F55\u5931\u8D25"));
|
|
4589
4648
|
return { attempt: view };
|
|
4590
4649
|
} catch (error) {
|
|
4650
|
+
if (error instanceof IpcError) throw error;
|
|
4591
4651
|
const message = error instanceof Error ? error.message : String(error);
|
|
4592
4652
|
if (message === "already-in-flight") {
|
|
4593
4653
|
return { attempt: attemptView(), alreadyInFlight: true };
|
|
@@ -4733,8 +4793,8 @@ async function statePayload(deps, settings) {
|
|
|
4733
4793
|
source: github.source,
|
|
4734
4794
|
/** 浏览器登录 attempt 视图(idle / waiting-browser / waiting-device / exchanging / done / error)。 */
|
|
4735
4795
|
attempt: attemptView(),
|
|
4736
|
-
/**
|
|
4737
|
-
browserAvailable:
|
|
4796
|
+
/** 浏览器登录是否可用:authorization 服务在、且 GitHub flow 真的注册上了(client_id 有内置默认)。 */
|
|
4797
|
+
browserAvailable: browserSignInAvailable(deps)
|
|
4738
4798
|
}
|
|
4739
4799
|
};
|
|
4740
4800
|
}
|
|
@@ -5013,7 +5073,7 @@ export {
|
|
|
5013
5073
|
readPluginInfo,
|
|
5014
5074
|
plugin_info_exports,
|
|
5015
5075
|
github_exports,
|
|
5016
|
-
|
|
5076
|
+
ensureGithubFlow,
|
|
5017
5077
|
github_auth_exports,
|
|
5018
5078
|
import_cli_exports,
|
|
5019
5079
|
pending_pr_exports,
|
package/lib/index.d.ts
CHANGED
|
@@ -10,6 +10,8 @@ interface PluginLogger {
|
|
|
10
10
|
interface PluginContext {
|
|
11
11
|
get?: (name: string) => unknown;
|
|
12
12
|
effect?: (factory: () => unknown, label?: string) => unknown;
|
|
13
|
+
/** cordis 的服务就绪钩子:依赖被提供(或重提供)时回调,用于「晚到的服务」注册。 */
|
|
14
|
+
inject?: (deps: string[], callback: (scope: PluginContext) => unknown) => unknown;
|
|
13
15
|
logger?: PluginLogger;
|
|
14
16
|
webServer?: {
|
|
15
17
|
register: (options: {
|
package/lib/index.js
CHANGED
|
@@ -7,9 +7,9 @@ import {
|
|
|
7
7
|
createTrendingHistoryTool,
|
|
8
8
|
createTrendingRunTool,
|
|
9
9
|
createUpdateService,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
} from "./chunk-
|
|
10
|
+
ensureGithubFlow,
|
|
11
|
+
readPluginInfo
|
|
12
|
+
} from "./chunk-5D2VRWPJ.js";
|
|
13
13
|
|
|
14
14
|
// src/index.ts
|
|
15
15
|
var name = "dsh-github-trending";
|
|
@@ -64,11 +64,21 @@ function apply(ctx, config = {}) {
|
|
|
64
64
|
onError: (error) => ctx.logger?.warn?.(`[dsh-github-trending] \u5B9A\u65F6\u8FD0\u884C\u5931\u8D25\uFF1A${error instanceof Error ? error.message : String(error)}`)
|
|
65
65
|
});
|
|
66
66
|
const pluginInfo = readPluginInfo();
|
|
67
|
-
|
|
68
|
-
get,
|
|
67
|
+
const githubAuth = (resolve) => ({
|
|
68
|
+
get: resolve,
|
|
69
69
|
logger: log,
|
|
70
70
|
...config.githubClientId === void 0 ? {} : { clientId: config.githubClientId }
|
|
71
71
|
});
|
|
72
|
+
const registerAuth = (resolve) => {
|
|
73
|
+
if (!ensureGithubFlow(githubAuth(resolve ?? get))) log("auth.flow.deferred", { reason: "authorization-not-ready" });
|
|
74
|
+
};
|
|
75
|
+
if (typeof ctx.inject === "function") {
|
|
76
|
+
ctx.inject(["authorization"], (scope) => {
|
|
77
|
+
registerAuth((name2) => typeof scope.get === "function" ? scope.get(name2) : void 0);
|
|
78
|
+
});
|
|
79
|
+
} else {
|
|
80
|
+
registerAuth();
|
|
81
|
+
}
|
|
72
82
|
const update = createUpdateService({
|
|
73
83
|
get,
|
|
74
84
|
env,
|
package/lib/internal.d.ts
CHANGED
|
@@ -1203,6 +1203,8 @@ interface AuthorizationLike {
|
|
|
1203
1203
|
status: 'authorized' | 'cancelled';
|
|
1204
1204
|
}>;
|
|
1205
1205
|
cancel?: (key: string) => void;
|
|
1206
|
+
/** 核心 0.2.x 有:按 key 查已注册的 flow;判定「真的注册上了」靠它。 */
|
|
1207
|
+
describe?: (key: string) => unknown;
|
|
1206
1208
|
}
|
|
1207
1209
|
interface WebServerLike {
|
|
1208
1210
|
register?: (route: {
|
|
@@ -1264,14 +1266,35 @@ interface GithubGrantPayload {
|
|
|
1264
1266
|
tokenType?: string;
|
|
1265
1267
|
scope?: string;
|
|
1266
1268
|
}
|
|
1269
|
+
/** 这个 key 现在是否**真的**有 flow 在注册表里。 */
|
|
1270
|
+
declare function isGithubFlowRegistered(deps: GithubAuthDeps): boolean;
|
|
1271
|
+
/**
|
|
1272
|
+
* 幂等注册 GitHub flow;`authorization` 还没就绪时返回 false,调用方可稍后重试。
|
|
1273
|
+
*
|
|
1274
|
+
* 为什么不能只在 `apply()` 里试一次:宿主按「服务可用性」激活插件,本插件只
|
|
1275
|
+
* `inject: ['webServer']`,apply 完全可能早于 `authorization`——后者要等
|
|
1276
|
+
* `credentials` 的异步 `[Service.init]`(启动时读 `.credentials.yaml`)走完才
|
|
1277
|
+
* 可见,而 `ctx.get()` 对未 active 的 provider 返回 undefined。那一刻若放弃注册,
|
|
1278
|
+
* 就永久没有 flow;而可用性又是按请求现算的,于是出现「按钮亮着、点了必然
|
|
1279
|
+
* NO_FLOW、界面毫无反馈」。所以注册做成可重入的自愈入口:apply 用
|
|
1280
|
+
* `ctx.inject(['authorization'])` 等服务就绪,HTTP 面每次读状态再兜底一次。
|
|
1281
|
+
*
|
|
1282
|
+
* @returns 注册后是否可用(服务缺失 / 注册失败时为 false)。
|
|
1283
|
+
*/
|
|
1284
|
+
declare function ensureGithubFlow(deps: GithubAuthDeps): boolean;
|
|
1267
1285
|
/**
|
|
1268
1286
|
* 向 `ctx.authorization` 注册 GitHub flow(若核心没有该服务则降级 no-op)。
|
|
1269
|
-
*
|
|
1287
|
+
* 等价于 {@link ensureGithubFlow},保留旧名字给 `apply()` 与测试用。
|
|
1270
1288
|
*/
|
|
1271
1289
|
declare function registerGithubFlow(deps: GithubAuthDeps): void;
|
|
1272
1290
|
/**
|
|
1273
1291
|
* 启动一次浏览器登录 attempt(进程内 `authorization.begin`,不阻塞请求)。
|
|
1274
|
-
*
|
|
1292
|
+
*
|
|
1293
|
+
* 返回的视图保证**不是 `idle`**:要么已经进入 waiting-*,要么已经落成 `error`
|
|
1294
|
+
* (供路由转成 HTTP 错误)。`idle` 只可能来自「flow 没注册」这类抢跑,前端拿到
|
|
1295
|
+
* 它就会以为什么都没发生——那正是「点了没反应」的形态,所以这里把它堵掉。
|
|
1296
|
+
*
|
|
1297
|
+
* @throws 服务不可用、flow 未注册、已有 attempt 在飞时抛错。
|
|
1275
1298
|
*/
|
|
1276
1299
|
declare function beginGithubSignIn(deps: GithubAuthDeps, method?: 'browser' | 'device'): Promise<GithubAttemptView>;
|
|
1277
1300
|
/** 取消进行中的 attempt。 */
|
|
@@ -1296,12 +1319,14 @@ declare const githubAuth_beginGithubSignIn: typeof beginGithubSignIn;
|
|
|
1296
1319
|
declare const githubAuth_buildAuthorizeUrl: typeof buildAuthorizeUrl;
|
|
1297
1320
|
declare const githubAuth_cancelGithubSignIn: typeof cancelGithubSignIn;
|
|
1298
1321
|
declare const githubAuth_createPkce: typeof createPkce;
|
|
1322
|
+
declare const githubAuth_ensureGithubFlow: typeof ensureGithubFlow;
|
|
1323
|
+
declare const githubAuth_isGithubFlowRegistered: typeof isGithubFlowRegistered;
|
|
1299
1324
|
declare const githubAuth_registerGithubFlow: typeof registerGithubFlow;
|
|
1300
1325
|
declare const githubAuth_resetAttemptForTest: typeof resetAttemptForTest;
|
|
1301
1326
|
declare const githubAuth_resolveClientId: typeof resolveClientId;
|
|
1302
1327
|
declare const githubAuth_verifyState: typeof verifyState;
|
|
1303
1328
|
declare namespace githubAuth {
|
|
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 };
|
|
1329
|
+
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_ensureGithubFlow as ensureGithubFlow, githubAuth_isGithubFlowRegistered as isGithubFlowRegistered, githubAuth_registerGithubFlow as registerGithubFlow, githubAuth_resetAttemptForTest as resetAttemptForTest, githubAuth_resolveClientId as resolveClientId, githubAuth_verifyState as verifyState };
|
|
1305
1330
|
}
|
|
1306
1331
|
|
|
1307
1332
|
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.2",
|
|
4
4
|
"description": "GitHub 趋势日报的 DeepSeek Harness 插件:按日 / 周 / 月周期定时 spawn 本地 trendradar 核心,抓取 Trending、生成中文简介与周期总结,并可选把订阅仓库的新 Release 合成中文摘要,一起提交到你的仓库、自动开 PR 合并;内置概览 / 榜单 / 运行记录 / 订阅 / 设置工作台。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|