@react-native-kakao/user 3.0.0-next.0 → 3.0.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 3.0.0-next.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 7fe35a2: Fall back to Kakao Account login when KakaoTalk login fails without user cancellation.
|
|
8
|
+
- Updated dependencies [11da5f6]
|
|
9
|
+
- @react-native-kakao/core@3.0.0-next.1
|
|
10
|
+
|
|
3
11
|
## 3.0.0-next.0
|
|
4
12
|
|
|
5
13
|
### Major Changes
|
|
@@ -11,6 +11,8 @@ import com.kakao.sdk.auth.model.Prompt.CERT
|
|
|
11
11
|
import com.kakao.sdk.auth.model.Prompt.CREATE
|
|
12
12
|
import com.kakao.sdk.auth.model.Prompt.LOGIN
|
|
13
13
|
import com.kakao.sdk.auth.model.Prompt.SELECT_ACCOUNT
|
|
14
|
+
import com.kakao.sdk.common.model.ClientError
|
|
15
|
+
import com.kakao.sdk.common.model.ClientErrorCause
|
|
14
16
|
import com.kakao.sdk.user.UserApiClient
|
|
15
17
|
import net.mjstudio.rnkakao.core.util.RNCKakaoResponseNotFoundException
|
|
16
18
|
import net.mjstudio.rnkakao.core.util.RNCKakaoUtil
|
|
@@ -83,6 +85,28 @@ class RNCKakaoUserModule internal constructor(
|
|
|
83
85
|
)
|
|
84
86
|
}
|
|
85
87
|
}
|
|
88
|
+
val requestedServiceTerms = serviceTerms?.filterIsInstance<String>()?.ifEmpty { null }
|
|
89
|
+
val requestedPrompts =
|
|
90
|
+
prompts
|
|
91
|
+
?.filterIsInstance<String>()
|
|
92
|
+
?.mapNotNull {
|
|
93
|
+
when (it) {
|
|
94
|
+
"Login" -> LOGIN
|
|
95
|
+
"Create" -> CREATE
|
|
96
|
+
"Cert" -> CERT
|
|
97
|
+
"SelectAccount" -> SELECT_ACCOUNT
|
|
98
|
+
else -> null
|
|
99
|
+
}
|
|
100
|
+
}?.ifEmpty { null }
|
|
101
|
+
val accountLogin = {
|
|
102
|
+
UserApiClient.instance.loginWithKakaoAccount(
|
|
103
|
+
context,
|
|
104
|
+
prompts = requestedPrompts,
|
|
105
|
+
nonce = nonce,
|
|
106
|
+
serviceTerms = requestedServiceTerms,
|
|
107
|
+
callback = callback,
|
|
108
|
+
)
|
|
109
|
+
}
|
|
86
110
|
|
|
87
111
|
if (scopes?.filterIsInstance<String>()?.isEmpty() == false) {
|
|
88
112
|
UserApiClient.instance.loginWithNewScopes(
|
|
@@ -97,31 +121,24 @@ class RNCKakaoUserModule internal constructor(
|
|
|
97
121
|
?.filterIsInstance<String>()
|
|
98
122
|
?.isEmpty() == true
|
|
99
123
|
) {
|
|
124
|
+
val talkCallback: (OAuthToken?, Throwable?) -> Unit = { token, error ->
|
|
125
|
+
if (error is ClientError && error.reason == ClientErrorCause.Cancelled) {
|
|
126
|
+
callback(token, error)
|
|
127
|
+
} else if (error != null || token == null) {
|
|
128
|
+
accountLogin()
|
|
129
|
+
} else {
|
|
130
|
+
callback(token, error)
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
100
134
|
UserApiClient.instance.loginWithKakaoTalk(
|
|
101
135
|
context,
|
|
102
136
|
nonce = nonce,
|
|
103
|
-
serviceTerms =
|
|
104
|
-
callback =
|
|
137
|
+
serviceTerms = requestedServiceTerms,
|
|
138
|
+
callback = talkCallback,
|
|
105
139
|
)
|
|
106
140
|
} else {
|
|
107
|
-
|
|
108
|
-
context,
|
|
109
|
-
prompts =
|
|
110
|
-
prompts
|
|
111
|
-
?.filterIsInstance<String>()
|
|
112
|
-
?.mapNotNull {
|
|
113
|
-
when (it) {
|
|
114
|
-
"Login" -> LOGIN
|
|
115
|
-
"Create" -> CREATE
|
|
116
|
-
"Cert" -> CERT
|
|
117
|
-
"SelectAccount" -> SELECT_ACCOUNT
|
|
118
|
-
else -> null
|
|
119
|
-
}
|
|
120
|
-
}?.ifEmpty { null },
|
|
121
|
-
nonce = nonce,
|
|
122
|
-
serviceTerms = serviceTerms?.filterIsInstance<String>()?.ifEmpty { null },
|
|
123
|
-
callback = callback,
|
|
124
|
-
)
|
|
141
|
+
accountLogin()
|
|
125
142
|
}
|
|
126
143
|
}
|
|
127
144
|
|
|
@@ -60,17 +60,7 @@ import RNCKakaoCore
|
|
|
60
60
|
RNCKakaoUtil.reject(reject, RNCKakaoError.responseNotFound(name: "token"))
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
-
|
|
64
|
-
if !scopes.isEmpty {
|
|
65
|
-
UserApi.shared.loginWithKakaoAccount(scopes: scopes, nonce: nonce, completion: callback)
|
|
66
|
-
} else if UserApi.isKakaoTalkLoginAvailable(), !useKakaoAccountLogin {
|
|
67
|
-
UserApi.shared
|
|
68
|
-
.loginWithKakaoTalk(
|
|
69
|
-
serviceTerms: emptyArrayToNil(serviceTerms),
|
|
70
|
-
nonce: nonce,
|
|
71
|
-
completion: callback
|
|
72
|
-
)
|
|
73
|
-
} else {
|
|
63
|
+
let accountLogin = {
|
|
74
64
|
var _prompts: [Prompt] = []
|
|
75
65
|
for p in prompts {
|
|
76
66
|
if p == "Login" {
|
|
@@ -86,13 +76,39 @@ import RNCKakaoCore
|
|
|
86
76
|
_prompts.append(.SelectAccount)
|
|
87
77
|
}
|
|
88
78
|
}
|
|
89
|
-
UserApi.shared
|
|
90
|
-
.
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
79
|
+
UserApi.shared.loginWithKakaoAccount(
|
|
80
|
+
prompts: self.emptyArrayToNil(_prompts),
|
|
81
|
+
serviceTerms: self.emptyArrayToNil(serviceTerms),
|
|
82
|
+
nonce: nonce,
|
|
83
|
+
completion: callback
|
|
84
|
+
)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if !scopes.isEmpty {
|
|
88
|
+
UserApi.shared.loginWithKakaoAccount(scopes: scopes, nonce: nonce, completion: callback)
|
|
89
|
+
} else if UserApi.isKakaoTalkLoginAvailable(), !useKakaoAccountLogin {
|
|
90
|
+
let talkCallback = { (token: OAuthToken?, error: Error?) in
|
|
91
|
+
if let sdkError = error as? SdkError {
|
|
92
|
+
switch sdkError {
|
|
93
|
+
case .ClientFailed(.Cancelled, _),
|
|
94
|
+
.AuthFailed(.AccessDenied, _):
|
|
95
|
+
callback(token, error)
|
|
96
|
+
default:
|
|
97
|
+
accountLogin()
|
|
98
|
+
}
|
|
99
|
+
} else if error != nil || token == nil {
|
|
100
|
+
accountLogin()
|
|
101
|
+
} else {
|
|
102
|
+
callback(token, error)
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
UserApi.shared.loginWithKakaoTalk(
|
|
106
|
+
serviceTerms: emptyArrayToNil(serviceTerms),
|
|
107
|
+
nonce: nonce,
|
|
108
|
+
completion: talkCallback
|
|
109
|
+
)
|
|
110
|
+
} else {
|
|
111
|
+
accountLogin()
|
|
96
112
|
}
|
|
97
113
|
}
|
|
98
114
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-native-kakao/user",
|
|
3
3
|
"description": "React Native Kakao User SDK",
|
|
4
|
-
"version": "3.0.0-next.
|
|
4
|
+
"version": "3.0.0-next.1",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
7
7
|
"types": "lib/typescript/src/index.d.ts",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"access": "public"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@react-native-kakao/core": "3.0.0-next.
|
|
60
|
+
"@react-native-kakao/core": "3.0.0-next.1",
|
|
61
61
|
"@types/invariant": "^2",
|
|
62
62
|
"@types/react": "19.0.0",
|
|
63
63
|
"del-cli": "^5.1.0",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"zx": "8.8.5"
|
|
69
69
|
},
|
|
70
70
|
"peerDependencies": {
|
|
71
|
-
"@react-native-kakao/core": "3.0.0-next.
|
|
71
|
+
"@react-native-kakao/core": "3.0.0-next.1",
|
|
72
72
|
"react": "*",
|
|
73
73
|
"react-native": ">=0.76.0"
|
|
74
74
|
},
|