-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.go
136 lines (116 loc) · 3.99 KB
/
types.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
package otplessgo
import "net/http"
// Represents a authentication channel / method
type Channel string
// Represents the OTP Length (4 or 6)
type OtpLength int
// Represents the metadata for a request
type Metadata map[string]string
// Represents authentication channel for oAuth authentication
type OAuthChannel string
const (
ChannelWhatsapp = Channel("WHATSAPP")
ChannelSMS = Channel("SMS")
ChannelVoiceCall = Channel("VOICE_CALL")
ChannelViber = Channel("VIBER")
ChannelEmail = Channel("EMAIL")
)
const (
OAuthWhatsapp = OAuthChannel("WHATSAPP")
OAuthTwitter = OAuthChannel("TWITTER")
OAuthGoogle = OAuthChannel("GOOGLE")
OAuthApple = OAuthChannel("APPLE")
OAuthLinkedin = OAuthChannel("LINKEDIN")
OAuthMicrosoft = OAuthChannel("MICROSOFT")
OAuthFacebook = OAuthChannel("FACEBOOK")
OAuthInstagram = OAuthChannel("INSTAGRAM")
OAuthLine = OAuthChannel("LINE")
OAuthSlack = OAuthChannel("SLACK")
OAuthDropbox = OAuthChannel("DROPBOX")
OAuthGithub = OAuthChannel("GITHUB")
OAuthBitbucket = OAuthChannel("BITBUCKET")
OAuthAtlassian = OAuthChannel("ATLASSIAN")
OAuthLinear = OAuthChannel("LINEAR")
OAuthGitlab = OAuthChannel("GITLAB")
OAuthTitktok = OAuthChannel("TIKTOK")
OAuthTwitch = OAuthChannel("TWITCH")
OAuthTelegram = OAuthChannel("TELEGRAM")
OAuthHubspot = OAuthChannel("HUBSPOT")
OAuthNotion = OAuthChannel("NOTION")
OAuthBox = OAuthChannel("BOX")
OAuthXero = OAuthChannel("XERO")
)
const (
DigitFour = OtpLength(4)
DigitSix = OtpLength(6)
)
// API Response for request made to OTPLESS API
type ApiResponse[T any] struct {
Response *T
ErrorResponse *ApiErrorResponse
RawResponse *http.Response
}
// API Error response for request made to OTPLESS API
type ApiErrorResponse struct {
Message string `json:"message,omitempty"`
Description string `json:"description,omitempty"`
ErrorCode string `json:"errorCode,omitempty"`
}
type ApiSuccessWithRequestID struct {
RequestID string `json:"requestId"`
}
type VerifySuccessResponse struct {
RequestID string `json:"requestId"`
IsOTPVerified bool `json:"isOTPVerified"`
Message string `json:"message"`
}
type CodeVerifyPayload struct {
Code string `json:"code"`
}
type CodeVerificationResponse struct {
RequestId string `json:"requestId"`
Message string `json:"message"`
}
type UserDetails struct {
Token string `json:"token"`
Status string `json:"status"`
CompletedAt int `json"completedAt"`
Identity []UserIdentity `json:"identities"`
Network UserNetwork `json:"network"`
DeviceInfo DeviceInfo `json:"deviceInfo"`
}
type UserIdentity struct {
IdentityType string `json:"identityType"`
IdentityValue string `json:"identityValue"`
Channel string `json:"channel"`
Methods []string `json:"methods"`
Verified bool `json:"verified"`
VerifiedTimeStamp int `json:"verifiedTimeStamp"`
}
type UserNetwork struct {
IP string `json:"ip"`
}
type DeviceInfo struct {
UserAgent string `json:"userAgent"`
Platform string `json:"platform"`
Vendor string `json:"vendor"`
Language string `json:"language"`
CookieEnabled bool `json:"cookieEnabled"`
ScreenWidth int `json:"screenWidth"`
ScreenHeight int `json:"screenHeight"`
ScreenColorDepth int `json:"screenColorDepth"`
DevicePixelRatio float64 `json:"devicePixelRatio"`
}
type RequestStatusResponse struct {
Token string `json:"token,omitempty"`
Status string `json:"status,omitempty"`
CompletedAt int `json:"completedAt,omitempty"`
}
type RequestIdentity struct {
Type string `json:"identityType,omitempty"`
Value string `json:"identityValue,omitempty"`
Channel string `json:"identityChannel,omitempty"`
Methods []string `json:"identityMethods,omitempty"`
Verified bool `json:"verified,omitempty"`
VerifiedTimeStamp int `json:"verifiedTimeStamp,omitempty"`
}