github.com/keybase/client/go@v0.0.0-20240309051027-028f7c731f8b/kbnm/hostmanifest/hostmanifest.go (about)

     1  package hostmanifest
     2  
     3  // AppManifest is a serializable App metadata container
     4  type AppManifest interface {
     5  	// ID returns the app identifier, usually the same as the name.
     6  	ID() string
     7  	// BinPath returns the path of the binary for the NativeMessaging app target.
     8  	BinPath() string
     9  }
    10  
    11  // App contains the metadata that defines a NativeMessaging app.
    12  type App struct {
    13  	Name        string `json:"name"`
    14  	Description string `json:"description"`
    15  	Path        string `json:"path"`
    16  	Type        string `json:"type"`
    17  }
    18  
    19  // ID returns the app identifier
    20  func (app App) ID() string {
    21  	return app.Name
    22  }
    23  
    24  // BinPath returns the path of the binary for the NativeMessaging app target.
    25  func (app App) BinPath() string {
    26  	return app.Path
    27  }
    28  
    29  // ChromeApp is the App metadata but includes Chrome-specific fields.
    30  type ChromeApp struct {
    31  	App
    32  	AllowedOrigins []string `json:"allowed_origins"`
    33  }
    34  
    35  // FirefoxApp is the App metadata but includes Firefox-specific fields.
    36  type FirefoxApp struct {
    37  	App
    38  	AllowedExtensions []string `json:"allowed_extensions"`
    39  }
    40  
    41  // Installer handles writing whitelist information for enabling the
    42  // NativeMessaging app.
    43  type Installer interface {
    44  	Install(u User, app AppManifest) error
    45  	Uninstall(u User, app AppManifest) error
    46  }