MCPcopy Create free account
hub / github.com/DEROFDN/Engram / XSWDPrompt

Function XSWDPrompt

functions.go:3530–3817  ·  view source on GitHub ↗

Prompt when an application submits request to connect to wallet with XSWD

(ad *xswd.ApplicationData)

Source from the content-addressed store, hash-verified

3528
3529// Prompt when an application submits request to connect to wallet with XSWD
3530func XSWDPrompt(ad *xswd.ApplicationData) (confirmed bool) {
3531 if cyberdeck.WS.advanced {
3532 // If global permissions enabled set them here
3533 if cyberdeck.WS.global.enabled {
3534 logger.Printf("[Engram] Applied global XSWD permissions to %s\n", ad.Name)
3535 cyberdeck.WS.RLock()
3536 for k, v := range cyberdeck.WS.global.permissions {
3537 ad.Permissions[k] = v
3538 }
3539 cyberdeck.WS.RUnlock()
3540 }
3541
3542 // If wallet is set to connect to all requests, connect to app
3543 if cyberdeck.WS.global.connect {
3544 logger.Printf("[Engram] Applied automatic XSWD connection to %s\n", ad.Name)
3545 fyne.CurrentApp().SendNotification(&fyne.Notification{Title: ad.Name, Content: "A new connection request has been approved"})
3546 go refreshXSWDList()
3547 return true
3548 }
3549 } else {
3550 // Restrictive mode overwrites any requested permissions to default Ask, and sets certain methods to AlwaysDeny
3551 ad.Permissions = map[string]xswd.Permission{}
3552 ad.Permissions["QueryKey"] = xswd.AlwaysDeny
3553 ad.Permissions["query_key"] = xswd.AlwaysDeny
3554 }
3555
3556 overlay := session.Window.Canvas().Overlays()
3557
3558 headerText := "NEW CONNECTION REQUEST"
3559
3560 header := canvas.NewText(headerText, colors.Gray)
3561 header.TextSize = 16
3562 header.Alignment = fyne.TextAlignCenter
3563 header.TextStyle = fyne.TextStyle{Bold: true}
3564
3565 labelApp := canvas.NewText("APP NAME", colors.Gray)
3566 labelApp.TextSize = 14
3567 labelApp.Alignment = fyne.TextAlignLeading
3568 labelApp.TextStyle = fyne.TextStyle{Bold: true}
3569
3570 textApp := widget.NewRichTextFromMarkdown("### " + ad.Name)
3571 textApp.Wrapping = fyne.TextWrapWord
3572
3573 labelID := canvas.NewText("APP ID", colors.Gray)
3574 labelID.TextSize = 14
3575 labelID.Alignment = fyne.TextAlignLeading
3576 labelID.TextStyle = fyne.TextStyle{Bold: true}
3577
3578 textID := widget.NewRichTextFromMarkdown(ad.Id)
3579 textID.Wrapping = fyne.TextWrapWord
3580
3581 labelURL := canvas.NewText("URL", colors.Gray)
3582 labelURL.TextSize = 14
3583 labelURL.Alignment = fyne.TextAlignLeading
3584 labelURL.TextStyle = fyne.TextStyle{Bold: true}
3585
3586 textURL := widget.NewRichTextFromMarkdown(ad.Url)
3587 textURL.Wrapping = fyne.TextWrapWord

Callers 1

toggleXSWDFunction · 0.85

Calls 2

refreshXSWDListFunction · 0.85
RefreshMethod · 0.80

Tested by

no test coverage detected