-
Notifications
You must be signed in to change notification settings - Fork 212
Expand file tree
/
Copy pathhandleUri.ts
More file actions
62 lines (58 loc) · 1.84 KB
/
Copy pathhandleUri.ts
File metadata and controls
62 lines (58 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import * as vscode from "vscode"
import { getRouterUnavailableSignInMessage } from "../core/config/routerRemoval"
import { ClineProvider } from "../core/webview/ClineProvider"
import { handleAuthCallback as handleZooCodeAuthCallback, setZooCodeUserInfo } from "../services/zoo-code-auth"
export const handleUri = async (uri: vscode.Uri) => {
const path = uri.path
const query = new URLSearchParams(uri.query.replace(/\+/g, "%2B"))
const visibleProvider = ClineProvider.getVisibleInstance()
switch (path) {
case "/openrouter": {
if (!visibleProvider) return
const code = query.get("code")
if (code) {
await visibleProvider.handleOpenRouterCallback(code)
}
break
}
case "/requesty": {
if (!visibleProvider) return
const code = query.get("code")
const baseUrl = query.get("baseUrl")
if (code) {
await visibleProvider.handleRequestyCallback(code, baseUrl)
}
break
}
case "/auth/clerk/callback": {
vscode.window.showInformationMessage(getRouterUnavailableSignInMessage())
break
}
case "/auth-callback": {
const token = query.get("token")
if (token) {
// Extract user info from callback URL params
// URLSearchParams.get() already decodes percent-encoded values - no need for decodeURIComponent
const name = query.get("name") ?? undefined
const email = query.get("email") ?? undefined
const image = query.get("image") ?? undefined
const success = await handleZooCodeAuthCallback(token)
if (success && visibleProvider) {
// Store user info only after successful auth validation
if (name || email || image) {
await setZooCodeUserInfo({
name,
email,
image,
})
}
// Update the active API configuration to use zoo-code with the new token
await visibleProvider.handleZooCodeCallback(token)
}
}
break
}
default:
break
}
}