-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmain.go
37 lines (32 loc) · 874 Bytes
/
main.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
package main
import (
"aremykeyssafe/gpg"
"aremykeyssafe/ssh"
"syscall/js"
)
func getSSHKeyLength(this js.Value, args []js.Value) interface{} {
key := args[0].String()
callback := args[len(args)-1:][0]
bitLen, fingerprint, err := ssh.Decode(key)
if err != nil {
callback.Invoke(err, js.Null(), js.Null())
}
callback.Invoke(js.Null(), bitLen, fingerprint)
return nil
}
func getGPGExpired(this js.Value, args []js.Value) interface{} {
pubKey := args[0].String()
callback := args[len(args)-1:][0]
expired, bitLen, keyType, err := gpg.Decode(pubKey)
if err != nil {
callback.Invoke(err, js.Null(), js.Null())
}
callback.Invoke(js.Null(), expired, keyType, bitLen)
return nil
}
func main() {
block := make(chan bool)
js.Global().Set("getSSHKeyLength", js.FuncOf(getSSHKeyLength))
js.Global().Set("getGPGExpired", js.FuncOf(getGPGExpired))
<-block
}