Skip to content

Add optional GitHub Star developer unlock - #37

Merged
qiin2333 merged 5 commits into
masterfrom
codex/github-star-dev-unlock
Jun 14, 2026
Merged

Add optional GitHub Star developer unlock#37
qiin2333 merged 5 commits into
masterfrom
codex/github-star-dev-unlock

Conversation

@qiin2333

@qiin2333 qiin2333 commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add an optional GitHub OAuth Device Flow verifier for developer-mode unlock, matching the Android Moonlight V+ approach of checking GET /user/starred/{owner}/{repo} after authorization.
  • Wire Settings developer mode to use GitHub Star verification when GITHUB_OAUTH_CLIENT_ID is configured, while preserving the existing activation-code path as fallback.
  • Document optional GitHub OAuth/API communication in the privacy policy.

AppGallery / HarmonyOS Market Notes

  • Android reference: qiin2333/moonlight-vplus uses GitHub OAuth Device Flow plus GitHub Star verification for developer feature unlock.
  • Harmony implementation is technically feasible and compiled through ArkTS.
  • Potential listing risk remains: this flow asks users to sign in to a third-party account and Star an external GitHub repository before unlocking an in-app feature. Huawei review guidance has risk areas around third-party account login requirements and inducement / external interaction style flows. Because there is no clear safe harbor for “Star to unlock”, the market package should keep GITHUB_OAUTH_CLIENT_ID empty unless review confirms this is acceptable.
  • With the default empty OAuth client ID, the app keeps the existing activation-code unlock behavior. If review blocks Star verification, this PR can still be merged without enabling it in release builds.

Configuration

  • entry/src/main/ets/config/GitHubOAuthConfig.ets
    • GITHUB_OAUTH_CLIENT_ID = '' by default, so GitHub Star unlock is disabled.
    • Set it to a GitHub OAuth App Client ID with Device Flow enabled to activate the Star verifier.
    • Star target defaults to AlkaidLab/moonlight-harmony.

Verification

  • Ran: DEVECO_SDK_HOME=/Applications/DevEco-Studio.app/Contents/sdk sh ./hvigorw --mode module -p module=entry assembleHap --no-daemon
  • Result: :entry:default@CompileArkTS completed successfully.
  • Packaging then failed at :entry:default@PackageHap because this local machine has no Java Runtime installed: “Unable to locate a Java Runtime.”

Summary by CodeRabbit

发行说明

  • 新功能

    • 新增 GitHub Star 验证流程,支持 GitHub OAuth 设备认证方式
    • 验证状态与账户信息仅存储在本地设备
    • 应用可连接 GitHub API 进行账户星标检查
  • 文档

    • 更新隐私政策,新增 GitHub 验证、数据存储与网络通信说明
    • 新增 GitHub OAuth 配置示例与使用说明
  • Chores

    • 更新构建脚本以支持新配置流程
    • 更新 gitignore 规则

@coderabbitai

coderabbitai Bot commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 10ec3082-f69f-4e01-8050-89adfcd1d351

📥 Commits

Reviewing files that changed from the base of the PR and between a56af88 and aa21975.

📒 Files selected for processing (3)
  • .gitignore
  • ci/patch-sdk.sh
  • entry/src/main/ets/config/GitHubOAuthConfig.ets.example
✅ Files skipped from review due to trivial changes (2)
  • .gitignore
  • entry/src/main/ets/config/GitHubOAuthConfig.ets.example

📝 Walkthrough

Walkthrough

新增基于GitHub OAuth Device Flow的Star验证流程用于激活开发者模式:定义数据结构与存储键、扩展HttpClient原始请求能力、实现GitHubStarVerifier核心逻辑、在Settings页面集成完整验证UI流程;同步更新隐私政策、新增OAuth配置模板、扩展CI脚本以支持ScanKit补丁和配置文件占位生成。

Changes

GitHub Star验证Developer Mode解锁

Layer / File(s) Summary
隐私政策与OAuth配置模板
PRIVACY_POLICY.md, entry/src/main/ets/config/GitHubOAuthConfig.ets.example, .gitignore
隐私政策四处章节(本地存储、网络通信、数据不收集、第三方服务)新增GitHub Star验证说明;新增OAuth Device Flow配置常量示例文件;.gitignore增加对实际配置文件的忽略。
存储键与数据结构定义
entry/src/main/ets/service/SettingsService.ets, entry/src/main/ets/utils/GitHubStarVerifier.ets
SettingsService新增8个GitHub设备授权/轮询相关存储键;GitHubStarVerifier新增GitHubDeviceCode、GitHubTokenPollStatus、GitHubTokenPollResult、GitHubStarCheck数据类与枚举。
HttpClient原始请求支持
entry/src/main/ets/utils/HttpClient.ets
新增HttpMethod字面量联合类型;实现requestRaw方法,直接返回原始HttpResponse而不对状态码做业务判断。
GitHub OAuth Device Flow核心实现
entry/src/main/ets/utils/GitHubStarVerifier.ets
实现requestDeviceCode(表单提交+响应解析)、pollAccessToken(四状态映射+动态间隔)、checkStar(204/404区分)、fetchLogin;封装postForm、githubApiHeaders、JSON解析与错误信息提取工具方法。
Settings页面GitHub验证集成
entry/src/main/ets/pages/SettingsPageV2.ets
新增验证状态字段与启动时恢复逻辑;重构开发者模式开关UI(getDeveloperModeSubtitle + toggleDeveloperMode);实现设备码申请展示、轮询节流、Star校验、登录名持久化、失败回滚;更新隐私政策对话框文案。

