This repository has been archived by the owner on Nov 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpermissions.go
85 lines (68 loc) · 2.29 KB
/
permissions.go
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// +build js,wasm
// https://w3c.github.io/permissions/#idl-index
package wasm
type (
PermissionStatus interface {
EventTarget
State() PermissionState
OnChange(func(Event)) EventHandler
}
Permissions interface {
Query(PermissionDescriptor) func() (PermissionStatus, error)
}
PermissionDescriptor interface {
Name() PermissionName
JSValue() jsValue
}
PushPermissionDescriptor interface {
PermissionDescriptor
UserVisibleOnly() bool
}
MidiPermissionDescriptor interface {
PermissionDescriptor
Sysex() bool
}
DevicePermissionDescriptor interface {
PermissionDescriptor
DeviceId() string
}
)
type PermissionSetParameters struct {
Descriptor PermissionDescriptor
State PermissionState
OneRealm bool
}
func (p PermissionSetParameters) JSValue() jsValue {
o := jsObject.New()
o.Set("descriptor", p.Descriptor.JSValue())
o.Set("state", string(p.State))
o.Set("oneRealm", p.OneRealm)
return o
}
type PermissionName string
const (
PermissionNameGeolocation PermissionName = "geolocation"
PermissionNameNotifications PermissionName = "notifications"
PermissionNamePush PermissionName = "push"
PermissionNameMidi PermissionName = "midi"
PermissionNameCamera PermissionName = "camera"
PermissionNameMicrophone PermissionName = "microphone"
PermissionNameSpeaker PermissionName = "speaker"
PermissionNameDeviceInfo PermissionName = "device-info"
PermissionNameBackgroundFetch PermissionName = "background-fetch"
PermissionNameBackgroundSync PermissionName = "background-sync"
PermissionNameBluetooth PermissionName = "bluetooth"
PermissionNamePersistentStorage PermissionName = "persistent-storage"
PermissionNameAmbientLightSensor PermissionName = "ambient-light-sensor"
PermissionNameAccelerometer PermissionName = "accelerometer"
PermissionNameGyroscope PermissionName = "gyroscope"
PermissionNameMagnetometer PermissionName = "magnetometer"
PermissionNameClipboard PermissionName = "clipboard"
PermissionNameDisplay PermissionName = "display"
)
type PermissionState string
const (
PermissionStateGranted PermissionState = "granted"
PermissionStateDenied PermissionState = "denied"
PermissionStatePrompt PermissionState = "prompt"
)