This repository has been archived by the owner on Jul 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathshare.go
66 lines (58 loc) · 3.07 KB
/
share.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
package doppler
type (
// SharePlain allows to generate a Doppler Share link by sending a plain text secret.
SharePlain struct {
URL *string `json:"url,omitempty"`
AuthenticatedURL *string `json:"authenticated_url,omitempty"`
Password *string `json:"password,omitempty"`
}
// ShareEncrypted allows to generate a Doppler Share link by sending an end-to-end encrypted secret.
ShareEncrypted struct {
URL *string `json:"url,omitempty"`
}
// SharePlainResponse represents a response from the share plain endpoint.
//
// Method: POST
// Endpoint: https://api.doppler.com/v1/share/secrets/plain
// Docs: https://docs.doppler.com/reference/share-secret
SharePlainResponse struct {
APIResponse `json:",inline"`
Secret *SharePlain `json:",inline"`
}
// SharePlainOptions represents the options for the share plain endpoint.
SharePlainOptions struct {
Secret string `url:"-" json:"secret"` // Plain text secret to share.
ExpireViews *int32 `url:"-" json:"expire_views,omitempty"` // Number of views before the link expires. Valid ranges: 1 to 50. -1 for unlimited.
ExpireDays *int32 `url:"-" json:"expire_days,omitempty"` // Number of days before the link expires. Valid range: 1 to 90.
}
// ShareEncryptedResponse represents a response from the share encrypted endpoint.
//
// Method: POST
// Endpoint: https://api.doppler.com/v1/share/secrets/encrypted
// Docs: https://docs.doppler.com/reference/share-secret-encrypted
ShareEncryptedResponse struct {
APIResponse `json:",inline"`
Secret *ShareEncrypted `json:",inline"`
}
// ShareEncryptedOptions represents the options for the share encrypted endpoint.
ShareEncryptedOptions struct {
Secret string `url:"-" json:"encrypted_secret"` // Base64 encoded AES-GCM encrypted secret to share. See docs for more details.
Password string `url:"-" json:"hashed_password"` // SHA256 hash of the password. This is NOT the hash of the derived encryption key.
KDF string `url:"-" json:"encryption_kdf"` // The key derivation function used. Must by "pbkdf2".
SaltRounds int32 `url:"-" json:"encryption_salt_rounds"` // Number of salt rounds used by KDF. Must be "100000".
ExpireViews *int32 `url:"-" json:"expire_views,omitempty"` // Number of views before the link expires. Valid ranges: 1 to 50. -1 for unlimited.
ExpireDays *int32 `url:"-" json:"expire_days,omitempty"` // Number of days before the link expires. Valid range: 1 to 90.
}
)
const (
// EncryptionKDF is the key derivation function used for encrypted secrets. As stated in the docs [1] this
// has to be "pbkdf2". This is a constatnt to avoid typos and help with testing.
//
// [1]: https://docs.doppler.com/reference/share-secret-encrypted
EncryptionKDF = "pbkdf2"
// EncryptionSaltRounds is the number of salt rounds used by the key derivation function. As stated in the docs [1] this
// has to be "100000". This is a constatnt to avoid typos and help with testing.
//
// [1]: https://docs.doppler.com/reference/share-secret-encrypted
EncryptionSaltRounds = 100000
)