CI脚本扩展

Layer / File(s) Summary
SDK扫描重构、ScanKit补丁与OAuth配置生成
ci/patch-sdk.sh
SDK加载程序文件扫描改用os.walk替代glob;新增ScanKit符号完整性补丁;新增GitHubOAuthConfig占位文件从.example自动生成逻辑。

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题清晰准确地概括了本PR的主要变更:添加可选的GitHub Star开发者解锁功能。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/github-star-dev-unlock

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@entry/src/main/ets/pages/SettingsPageV2.ets`:
- Around line 3904-3906: The code currently writes the GitHub access token into
long-lived preferences via
PreferencesUtil.put(SettingsKeys.DEV_GITHUB_ACCESS_TOKEN, accessToken) in
SettingsPageV2.ets; instead, stop persisting the raw token in PreferencesUtil:
store it in a secure credential store (e.g., platform secure storage/keystore
API) or keep it only in-memory for the session and clear it immediately after
use. Replace the PreferencesUtil.put call for
SettingsKeys.DEV_GITHUB_ACCESS_TOKEN with a secure-storage write (or remove
persistence and use a transient in-memory/session variable) and ensure any
retrieval logic expects the secure store or session-only token; leave the
non-sensitive SettingsKeys.DEV_GITHUB_LOGIN write intact if desired.
- Around line 3888-3891: The PENDING/SLOW_DOWN branch is calling
saveDeveloperPendingDeviceCode(deviceCode) which recomputes expires_at (current
time + expiresInSeconds) and thus keeps extending local expiry; instead only
update the polling interval without touching expires_at. Change the branch
handling PENDING/SLOW_DOWN to set deviceCode.intervalSeconds and persist it with
a method that preserves the existing expires_at (either add an optional
parameter preserveExpiry:boolean to saveDeveloperPendingDeviceCode and call
saveDeveloperPendingDeviceCode(deviceCode, {preserveExpiry: true}) or introduce
a new helper like updateDeveloperPendingDeviceCodeInterval(deviceCode) that
updates only intervalSeconds in storage). Ensure the code paths that
compute/overwrite expires_at (inside saveDeveloperPendingDeviceCode) are skipped
when preserveExpiry is requested.

In `@entry/src/main/ets/utils/GitHubStarVerifier.ets`:
- Around line 241-246: The githubApiHeaders function is missing a User-Agent
header which can cause GitHub to reject requests; update
GitHubStarVerifier.githubApiHeaders to include a stable User-Agent (e.g. add a
static constant like GitHubStarVerifier.USER_AGENT and set headers['User-Agent']
= GitHubStarVerifier.USER_AGENT) so fetchLogin and checkStar (which reuse
githubApiHeaders) inherit the header; no other call-site changes required beyond
creating the USER_AGENT constant and returning it in githubApiHeaders.

In `@PRIVACY_POLICY.md`:
- Around line 95-96: PRIVACY_POLICY.md now documents that the app calls GitHub
OAuth Device Flow and GitHub API for optional developer-mode GitHub Star
verification, but the in-app PrivacyPolicyDialog in SettingsPageV2.ets
(component PrivacyPolicyDialog) still states “no internet data transfer / no
third-party services”; update the PrivacyPolicyDialog text to match the
PRIVACY_POLICY.md disclosure by changing the relevant copy in
PrivacyPolicyDialog (in entry/src/main/ets/pages/SettingsPageV2.ets) to
explicitly mention the optional GitHub OAuth Device Flow and GitHub API usage
for developer-mode Star verification (or rephrase to a consistent statement that
third‑party services are used only for that optional verification), ensuring
both documents convey the same scope and optional nature of the GitHub
third‑party interaction.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: a1370f28-5dd0-424b-ac8a-cce1eb3b9a62

📥 Commits

Reviewing files that changed from the base of the PR and between 4798db1 and 7437536.

📒 Files selected for processing (7)
  • PRIVACY_POLICY.md
  • entry/src/main/ets/config/GitHubOAuthConfig.ets
  • entry/src/main/ets/config/GitHubOAuthConfig.ets.example
  • entry/src/main/ets/pages/SettingsPageV2.ets
  • entry/src/main/ets/service/SettingsService.ets
  • entry/src/main/ets/utils/GitHubStarVerifier.ets
  • entry/src/main/ets/utils/HttpClient.ets

Comment thread entry/src/main/ets/pages/SettingsPageV2.ets
Comment thread entry/src/main/ets/pages/SettingsPageV2.ets Outdated
Comment thread entry/src/main/ets/utils/GitHubStarVerifier.ets
Comment thread PRIVACY_POLICY.md
@qiin2333
qiin2333 merged commit d99033a into master Jun 14, 2026
2 checks passed
@qiin2333
qiin2333 deleted the codex/github-star-dev-unlock branch June 14, 2026 05:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant