forked from gopasspw/gopass
-
Notifications
You must be signed in to change notification settings - Fork 0
/
manifest.go
63 lines (55 loc) · 1.54 KB
/
manifest.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
package manifest
import (
"encoding/json"
"fmt"
)
func getManifestContent(browser, wrapperPath string) ([]byte, error) {
switch browser {
case "firefox":
return newFirefoxManifest(wrapperPath).Format()
case "chrome":
fallthrough
case "chromium":
return newChromeManifest(wrapperPath).Format()
default:
return nil, fmt.Errorf("no manifest template for browser %s", browser)
}
}
type chromeManifest struct {
Name string `json:"name"`
Description string `json:"description"`
Path string `json:"path"`
Type string `json:"type"`
AllowedOrigins []string `json:"allowed_origins"`
}
func newChromeManifest(path string) *chromeManifest {
return &chromeManifest{
Name: Name,
Type: connectionType,
Path: path,
Description: description,
AllowedOrigins: chromeOrigins,
}
}
func (c *chromeManifest) Format() ([]byte, error) {
return json.MarshalIndent(c, "", " ")
}
type firefoxManifest struct {
Name string `json:"name"`
Description string `json:"description"`
Path string `json:"path"`
Type string `json:"type"`
AllowedExtensions []string `json:"allowed_extensions"`
}
func newFirefoxManifest(path string) *firefoxManifest {
return &firefoxManifest{
Name: Name,
Type: connectionType,
Path: path,
Description: description,
AllowedExtensions: firefoxOrigins,
}
}
func (f *firefoxManifest) Format() ([]byte, error) {
return json.MarshalIndent(f, "", " ")
}