models.go

v1.0.0
Doc Versions Source
1
package api
2
3
import "encoding/json"
4
5
// PreloginRequest is the body for POST /identity/accounts/prelogin.
6
type PreloginRequest struct {
7
	Email string `json:"email"`
8
}
9
10
// PreloginResponse contains KDF parameters for a given email.
11
type PreloginResponse struct {
12
	Kdf            int `json:"kdf"`
13
	KdfIterations  int `json:"kdfIterations"`
14
	KdfMemory      int `json:"kdfMemory,omitempty"`
15
	KdfParallelism int `json:"kdfParallelism,omitempty"`
16
}
17
18
// TokenResponse is the response from POST /identity/connect/token.
19
type TokenResponse struct {
20
	AccessToken  string `json:"access_token"`
21
	RefreshToken string `json:"refresh_token"`
22
	ExpiresIn    int    `json:"expires_in"`
23
	TokenType    string `json:"token_type"`
24
25
	// Encryption keys — only present on password grant (not refresh).
26
	Key        string `json:"Key"`
27
	PrivateKey string `json:"PrivateKey"`
28
29
	// 2FA challenge fields — present when HTTP 400 + 2FA required.
30
	TwoFactorProviders2 map[string]map[string]any `json:"TwoFactorProviders2,omitempty"`
31
}
32
33
// RegisterRequest is the body for POST /identity/accounts/register.
34
type RegisterRequest struct {
35
	Name               string       `json:"name"`
36
	Email              string       `json:"email"`
37
	MasterPasswordHash string       `json:"masterPasswordHash"`
38
	MasterPasswordHint *string      `json:"masterPasswordHint"`
39
	Key                string       `json:"key"`
40
	Kdf                int          `json:"kdf"`
41
	KdfIterations      int          `json:"kdfIterations"`
42
	KdfMemory          int          `json:"kdfMemory,omitempty"`
43
	KdfParallelism     int          `json:"kdfParallelism,omitempty"`
44
	Keys               RegisterKeys `json:"keys"`
45
}
46
47
// RegisterKeys contains the public/private key pair for registration.
48
type RegisterKeys struct {
49
	PublicKey           string `json:"publicKey"`
50
	EncryptedPrivateKey string `json:"encryptedPrivateKey"`
51
}
52
53
// ErrorResponse is the error format returned by the server API.
54
type ErrorResponse struct {
55
	Message          string              `json:"message"`
56
	Error            string              `json:"error"`
57
	ErrorDescription string              `json:"error_description"`
58
	ValidationErrors map[string][]string `json:"validationErrors,omitempty"`
59
	ErrorModel       *ErrorModel         `json:"errorModel,omitempty"`
60
}
61
62
// ErrorModel is the nested error object in server error responses.
63
type ErrorModel struct {
64
	Message string `json:"message"`
65
	Object  string `json:"object"`
66
}
67
68
// SyncResponse is the response from GET /api/sync.
69
type SyncResponse struct {
70
	Profile     SyncProfile       `json:"profile"`
71
	Folders     []json.RawMessage `json:"folders"`
72
	Ciphers     []json.RawMessage `json:"ciphers"`
73
	Collections []json.RawMessage `json:"collections"`
74
	Sends       []json.RawMessage `json:"sends"`
75
}
76
77
// SyncProfile is the profile section of the sync response.
78
type SyncProfile struct {
79
	ID            string    `json:"id"`
80
	Email         string    `json:"email"`
81
	Name          string    `json:"name"`
82
	Organizations []SyncOrg `json:"organizations"`
83
}
84
85
// SyncOrg is an organization entry in the sync profile.
86
type SyncOrg struct {
87
	ID      string `json:"id"`
88
	Name    string `json:"name"`
89
	Key     string `json:"key"`
90
	Status  int    `json:"status"`
91
	Type    int    `json:"type"`
92
	Enabled bool   `json:"enabled"`
93
}
94

Source Files