跳到主要内容

Claude Cage · 面向 Claude 的隔离开发环境,支持桌面工作台、多账号、远程部署与移动端连接。上游 Lee-xeo/Claude-Cage 完整源码镜像,非灵栈原创;主许可 MIT,第三方组件遵循各自许可。来源:https://github.com/Lee-xeo/Claude-Cage 。手动同步,不附带 Release 安装包。

浏览文件

password_target.go

30 行 · 908 B历史下载
1package maclogin
2
3import "time"
4
5type passwordTarget struct {
6 maintenanceWindow
7 Accessibility bool `json:"accessibility"`
8 SelectionRequired bool `json:"selection_required"`
9}
10
11// Before Accessibility is granted, the user selects the input position in
12// Apple's system panel. The host binds that click to the current GUI session
13// and panel, and consumes it when the user requests password entry.
14type passwordSelection struct {
15 Geometry string
16 X, Y int
17 Clicked time.Time
18}
19
20func (selection passwordSelection) permits(target passwordTarget, user string, now time.Time) bool {
21 if !target.valid(user) {
22 return false
23 }
24 if target.Accessibility {
25 return target.PasswordFocused
26 }
27 return target.SelectionRequired && selection.Geometry == target.geometry() &&
28 now.Sub(selection.Clicked) >= 0 && now.Sub(selection.Clicked) <= 30*time.Second &&
29 target.contains(selection.X, selection.Y)
30}