forked from invertase/react-native-apple-authentication
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSignInWithAppleConfiguration.kt
More file actions
89 lines (71 loc) · 1.9 KB
/
SignInWithAppleConfiguration.kt
File metadata and controls
89 lines (71 loc) · 1.9 KB
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
package com.RNAppleAuthentication
data class SignInWithAppleConfiguration private constructor(
val clientId: String,
val redirectUri: String,
val scope: String,
val responseType: String,
val state: String,
val rawNonce: String,
val nonce: String,
val fullScreen: Boolean = true
) {
class Builder {
private lateinit var clientId: String
private lateinit var redirectUri: String
private lateinit var scope: String
private lateinit var responseType: String
private lateinit var state: String
private lateinit var rawNonce: String
private lateinit var nonce: String
private var fullScreen: Boolean = true
fun clientId(clientId: String) = apply {
this.clientId = clientId
}
fun redirectUri(redirectUri: String) = apply {
this.redirectUri = redirectUri
}
fun scope(scope: Scope) = apply {
this.scope = scope.signal()
}
fun responseType(type: ResponseType) = apply {
this.responseType = type.signal()
}
fun state(state: String) = apply {
this.state = state
}
fun rawNonce(rawNonce: String) = apply {
this.rawNonce = rawNonce
}
fun nonce(nonce: String) = apply {
this.nonce = nonce
}
fun fullScreen(fullScreen: Boolean) = apply {
this.fullScreen = fullScreen
}
fun build() = SignInWithAppleConfiguration(clientId, redirectUri, scope, responseType, state, rawNonce, nonce, fullScreen)
}
enum class ResponseType {
CODE {
override fun signal() = "code"
},
ID_TOKEN {
override fun signal() = "id_token"
},
ALL {
override fun signal() = "code id_token"
};
abstract fun signal(): String
}
enum class Scope {
NAME {
override fun signal() = "name"
},
EMAIL {
override fun signal() = "email"
},
ALL {
override fun signal() = "name email"
};
abstract fun signal(): String
}
}