chore: 为 SECTL Auth 登录链路添加耗时日志

定位点击登录到浏览器弹出之间约 1 分钟延迟的来源,在前端
(handleOAuthLogin / getAuthorizationUrl) 与 Rust (oauth_start_callback_server)
各步骤加 +Nms 相对耗时日志。

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
JSR
2026-07-05 18:44:59 +08:00
parent e40ba986b2
commit b46acd7581
3 changed files with 46 additions and 4 deletions
+10 -1
View File
@@ -120,9 +120,16 @@ class SectlAuthService {
}
async getAuthorizationUrl(scope?: string[]): Promise<string> {
const t0 = performance.now()
const log = (step: string) =>
console.log(`[sectlAuth.getAuthorizationUrl] ${step} +${Math.round(performance.now() - t0)}ms`)
const state = this.generateRandomState()
log("after generateRandomState")
this.codeVerifier = await generateCodeVerifier()
log("after generateCodeVerifier")
const codeChallenge = await generateCodeChallenge(this.codeVerifier)
log("after generateCodeChallenge")
// 保存 code_verifier 到 localStorage,以便 deep link 回调时使用
localStorage.setItem("sectl_code_verifier", this.codeVerifier)
@@ -140,7 +147,9 @@ class SectlAuthService {
params.set("scope", scope.join(" "))
}
return `${SECTL_CONFIG.authUrl}/oauth/authorize?${params.toString()}`
const url = `${SECTL_CONFIG.authUrl}/oauth/authorize?${params.toString()}`
log("done")
return url
}
async authorize(scope?: string[]): Promise<TokenData> {