Ask permission to complete a specific request from a connected application, can choose to Allow, Always Allow, Deny, Always Deny the request
(ad *xswd.ApplicationData, request *jrpc2.Request)
| 3901 | // Ask permission to complete a specific request from a connected application, |
| 3902 | // can choose to Allow, Always Allow, Deny, Always Deny the request |
| 3903 | func AskPermissionForRequest(ad *xswd.ApplicationData, request *jrpc2.Request) (choice xswd.Permission) { |
| 3904 | method := request.Method() |
| 3905 | // Gnomon methods behave as AlwaysAllow |
| 3906 | if strings.HasPrefix(method, "Gnomon.") { |
| 3907 | return xswd.Allow |
| 3908 | } |
| 3909 | |
| 3910 | // All other methods require approval |
| 3911 | choice = xswd.Deny |
| 3912 | |
| 3913 | // EPOCH is not online or permissioned so Deny request |
| 3914 | if strings.HasSuffix(method, "EPOCH") && !epoch.IsActive() { |
| 3915 | return |
| 3916 | } else if method == "AttemptEPOCHWithAddr" && !cyberdeck.EPOCH.allowWithAddress { |
| 3917 | return |
| 3918 | } |
| 3919 | |
| 3920 | overlay := session.Window.Canvas().Overlays() |
| 3921 | |
| 3922 | headerText := "NEW PERMISSION REQUEST" |
| 3923 | |
| 3924 | header := canvas.NewText(headerText, colors.Gray) |
| 3925 | header.TextSize = 16 |
| 3926 | header.Alignment = fyne.TextAlignCenter |
| 3927 | header.TextStyle = fyne.TextStyle{Bold: true} |
| 3928 | |
| 3929 | labelApp := canvas.NewText("FROM", colors.Gray) |
| 3930 | labelApp.TextSize = 14 |
| 3931 | labelApp.Alignment = fyne.TextAlignLeading |
| 3932 | labelApp.TextStyle = fyne.TextStyle{Bold: true} |
| 3933 | |
| 3934 | textApp := widget.NewRichTextFromMarkdown("### " + ad.Name) |
| 3935 | textApp.Wrapping = fyne.TextWrapWord |
| 3936 | |
| 3937 | labelRequest := canvas.NewText("REQUESTING", colors.Gray) |
| 3938 | labelRequest.TextSize = 14 |
| 3939 | labelRequest.Alignment = fyne.TextAlignLeading |
| 3940 | labelRequest.TextStyle = fyne.TextStyle{Bold: true} |
| 3941 | |
| 3942 | textRequest := widget.NewRichTextFromMarkdown("### " + method) |
| 3943 | textRequest.Wrapping = fyne.TextWrapWord |
| 3944 | |
| 3945 | labelParams := canvas.NewText("PARAMETERS", colors.Gray) |
| 3946 | labelParams.TextSize = 14 |
| 3947 | labelParams.Alignment = fyne.TextAlignLeading |
| 3948 | labelParams.TextStyle = fyne.TextStyle{Bold: true} |
| 3949 | |
| 3950 | params := "None" |
| 3951 | if method == "HandleTELALinks" { |
| 3952 | var linkParams TELALink_Params |
| 3953 | err := request.UnmarshalParams(&linkParams) |
| 3954 | if err != nil { |
| 3955 | logger.Errorf("[Engram] Denied TELA link request %s from %s: %s\n", request.ParamString(), ad.Name, err) |
| 3956 | return |
| 3957 | } |
| 3958 | |
| 3959 | params, err = handleTELALinkRequest(linkParams) |
| 3960 | if err != nil { |
no test coverage detected