v0.28.0 3cb3770

permission.go RawHistoryFolder

1package entity
2
3// DomainTimestamp represents a Unix timestamp in seconds.
4// This is a domain-owned type to avoid importing time in the domain layer.
5
6// PermissionType represents the type of permission being requested.
7type PermissionType string
8
9const (
10	// PermissionTypeMicrophone represents microphone access permission.
11	PermissionTypeMicrophone PermissionType = "microphone"
12
13	// PermissionTypeCamera represents camera access permission.
14	PermissionTypeCamera PermissionType = "camera"
15
16	// PermissionTypeDisplay represents screen sharing/display capture permission.
17	PermissionTypeDisplay PermissionType = "display"
18
19	// PermissionTypeDeviceInfo represents device enumeration permission.
20	PermissionTypeDeviceInfo PermissionType = "device_info"
21
22	// PermissionTypeClipboard represents clipboard access permission.
23	PermissionTypeClipboard PermissionType = "clipboard"
24
25	// PermissionTypeNotification represents notification permission.
26	PermissionTypeNotification PermissionType = "notification"
27
28	// PermissionTypeGeolocation represents geolocation permission.
29	PermissionTypeGeolocation PermissionType = "geolocation"
30
31	// PermissionTypePointerLock represents pointer lock permission.
32	PermissionTypePointerLock PermissionType = "pointer_lock"
33
34	// PermissionTypeMediaKeySystem represents DRM/media key system permission.
35	PermissionTypeMediaKeySystem PermissionType = "media_key_system"
36
37	// PermissionTypeWebsiteDataAccess represents 3rd party cookie/data access permission.
38	PermissionTypeWebsiteDataAccess PermissionType = "website_data_access"
39)
40
41// Metadata keys for PermissionMetadata.
42const (
43	// PermissionMetadataKeyRequestingDomain is the origin that is requesting cross-site
44	// data access (i.e. the third-party domain asking for its cookies/storage).
45	PermissionMetadataKeyRequestingDomain = "requesting_domain"
46
47	// PermissionMetadataKeyCurrentDomain is the first-party domain currently loaded in
48	// the WebView — the context in which the cross-site request is happening.
49	PermissionMetadataKeyCurrentDomain = "current_domain"
50)
51
52// PermissionMetadata carries extra context for specific permission types.
53// For website_data_access, callers must populate both keys:
54//   - PermissionMetadataKeyRequestingDomain: the origin requesting cross-site data access
55//   - PermissionMetadataKeyCurrentDomain: the domain currently loaded in the WebView
56type PermissionMetadata map[string]string
57
58// PermissionDecision represents the user's decision for a permission.
59type PermissionDecision string
60
61const (
62	// PermissionGranted means the permission was allowed.
63	PermissionGranted PermissionDecision = "granted"
64
65	// PermissionDenied means the permission was denied.
66	PermissionDenied PermissionDecision = "denied"
67
68	// PermissionPrompt means no decision has been made yet (default state).
69	PermissionPrompt PermissionDecision = "prompt"
70)
71
72// PermissionRecord stores a permission decision for a specific origin and type.
73type PermissionRecord struct {
74	Origin    string             // The origin (domain) this permission applies to
75	Type      PermissionType     // The type of permission
76	Decision  PermissionDecision // The decision: granted, denied, or prompt
77	UpdatedAt int64              // Unix timestamp in seconds when this record was last updated
78}
79
80// IsGranted returns true if the permission is granted.
81func (p *PermissionRecord) IsGranted() bool {
82	return p.Decision == PermissionGranted
83}
84
85// IsDenied returns true if the permission is denied.
86func (p *PermissionRecord) IsDenied() bool {
87	return p.Decision == PermissionDenied
88}
89
90// PermissionSet represents multiple permission decisions for a single request.
91// This is used when handling combined permission requests (e.g., mic + camera).
92type PermissionSet struct {
93	Types    []PermissionType
94	Decision PermissionDecision
95}
96
97// CanPersist returns true if this permission type can be persisted.
98// Per W3C spec, display capture permissions cannot be persisted.
99func CanPersist(permType PermissionType) bool {
100	switch permType {
101	case PermissionTypeDisplay:
102		return false // W3C forbids persisting display capture permissions
103	case PermissionTypeDeviceInfo, PermissionTypePointerLock:
104		return false // Auto-allowed, no need to persist
105	default:
106		return true
107	}
108}
109
110// IsAutoAllow returns true if this permission type should be auto-allowed.
111func IsAutoAllow(permType PermissionType) bool {
112	switch permType {
113	case PermissionTypeDisplay:
114		return true // Portal handles the UI
115	case PermissionTypeDeviceInfo:
116		return true // Low risk, just lists devices
117	case PermissionTypePointerLock:
118		return true // Low risk, default WebKit behavior
119	default:
120		return false
121	}
122}
123
124// PermissionTypesToStrings converts permission types to strings for logging.
125func PermissionTypesToStrings(types []PermissionType) []string {
126	result := make([]string, len(types))
127	for i, t := range types {
128		result[i] = string(t)
129	}
130	return result
131}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 8

Tags 42

↑↓ moveenter openesc close