-
Notifications
You must be signed in to change notification settings - Fork 6
/
config.go
88 lines (79 loc) · 3.21 KB
/
config.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package main
import (
"encoding/hex"
"fmt"
"os"
)
type UmaConfig struct {
ApiClientID string
ApiClientSecret string
NodeUUID string
Username string
UserID string
UmaEncryptionCertChain string
UmaEncryptionPubKeyHex string
UmaEncryptionPrivKeyHex string
UmaSigningCertChain string
UmaSigningPubKeyHex string
UmaSigningPrivKeyHex string
RemoteSigningNodeMasterSeedHex string
OskNodeSigningKeyPassword string
ClientBaseURL *string
OwnVaspDomain string
}
func (c *UmaConfig) UmaEncryptionPrivKeyBytes() ([]byte, error) {
return hex.DecodeString(c.UmaEncryptionPrivKeyHex)
}
func (c *UmaConfig) UmaSigningPrivKeyBytes() ([]byte, error) {
return hex.DecodeString(c.UmaSigningPrivKeyHex)
}
func (c *UmaConfig) NodeMasterSeedBytes() ([]byte, error) {
return hex.DecodeString(c.RemoteSigningNodeMasterSeedHex)
}
/**
* This object defines the configuration for the UMA server. First, initialize your client ID and
* client secret. Those are available in your account at https://app.lightspark.com/api_config.
*
* Those variables can either be set through environmental variables:
*
* export LIGHTSPARK_API_TOKEN_CLIENT_ID=<client_id>
* export LIGHTSPARK_API_TOKEN_CLIENT_SECRET=<client_secret>
*
* Or simply edited inline.
*
* This example also assumes you already know your node UUID. Generally, an LNURL API would serve
* many different usernames while maintaining some internal mapping from username to node UUID. For
* simplicity, this example works with a single username and node UUID.
*
* export LIGHTSPARK_UMA_NODE_ID=0187c4d6-704b-f96b-0000-a2e8145bc1f9
*/
func NewConfig() UmaConfig {
username := os.Getenv("LIGHTSPARK_UMA_RECEIVER_USER")
if username == "" {
username = "ls_test"
}
baseUrlEnv := os.Getenv("LIGHTSPARK_EXAMPLE_BASE_URL")
baseUrlStr := fmt.Sprintf("https://%s/graphql/server/rc", baseUrlEnv)
baseUrl := &baseUrlStr
if baseUrlEnv == "" {
baseUrl = nil
}
return UmaConfig{
ApiClientID: os.Getenv("LIGHTSPARK_API_TOKEN_CLIENT_ID"),
ApiClientSecret: os.Getenv("LIGHTSPARK_API_TOKEN_CLIENT_SECRET"),
NodeUUID: os.Getenv("LIGHTSPARK_UMA_NODE_ID"),
Username: username,
// Static UUID so that callback URLs are always the same.
UserID: "4b41ae03-01b8-4974-8d26-26a35d28851b",
UmaEncryptionCertChain: os.Getenv("LIGHTSPARK_UMA_ENCRYPTION_CERT_CHAIN"),
UmaEncryptionPubKeyHex: os.Getenv("LIGHTSPARK_UMA_ENCRYPTION_PUBKEY"),
UmaEncryptionPrivKeyHex: os.Getenv("LIGHTSPARK_UMA_ENCRYPTION_PRIVKEY"),
UmaSigningCertChain: os.Getenv("LIGHTSPARK_UMA_SIGNING_CERT_CHAIN"),
UmaSigningPubKeyHex: os.Getenv("LIGHTSPARK_UMA_SIGNING_PUBKEY"),
UmaSigningPrivKeyHex: os.Getenv("LIGHTSPARK_UMA_SIGNING_PRIVKEY"),
RemoteSigningNodeMasterSeedHex: os.Getenv("LIGHTSPARK_UMA_REMOTE_SIGNING_NODE_MASTER_SEED"),
OskNodeSigningKeyPassword: os.Getenv("LIGHTSPARK_UMA_OSK_NODE_SIGNING_KEY_PASSWORD"),
ClientBaseURL: baseUrl,
OwnVaspDomain: os.Getenv("LIGHTSPARK_UMA_VASP_DOMAIN"),
}
}