forked from Kachit/appstore-sdk-go
/
config.go
60 lines (50 loc) · 1.4 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
package appstore
import "time"
//AppStoreConnectAPIProductionUri const
const AppStoreConnectAPIProductionUri = "https://api.appstoreconnect.apple.com"
//AppStoreConnectAPIAudience const
const AppStoreConnectAPIAudience = "appstoreconnect-v1"
//AppStoreConnectAPITokenTtl const
const AppStoreConnectAPITokenTtl = 600
//AppStoreConnectAPIHttpMaxIdleConnection const
const AppStoreConnectAPIHttpMaxIdleConnection = 10
//AppStoreConnectAPIHttpIdleConnectionTimeout const
const AppStoreConnectAPIHttpIdleConnectionTimeout = 30 * time.Second
//Config structure
type Config struct {
Uri string
VendorNo string
IssuerId string
KeyId string
PrivateKey string
Token *TokenConfig
}
//TokenConfig token config structure
type TokenConfig struct {
Audience string
Type string
Algo string
Ttl int
}
//NewConfig Create new config from credentials
func NewConfig(issuerId string, keyId string, vendorNo string, pkPathOrContent string) *Config {
cfg := &Config{
Uri: AppStoreConnectAPIProductionUri,
IssuerId: issuerId,
KeyId: keyId,
VendorNo: vendorNo,
PrivateKey: pkPathOrContent,
Token: NewTokenConfig(),
}
return cfg
}
//NewTokenConfig Create new token config
func NewTokenConfig() *TokenConfig {
cfg := &TokenConfig{
Type: "JWT",
Algo: "ES256",
Audience: AppStoreConnectAPIAudience,
Ttl: AppStoreConnectAPITokenTtl,
}
return cfg
}