@react-native-kakao/user 3.1.0-next.0 → 3.1.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 +30 -0
- package/android/src/main/java/net/mjstudio/rnkakao/user/RNCKakaoUserModule.kt +289 -128
- package/ios/RNCKakaoUser.mm +58 -6
- package/ios/RNCKakaoUserManager.swift +211 -43
- package/lib/commonjs/index.js +66 -5
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/index.web.js +106 -5
- package/lib/commonjs/index.web.js.map +1 -1
- package/lib/commonjs/spec/NativeKakaoUser.ts +23 -1
- package/lib/module/index.js +61 -5
- package/lib/module/index.js.map +1 -1
- package/lib/module/index.web.js +101 -5
- package/lib/module/index.web.js.map +1 -1
- package/lib/module/spec/NativeKakaoUser.ts +23 -1
- package/lib/typescript/src/index.d.ts +58 -2
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/spec/NativeKakaoUser.d.ts +8 -2
- package/lib/typescript/src/spec/NativeKakaoUser.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/index.ts +157 -4
- package/src/index.web.ts +123 -7
- package/src/spec/NativeKakaoUser.ts +23 -1
|
@@ -33,6 +33,8 @@ import RNCKakaoCore
|
|
|
33
33
|
useKakaoAccountLogin: Bool,
|
|
34
34
|
scopes: [String],
|
|
35
35
|
nonce: String?,
|
|
36
|
+
loginHint: String?,
|
|
37
|
+
channelPublicIds: [String],
|
|
36
38
|
resolve: @escaping RCTPromiseResolveBlock,
|
|
37
39
|
reject: @escaping RCTPromiseRejectBlock
|
|
38
40
|
) {
|
|
@@ -41,47 +43,25 @@ import RNCKakaoCore
|
|
|
41
43
|
RNCKakaoUtil.reject(reject, RNCKakaoError.sdkNotInitialized)
|
|
42
44
|
return
|
|
43
45
|
}
|
|
44
|
-
let callback =
|
|
45
|
-
if let error {
|
|
46
|
-
RNCKakaoUtil.reject(reject, error)
|
|
47
|
-
} else if let token {
|
|
48
|
-
resolve([
|
|
49
|
-
"accessToken": token.accessToken,
|
|
50
|
-
"refreshToken": token.refreshToken,
|
|
51
|
-
"tokenType": token.tokenType,
|
|
52
|
-
"idToken": token.idToken as Any,
|
|
53
|
-
"accessTokenExpiresAt": token.expiredAt.timeIntervalSince1970,
|
|
54
|
-
"refreshTokenExpiresAt": token.refreshTokenExpiredAt.timeIntervalSince1970,
|
|
55
|
-
"accessTokenExpiresIn": token.expiresIn,
|
|
56
|
-
"refreshTokenExpiresIn": token.refreshTokenExpiresIn,
|
|
57
|
-
"scopes": token.scopes ?? []
|
|
58
|
-
])
|
|
59
|
-
} else {
|
|
60
|
-
RNCKakaoUtil.reject(reject, RNCKakaoError.responseNotFound(name: "token"))
|
|
61
|
-
}
|
|
62
|
-
}
|
|
46
|
+
let callback = tokenCallback(resolve, reject: reject)
|
|
63
47
|
let accountLogin = {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
48
|
+
let _prompts = self.loginPrompts(prompts)
|
|
49
|
+
if let loginHint {
|
|
50
|
+
UserApi.shared.loginWithKakaoAccount(
|
|
51
|
+
prompts: self.emptyArrayToNil(_prompts),
|
|
52
|
+
loginHint: loginHint,
|
|
53
|
+
nonce: nonce,
|
|
54
|
+
completion: callback
|
|
55
|
+
)
|
|
56
|
+
} else {
|
|
57
|
+
UserApi.shared.loginWithKakaoAccount(
|
|
58
|
+
prompts: self.emptyArrayToNil(_prompts),
|
|
59
|
+
channelPublicIds: self.emptyArrayToNil(channelPublicIds),
|
|
60
|
+
serviceTerms: self.emptyArrayToNil(serviceTerms),
|
|
61
|
+
nonce: nonce,
|
|
62
|
+
completion: callback
|
|
63
|
+
)
|
|
78
64
|
}
|
|
79
|
-
UserApi.shared.loginWithKakaoAccount(
|
|
80
|
-
prompts: self.emptyArrayToNil(_prompts),
|
|
81
|
-
serviceTerms: self.emptyArrayToNil(serviceTerms),
|
|
82
|
-
nonce: nonce,
|
|
83
|
-
completion: callback
|
|
84
|
-
)
|
|
85
65
|
}
|
|
86
66
|
|
|
87
67
|
if !scopes.isEmpty {
|
|
@@ -103,6 +83,7 @@ import RNCKakaoCore
|
|
|
103
83
|
}
|
|
104
84
|
}
|
|
105
85
|
UserApi.shared.loginWithKakaoTalk(
|
|
86
|
+
channelPublicIds: emptyArrayToNil(channelPublicIds),
|
|
106
87
|
serviceTerms: emptyArrayToNil(serviceTerms),
|
|
107
88
|
nonce: nonce,
|
|
108
89
|
completion: talkCallback
|
|
@@ -113,6 +94,135 @@ import RNCKakaoCore
|
|
|
113
94
|
}
|
|
114
95
|
}
|
|
115
96
|
|
|
97
|
+
@objc public func loginWithKakao(
|
|
98
|
+
_ uiMode: String,
|
|
99
|
+
orientation: String,
|
|
100
|
+
launchMethod: String,
|
|
101
|
+
prompts: [String],
|
|
102
|
+
loginHint: String?,
|
|
103
|
+
nonce: String?,
|
|
104
|
+
channelPublicIds: [String],
|
|
105
|
+
serviceTerms: [String],
|
|
106
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
107
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
108
|
+
) {
|
|
109
|
+
onMain { [self] in
|
|
110
|
+
guard let _ = try? KakaoSDK.shared.appKey() else {
|
|
111
|
+
RNCKakaoUtil.reject(reject, RNCKakaoError.sdkNotInitialized)
|
|
112
|
+
return
|
|
113
|
+
}
|
|
114
|
+
guard nonce == nil else {
|
|
115
|
+
RNCKakaoUtil.reject(
|
|
116
|
+
reject,
|
|
117
|
+
RNCKakaoError
|
|
118
|
+
.unknown(
|
|
119
|
+
"The Kakao iOS login chooser does not forward nonce for account login. Use login instead."
|
|
120
|
+
)
|
|
121
|
+
)
|
|
122
|
+
return
|
|
123
|
+
}
|
|
124
|
+
UserApi.shared.loginWithKakao(
|
|
125
|
+
BridgeConfiguration(
|
|
126
|
+
orientation: LoginOrientation(rawValue: orientation),
|
|
127
|
+
uiMode: LoginUiMode(rawValue: uiMode)
|
|
128
|
+
),
|
|
129
|
+
loginProperties: LoginConfiguration(
|
|
130
|
+
talk: LoginConfiguration
|
|
131
|
+
.Talk(launchMethod: launchMethod == "CustomScheme" ? .CustomScheme : .UniversalLink),
|
|
132
|
+
account: LoginConfiguration.Account(
|
|
133
|
+
prompts: emptyArrayToNil(loginPrompts(prompts)),
|
|
134
|
+
loginHint: loginHint
|
|
135
|
+
),
|
|
136
|
+
channelPublicIds: emptyArrayToNil(channelPublicIds),
|
|
137
|
+
serviceTerms: emptyArrayToNil(serviceTerms),
|
|
138
|
+
nonce: nonce
|
|
139
|
+
),
|
|
140
|
+
completion: tokenCallback(resolve, reject: reject)
|
|
141
|
+
)
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
@objc public func issueAccessTokenWithCode(
|
|
146
|
+
_ code: String,
|
|
147
|
+
codeVerifier: String?,
|
|
148
|
+
redirectUri: String?,
|
|
149
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
150
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
151
|
+
) {
|
|
152
|
+
onMain { [self] in
|
|
153
|
+
guard let _ = try? KakaoSDK.shared.appKey() else {
|
|
154
|
+
RNCKakaoUtil.reject(reject, RNCKakaoError.sdkNotInitialized)
|
|
155
|
+
return
|
|
156
|
+
}
|
|
157
|
+
AuthApi.shared.token(
|
|
158
|
+
code: code,
|
|
159
|
+
codeVerifier: codeVerifier,
|
|
160
|
+
redirectUri: redirectUri ?? KakaoSDK.shared.redirectUri(),
|
|
161
|
+
completion: tokenCallback(resolve, reject: reject)
|
|
162
|
+
)
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
@objc public func refreshToken(
|
|
167
|
+
_ token: [String: Any]?,
|
|
168
|
+
loggingEnabled: NSNumber?,
|
|
169
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
170
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
171
|
+
) {
|
|
172
|
+
onMain { [self] in
|
|
173
|
+
guard let _ = try? KakaoSDK.shared.appKey() else {
|
|
174
|
+
RNCKakaoUtil.reject(reject, RNCKakaoError.sdkNotInitialized)
|
|
175
|
+
return
|
|
176
|
+
}
|
|
177
|
+
var oldToken: OAuthToken?
|
|
178
|
+
if let token {
|
|
179
|
+
guard let accessToken = token["accessToken"] as? String,
|
|
180
|
+
let refreshToken = token["refreshToken"] as? String,
|
|
181
|
+
let accessTokenExpiresAt = token["accessTokenExpiresAt"] as? Double,
|
|
182
|
+
let refreshTokenExpiresAt = token["refreshTokenExpiresAt"] as? Double,
|
|
183
|
+
let scopes = token["scopes"] as? [String]
|
|
184
|
+
else {
|
|
185
|
+
RNCKakaoUtil.reject(reject, SdkError(reason: .BadParameter))
|
|
186
|
+
return
|
|
187
|
+
}
|
|
188
|
+
let now = Date().timeIntervalSince1970
|
|
189
|
+
oldToken = OAuthToken(
|
|
190
|
+
accessToken: accessToken,
|
|
191
|
+
expiresIn: accessTokenExpiresAt - now,
|
|
192
|
+
expiredAt: Date(timeIntervalSince1970: accessTokenExpiresAt),
|
|
193
|
+
tokenType: token["tokenType"] as? String ?? "bearer",
|
|
194
|
+
refreshToken: refreshToken,
|
|
195
|
+
refreshTokenExpiresIn: refreshTokenExpiresAt - now,
|
|
196
|
+
refreshTokenExpiredAt: Date(timeIntervalSince1970: refreshTokenExpiresAt),
|
|
197
|
+
scope: scopes.isEmpty ? nil : scopes.joined(separator: " "),
|
|
198
|
+
scopes: scopes,
|
|
199
|
+
idToken: token["idToken"] as? String
|
|
200
|
+
)
|
|
201
|
+
}
|
|
202
|
+
AuthApi.shared.refreshToken(
|
|
203
|
+
token: oldToken,
|
|
204
|
+
loggingEnabled: loggingEnabled?.boolValue ?? true,
|
|
205
|
+
completion: tokenCallback(resolve, reject: reject)
|
|
206
|
+
)
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
@objc public func signup(
|
|
211
|
+
_ properties: [String: String]?,
|
|
212
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
213
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
214
|
+
) {
|
|
215
|
+
onMain {
|
|
216
|
+
UserApi.shared.signup(properties: properties) { _, error in
|
|
217
|
+
if let error {
|
|
218
|
+
RNCKakaoUtil.reject(reject, error)
|
|
219
|
+
} else {
|
|
220
|
+
resolve(nil)
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
116
226
|
@objc public func logout(
|
|
117
227
|
_ resolve: @escaping RCTPromiseResolveBlock,
|
|
118
228
|
reject: @escaping RCTPromiseRejectBlock
|
|
@@ -336,17 +446,37 @@ import RNCKakaoCore
|
|
|
336
446
|
}
|
|
337
447
|
}
|
|
338
448
|
|
|
449
|
+
@objc public func updateProfile(
|
|
450
|
+
_ properties: [String: String],
|
|
451
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
452
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
453
|
+
) {
|
|
454
|
+
onMain {
|
|
455
|
+
UserApi.shared.updateProfile(properties: properties) { error in
|
|
456
|
+
if let error {
|
|
457
|
+
RNCKakaoUtil.reject(reject, error)
|
|
458
|
+
} else {
|
|
459
|
+
resolve(nil)
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
|
|
339
465
|
@objc public func me(
|
|
340
|
-
_
|
|
466
|
+
_ secureResource: NSNumber?,
|
|
467
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
341
468
|
reject: @escaping RCTPromiseRejectBlock
|
|
342
469
|
) {
|
|
343
470
|
onMain {
|
|
344
|
-
UserApi.shared.me { user, error in
|
|
471
|
+
UserApi.shared.me(secureResource: secureResource?.boolValue ?? true) { user, error in
|
|
345
472
|
if let error {
|
|
346
473
|
RNCKakaoUtil.reject(reject, error)
|
|
347
474
|
} else if let user {
|
|
348
475
|
resolve([
|
|
349
476
|
"id": user.id as Any,
|
|
477
|
+
"uuid": user.uuid as Any,
|
|
478
|
+
"groupUserToken": user.groupUserToken as Any,
|
|
479
|
+
"hasSignedUp": user.hasSignedUp as Any,
|
|
350
480
|
"connectedAt": user.connectedAt?.timeIntervalSince1970 as Any,
|
|
351
481
|
"synchedAt": user.synchedAt?.timeIntervalSince1970 as Any,
|
|
352
482
|
"name": user.kakaoAccount?.name as Any,
|
|
@@ -355,10 +485,12 @@ import RNCKakaoCore
|
|
|
355
485
|
"profileImageUrl": user.kakaoAccount?.profile?.profileImageUrl?.absoluteString as Any,
|
|
356
486
|
"thumbnailImageUrl": user.kakaoAccount?.profile?.thumbnailImageUrl?
|
|
357
487
|
.absoluteString as Any,
|
|
488
|
+
"isDefaultImage": user.kakaoAccount?.profile?.isDefaultImage as Any,
|
|
358
489
|
"phoneNumber": user.kakaoAccount?.phoneNumber as Any,
|
|
359
490
|
"ageRange": user.kakaoAccount?.ageRange?.rawValue as Any,
|
|
360
491
|
"birthday": user.kakaoAccount?.birthday as Any,
|
|
361
|
-
"birthdayType": user.kakaoAccount?.birthdayType as Any,
|
|
492
|
+
"birthdayType": user.kakaoAccount?.birthdayType?.rawValue as Any,
|
|
493
|
+
"isLeapMonth": user.kakaoAccount?.isLeapMonth as Any,
|
|
362
494
|
"birthyear": user.kakaoAccount?.birthyear as Any,
|
|
363
495
|
"gender": user.kakaoAccount?.gender?.rawValue as Any,
|
|
364
496
|
"isEmailValid": user.kakaoAccount?.isEmailValid as Any,
|
|
@@ -376,7 +508,12 @@ import RNCKakaoCore
|
|
|
376
508
|
"profileImageNeedsAgreement": user.kakaoAccount?.profileImageNeedsAgreement as Any,
|
|
377
509
|
"profileNicknameNeedsAgreement": user.kakaoAccount?
|
|
378
510
|
.profileNicknameNeedsAgreement as Any,
|
|
379
|
-
"
|
|
511
|
+
"legalName": user.kakaoAccount?.legalName as Any,
|
|
512
|
+
"legalNameNeedsAgreement": user.kakaoAccount?.legalNameNeedsAgreement as Any,
|
|
513
|
+
"legalBirthDate": user.kakaoAccount?.legalBirthDate as Any,
|
|
514
|
+
"legalBirthDateNeedsAgreement": user.kakaoAccount?.legalBirthDateNeedsAgreement as Any,
|
|
515
|
+
"legalGender": user.kakaoAccount?.legalGender?.rawValue as Any,
|
|
516
|
+
"legalGenderNeedsAgreement": user.kakaoAccount?.legalGenderNeedsAgreement as Any
|
|
380
517
|
])
|
|
381
518
|
} else {
|
|
382
519
|
RNCKakaoUtil.reject(reject, RNCKakaoError.responseNotFound(name: "user"))
|
|
@@ -406,6 +543,37 @@ import RNCKakaoCore
|
|
|
406
543
|
}
|
|
407
544
|
}
|
|
408
545
|
|
|
546
|
+
private func loginPrompts(_ prompts: [String]) -> [Prompt] {
|
|
547
|
+
prompts
|
|
548
|
+
.compactMap { Prompt(rawValue: $0 == "SelectAccount" ? "select_account" : $0.lowercased()) }
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
private func tokenCallback(
|
|
552
|
+
_ resolve: @escaping RCTPromiseResolveBlock,
|
|
553
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
554
|
+
) -> (OAuthToken?, Error?) -> Void {
|
|
555
|
+
{ (token: OAuthToken?, error: Error?) in
|
|
556
|
+
if let error {
|
|
557
|
+
RNCKakaoUtil.reject(reject, error)
|
|
558
|
+
} else if let token {
|
|
559
|
+
let now = Date()
|
|
560
|
+
resolve([
|
|
561
|
+
"accessToken": token.accessToken,
|
|
562
|
+
"refreshToken": token.refreshToken,
|
|
563
|
+
"tokenType": token.tokenType,
|
|
564
|
+
"idToken": token.idToken as Any,
|
|
565
|
+
"accessTokenExpiresAt": token.expiredAt.timeIntervalSince1970,
|
|
566
|
+
"refreshTokenExpiresAt": token.refreshTokenExpiredAt.timeIntervalSince1970,
|
|
567
|
+
"accessTokenExpiresIn": Int(token.expiredAt.timeIntervalSince(now)),
|
|
568
|
+
"refreshTokenExpiresIn": Int(token.refreshTokenExpiredAt.timeIntervalSince(now)),
|
|
569
|
+
"scopes": token.scopes ?? []
|
|
570
|
+
])
|
|
571
|
+
} else {
|
|
572
|
+
RNCKakaoUtil.reject(reject, RNCKakaoError.responseNotFound(name: "token"))
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
|
|
409
577
|
private func emptyArrayToNil<T>(_ arr: [T]?) -> [T]? {
|
|
410
578
|
if arr == nil || arr?.isEmpty == true {
|
|
411
579
|
return nil
|
package/lib/commonjs/index.js
CHANGED
|
@@ -8,10 +8,13 @@ exports.getAccessToken = getAccessToken;
|
|
|
8
8
|
exports.hasToken = void 0;
|
|
9
9
|
exports.isKakaoTalkLoginAvailable = isKakaoTalkLoginAvailable;
|
|
10
10
|
exports.isLogined = isLogined;
|
|
11
|
+
exports.issueAccessTokenWithCode = issueAccessTokenWithCode;
|
|
11
12
|
exports.issueAccessTokenWithCodeWeb = issueAccessTokenWithCodeWeb;
|
|
12
13
|
exports.login = login;
|
|
14
|
+
exports.loginWithKakao = loginWithKakao;
|
|
13
15
|
exports.logout = logout;
|
|
14
16
|
exports.me = me;
|
|
17
|
+
exports.refreshToken = refreshToken;
|
|
15
18
|
exports.revokeScopes = revokeScopes;
|
|
16
19
|
exports.revokeServiceTerms = revokeServiceTerms;
|
|
17
20
|
exports.scopes = scopes;
|
|
@@ -19,22 +22,60 @@ exports.selectShippingAddress = selectShippingAddress;
|
|
|
19
22
|
exports.serviceTerms = serviceTerms;
|
|
20
23
|
exports.setAccessTokenWeb = setAccessTokenWeb;
|
|
21
24
|
exports.shippingAddresses = shippingAddresses;
|
|
25
|
+
exports.signup = signup;
|
|
22
26
|
exports.unlink = unlink;
|
|
27
|
+
exports.updateProfile = updateProfile;
|
|
23
28
|
var _jsUtil = require("@mj-studio/js-util");
|
|
24
29
|
var _core = require("@react-native-kakao/core");
|
|
25
30
|
var _NativeKakaoUser = _interopRequireDefault(require("./spec/NativeKakaoUser"));
|
|
26
31
|
var _validateShippingAddressOptions = require("./validateShippingAddressOptions");
|
|
27
32
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
33
|
+
const minActivityRequestCode = -2147483648;
|
|
34
|
+
const maxActivityRequestCode = 2147483647;
|
|
28
35
|
function login({
|
|
29
36
|
serviceTerms,
|
|
30
37
|
prompts,
|
|
31
38
|
useKakaoAccountLogin,
|
|
32
39
|
scopes,
|
|
33
|
-
nonce
|
|
40
|
+
nonce,
|
|
41
|
+
loginHint,
|
|
42
|
+
channelPublicIds,
|
|
43
|
+
android
|
|
34
44
|
} = {}) {
|
|
45
|
+
const requestCode = android?.requestCode;
|
|
46
|
+
(0, _core.kAssert)(requestCode == null || Number.isInteger(requestCode) && requestCode >= minActivityRequestCode && requestCode <= maxActivityRequestCode, `[login] android.requestCode must be an integer from ${minActivityRequestCode} to ${maxActivityRequestCode}`);
|
|
35
47
|
(0, _core.kAssert)(!useKakaoAccountLogin ? !_jsUtil.is.notEmptyArray(prompts) && !_jsUtil.is.notEmptyArray(scopes) : true, '[login] `prompts` and `scopes` cannot be passed if useKakaoAccountLogin is false.');
|
|
36
|
-
(0, _core.kAssert)(_jsUtil.is.notEmptyArray(scopes) ? !_jsUtil.is.notEmptyArray(prompts) && !_jsUtil.is.notEmptyArray(serviceTerms) : true, '[login] `scopes` cannot be passed with `prompts` or `
|
|
37
|
-
|
|
48
|
+
(0, _core.kAssert)(_jsUtil.is.notEmptyArray(scopes) ? !_jsUtil.is.notEmptyArray(prompts) && !_jsUtil.is.notEmptyArray(serviceTerms) && !_jsUtil.is.notEmptyArray(channelPublicIds) : true, '[login] `scopes` cannot be passed with `prompts`, `serviceTerms`, or `channelPublicIds`');
|
|
49
|
+
(0, _core.kAssert)(loginHint == null || !_jsUtil.is.notEmptyArray(scopes) && !_jsUtil.is.notEmptyArray(serviceTerms) && !_jsUtil.is.notEmptyArray(channelPublicIds), '[login] `loginHint` cannot be passed with `scopes`, `serviceTerms`, or `channelPublicIds` on native platforms.');
|
|
50
|
+
return _NativeKakaoUser.default.login(serviceTerms ?? [], prompts ?? [], useKakaoAccountLogin ?? false, scopes ?? [], nonce, loginHint, channelPublicIds ?? [], requestCode);
|
|
51
|
+
}
|
|
52
|
+
async function signup({
|
|
53
|
+
properties
|
|
54
|
+
} = {}) {
|
|
55
|
+
await _NativeKakaoUser.default.signup(properties);
|
|
56
|
+
}
|
|
57
|
+
function loginWithKakao({
|
|
58
|
+
uiMode = 'auto',
|
|
59
|
+
prompts,
|
|
60
|
+
loginHint,
|
|
61
|
+
nonce,
|
|
62
|
+
channelPublicIds,
|
|
63
|
+
serviceTerms,
|
|
64
|
+
ios
|
|
65
|
+
} = {}) {
|
|
66
|
+
return _NativeKakaoUser.default.loginWithKakao(uiMode, ios?.orientation ?? 'auto', ios?.launchMethod ?? 'UniversalLink', prompts ?? [], loginHint, nonce, channelPublicIds ?? [], serviceTerms ?? []);
|
|
67
|
+
}
|
|
68
|
+
function refreshToken({
|
|
69
|
+
token,
|
|
70
|
+
ios
|
|
71
|
+
} = {}) {
|
|
72
|
+
(0, _core.kAssert)(ios?.loggingEnabled == null || typeof ios.loggingEnabled === 'boolean', '[refreshToken] ios.loggingEnabled must be a boolean');
|
|
73
|
+
if (token !== undefined) {
|
|
74
|
+
(0, _core.kAssert)(token != null && _jsUtil.is.string(token.accessToken) && token.accessToken.length > 0 && _jsUtil.is.string(token.refreshToken) && token.refreshToken.length > 0, '[refreshToken] token must contain non-empty accessToken and refreshToken strings');
|
|
75
|
+
(0, _core.kAssert)([token.accessTokenExpiresAt, token.refreshTokenExpiresAt].every(value => Number.isFinite(value) && !Number.isNaN(new Date(value * 1000).getTime())) && [token.accessTokenExpiresIn, token.refreshTokenExpiresIn].every(Number.isFinite), '[refreshToken] token expiry timestamps must be valid Unix seconds and lifetimes must be finite');
|
|
76
|
+
(0, _core.kAssert)((token.tokenType == null || _jsUtil.is.string(token.tokenType)) && (token.idToken == null || _jsUtil.is.string(token.idToken)) && Array.isArray(token.scopes) && token.scopes.every(scope => _jsUtil.is.string(scope)), '[refreshToken] tokenType and idToken must be strings when present, and scopes must be strings');
|
|
77
|
+
}
|
|
78
|
+
return _NativeKakaoUser.default.refreshToken(token, ios?.loggingEnabled ?? true);
|
|
38
79
|
}
|
|
39
80
|
function logout() {
|
|
40
81
|
return _NativeKakaoUser.default.logout();
|
|
@@ -79,12 +120,27 @@ function revokeServiceTerms(tags) {
|
|
|
79
120
|
function selectShippingAddress() {
|
|
80
121
|
return _NativeKakaoUser.default.selectShippingAddress();
|
|
81
122
|
}
|
|
82
|
-
function me(
|
|
83
|
-
|
|
123
|
+
function me({
|
|
124
|
+
secureResource = true
|
|
125
|
+
} = {}) {
|
|
126
|
+
return _NativeKakaoUser.default.me(secureResource);
|
|
127
|
+
}
|
|
128
|
+
async function issueAccessTokenWithCode({
|
|
129
|
+
code,
|
|
130
|
+
codeVerifier,
|
|
131
|
+
redirectUri
|
|
132
|
+
}) {
|
|
133
|
+
(0, _core.kAssert)(_jsUtil.is.string(code) && code.length > 0, '[issueAccessTokenWithCode] code is required');
|
|
134
|
+
return _NativeKakaoUser.default.issueAccessTokenWithCode(code, codeVerifier, redirectUri);
|
|
84
135
|
}
|
|
85
136
|
function getAccessToken() {
|
|
86
137
|
return _NativeKakaoUser.default.getAccessToken();
|
|
87
138
|
}
|
|
139
|
+
function updateProfile({
|
|
140
|
+
properties
|
|
141
|
+
}) {
|
|
142
|
+
return _NativeKakaoUser.default.updateProfile(properties);
|
|
143
|
+
}
|
|
88
144
|
|
|
89
145
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
90
146
|
function setAccessTokenWeb(token) {}
|
|
@@ -94,6 +150,10 @@ async function issueAccessTokenWithCodeWeb(params) {
|
|
|
94
150
|
}
|
|
95
151
|
const KakaoUser = {
|
|
96
152
|
login,
|
|
153
|
+
loginWithKakao,
|
|
154
|
+
refreshToken,
|
|
155
|
+
issueAccessTokenWithCode,
|
|
156
|
+
signup,
|
|
97
157
|
logout,
|
|
98
158
|
unlink,
|
|
99
159
|
isLogined,
|
|
@@ -106,6 +166,7 @@ const KakaoUser = {
|
|
|
106
166
|
shippingAddresses,
|
|
107
167
|
selectShippingAddress,
|
|
108
168
|
me,
|
|
169
|
+
updateProfile,
|
|
109
170
|
getAccessToken,
|
|
110
171
|
setAccessTokenWeb,
|
|
111
172
|
issueAccessTokenWithCodeWeb
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_jsUtil","require","_core","_NativeKakaoUser","_interopRequireDefault","_validateShippingAddressOptions","e","__esModule","default","login","serviceTerms","prompts","useKakaoAccountLogin","scopes","nonce","kAssert","is","notEmptyArray","Native","logout","unlink","isLogined","hasToken","exports","isKakaoTalkLoginAvailable","revokeScopes","result","tags","shippingAddresses","addressId","fromUpdatedAt","pageSize","validateShippingAddressOptions","revokeServiceTerms","selectShippingAddress","me","getAccessToken","
|
|
1
|
+
{"version":3,"names":["_jsUtil","require","_core","_NativeKakaoUser","_interopRequireDefault","_validateShippingAddressOptions","e","__esModule","default","minActivityRequestCode","maxActivityRequestCode","login","serviceTerms","prompts","useKakaoAccountLogin","scopes","nonce","loginHint","channelPublicIds","android","requestCode","kAssert","Number","isInteger","is","notEmptyArray","Native","signup","properties","loginWithKakao","uiMode","ios","orientation","launchMethod","refreshToken","token","loggingEnabled","undefined","string","accessToken","length","accessTokenExpiresAt","refreshTokenExpiresAt","every","value","isFinite","isNaN","Date","getTime","accessTokenExpiresIn","refreshTokenExpiresIn","tokenType","idToken","Array","isArray","scope","logout","unlink","isLogined","hasToken","exports","isKakaoTalkLoginAvailable","revokeScopes","result","tags","shippingAddresses","addressId","fromUpdatedAt","pageSize","validateShippingAddressOptions","revokeServiceTerms","selectShippingAddress","me","secureResource","issueAccessTokenWithCode","code","codeVerifier","redirectUri","getAccessToken","updateProfile","setAccessTokenWeb","issueAccessTokenWithCodeWeb","params","KakaoUser","_default"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";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,cAAc,CAAC;AAClC;AAEO,eAAeC,wBAAwBA,CAAC;EAC7CC,IAAI;EACJC,YAAY;EACZC;AACqB,CAAC,EAA4B;EAClD,IAAAxD,aAAO,EAACG,UAAE,CAACc,MAAM,CAACqC,IAAI,CAAC,IAAIA,IAAI,CAACnC,MAAM,GAAG,CAAC,EAAE,6CAA6C,CAAC;EAE1F,OAAOd,wBAAM,CAACgD,wBAAwB,CAACC,IAAI,EAAEC,YAAY,EAAEC,WAAW,CAAC;AACzE;AAEO,SAASC,cAAcA,CAAA,EAAkC;EAC9D,OAAOpD,wBAAM,CAACoD,cAAc,CAAC,CAAC;AAChC;AAEO,SAASC,aAAaA,CAAC;EAC5BnD;AAGF,CAAC,EAAiB;EAChB,OAAOF,wBAAM,CAACqD,aAAa,CAACnD,UAAU,CAAC;AACzC;;AAEA;AACO,SAASoD,iBAAiBA,CAAC7C,KAAa,EAAE,CAAC;AAClD;AACO,eAAe8C,2BAA2BA,CAACC,MAKjD,EAQE;EACD,OAAO,CAAC,CAAC;AACX;AAEA,MAAMC,SAAS,GAAG;EAChBxE,KAAK;EACLkB,cAAc;EACdK,YAAY;EACZwC,wBAAwB;EACxB/C,MAAM;EACN6B,MAAM;EACNC,MAAM;EACNC,SAAS;EACTC,QAAQ;EACRE,yBAAyB;EACzB9C,MAAM;EACN+C,YAAY;EACZlD,YAAY;EACZ0D,kBAAkB;EAClBL,iBAAiB;EACjBM,qBAAqB;EACrBC,EAAE;EACFO,aAAa;EACbD,cAAc;EACdE,iBAAiB;EACjBC;AACF,CAAC;AAAC,IAAAG,QAAA,GAAAxB,OAAA,CAAApD,OAAA,GACa2E,SAAS","ignoreList":[]}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.unlink = exports.shippingAddresses = exports.setAccessTokenWeb = exports.serviceTerms = exports.selectShippingAddress = exports.scopes = exports.revokeServiceTerms = exports.revokeScopes = exports.me = exports.logout = exports.login = exports.issueAccessTokenWithCodeWeb = exports.isLogined = exports.isKakaoTalkLoginAvailable = exports.hasToken = exports.getAccessToken = exports.default = void 0;
|
|
6
|
+
exports.updateProfile = exports.unlink = exports.signup = exports.shippingAddresses = exports.setAccessTokenWeb = exports.serviceTerms = exports.selectShippingAddress = exports.scopes = exports.revokeServiceTerms = exports.revokeScopes = exports.refreshToken = exports.me = exports.logout = exports.loginWithKakao = exports.login = exports.issueAccessTokenWithCodeWeb = exports.issueAccessTokenWithCode = exports.isLogined = exports.isKakaoTalkLoginAvailable = exports.hasToken = exports.getAccessToken = exports.default = void 0;
|
|
7
7
|
var _jsUtil = require("@mj-studio/js-util");
|
|
8
8
|
var _core = require("@react-native-kakao/core");
|
|
9
9
|
var _validateShippingAddressOptions = require("./validateShippingAddressOptions");
|
|
@@ -14,6 +14,18 @@ function isoToUnix(value) {
|
|
|
14
14
|
return Date.parse(value) / 1000;
|
|
15
15
|
}
|
|
16
16
|
const KakaoUser = {
|
|
17
|
+
loginWithKakao: () => (0, _core.kRunWebAPI)(() => {
|
|
18
|
+
throw {
|
|
19
|
+
code: 'Package-UnsupportedPlatform',
|
|
20
|
+
message: 'loginWithKakao is supported on Android and iOS. Use login with web.redirectUri on web.'
|
|
21
|
+
};
|
|
22
|
+
}),
|
|
23
|
+
refreshToken: () => (0, _core.kRunWebAPI)(() => {
|
|
24
|
+
throw {
|
|
25
|
+
code: 'Package-UnsupportedPlatform',
|
|
26
|
+
message: 'The Kakao JavaScript SDK does not support refreshToken.'
|
|
27
|
+
};
|
|
28
|
+
}),
|
|
17
29
|
hasToken: () => (0, _core.kRunWebAPI)(() => Kakao.Auth.getAccessToken() != null),
|
|
18
30
|
getAccessToken: () => (0, _core.kRunWebAPI)(async () => {
|
|
19
31
|
const {
|
|
@@ -29,9 +41,49 @@ const KakaoUser = {
|
|
|
29
41
|
appId: app_id
|
|
30
42
|
};
|
|
31
43
|
}),
|
|
44
|
+
issueAccessTokenWithCode: ({
|
|
45
|
+
code,
|
|
46
|
+
codeVerifier,
|
|
47
|
+
redirectUri,
|
|
48
|
+
web
|
|
49
|
+
}) => (0, _core.kRunWebAPI)(async () => {
|
|
50
|
+
(0, _core.kAssert)(_jsUtil.is.string(code) && code.length > 0 && _jsUtil.is.string(redirectUri) && redirectUri.length > 0, '[issueAccessTokenWithCode] code and redirectUri are required on web');
|
|
51
|
+
if (typeof Kakao === 'undefined' || !Kakao.isInitialized()) {
|
|
52
|
+
(0, _core.kCreateWebError)({
|
|
53
|
+
code: 'Package-SDKNotInitialized',
|
|
54
|
+
message: 'Initialize the Kakao SDK before exchanging an authorization code.'
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
const token = await KakaoUser.issueAccessTokenWithCodeWeb({
|
|
58
|
+
code,
|
|
59
|
+
codeVerifier,
|
|
60
|
+
redirectUri: redirectUri,
|
|
61
|
+
clientSecret: web?.clientSecret
|
|
62
|
+
});
|
|
63
|
+
if (!_jsUtil.is.string(token.accessToken) || !token.accessToken || !_jsUtil.is.string(token.refreshToken) || !token.refreshToken || !_jsUtil.is.string(token.tokenType) || token.idToken != null && !_jsUtil.is.string(token.idToken) || !Number.isFinite(token.expiresIn) || token.expiresIn < 0 || !Number.isFinite(token.refreshTokenExpiresIn) || token.refreshTokenExpiresIn < 0 || token.scope != null && !_jsUtil.is.string(token.scope)) {
|
|
64
|
+
(0, _core.kCreateWebError)({
|
|
65
|
+
code: 'Package-APIResponseNotFound',
|
|
66
|
+
message: 'issueAccessTokenWithCode returned invalid token data.'
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
const issuedAt = Math.floor(Date.now() / 1000);
|
|
70
|
+
KakaoUser.setAccessTokenWeb(token.accessToken);
|
|
71
|
+
return {
|
|
72
|
+
accessToken: token.accessToken,
|
|
73
|
+
refreshToken: token.refreshToken,
|
|
74
|
+
tokenType: token.tokenType,
|
|
75
|
+
idToken: token.idToken,
|
|
76
|
+
accessTokenExpiresIn: token.expiresIn,
|
|
77
|
+
refreshTokenExpiresIn: token.refreshTokenExpiresIn,
|
|
78
|
+
accessTokenExpiresAt: issuedAt + token.expiresIn,
|
|
79
|
+
refreshTokenExpiresAt: issuedAt + token.refreshTokenExpiresIn,
|
|
80
|
+
scopes: token.scope?.split(' ').filter(Boolean) ?? []
|
|
81
|
+
};
|
|
82
|
+
}),
|
|
32
83
|
issueAccessTokenWithCodeWeb: ({
|
|
33
84
|
clientSecret,
|
|
34
85
|
code,
|
|
86
|
+
codeVerifier,
|
|
35
87
|
redirectUri
|
|
36
88
|
}) => (0, _core.kRunWebAPI)(async () => {
|
|
37
89
|
const res = await (0, _core.kFetchFormUrlEncoded)('https://kauth.kakao.com/oauth/token', {
|
|
@@ -41,6 +93,7 @@ const KakaoUser = {
|
|
|
41
93
|
client_id: _core.kGlobalStorage.restApiKey,
|
|
42
94
|
redirect_uri: redirectUri,
|
|
43
95
|
code,
|
|
96
|
+
code_verifier: codeVerifier,
|
|
44
97
|
client_secret: clientSecret
|
|
45
98
|
})
|
|
46
99
|
}).then(r => r.body);
|
|
@@ -61,8 +114,10 @@ const KakaoUser = {
|
|
|
61
114
|
throughTalk,
|
|
62
115
|
serviceTerms
|
|
63
116
|
} = params?.web ?? {};
|
|
117
|
+
const channelPublicIds = params?.channelPublicIds;
|
|
64
118
|
return Kakao.Auth.authorize((0, _jsUtil.filterNonNullishKeys)({
|
|
65
|
-
loginHint,
|
|
119
|
+
loginHint: params?.loginHint ?? loginHint,
|
|
120
|
+
channelPublicId: channelPublicIds?.length ? channelPublicIds.join(',') : undefined,
|
|
66
121
|
nonce: params?.nonce ?? nonce,
|
|
67
122
|
prompt: (prompt ?? params?.prompts?.map(value => value === 'SelectAccount' ? 'select_account' : value.toLowerCase()))?.join(','),
|
|
68
123
|
redirectUri,
|
|
@@ -72,6 +127,16 @@ const KakaoUser = {
|
|
|
72
127
|
throughTalk: throughTalk ?? (params?.useKakaoAccountLogin ? false : undefined)
|
|
73
128
|
}));
|
|
74
129
|
}),
|
|
130
|
+
signup: ({
|
|
131
|
+
properties
|
|
132
|
+
} = {}) => (0, _core.kRunWebAPI)(async () => {
|
|
133
|
+
await Kakao.API.request({
|
|
134
|
+
url: '/v1/user/signup',
|
|
135
|
+
data: (0, _jsUtil.filterNonNullishKeys)({
|
|
136
|
+
properties
|
|
137
|
+
})
|
|
138
|
+
});
|
|
139
|
+
}),
|
|
75
140
|
logout: () => (0, _core.kRunWebAPI)(async () => {
|
|
76
141
|
try {
|
|
77
142
|
await Kakao.Auth.logout();
|
|
@@ -191,15 +256,42 @@ const KakaoUser = {
|
|
|
191
256
|
throw error;
|
|
192
257
|
}
|
|
193
258
|
}),
|
|
194
|
-
|
|
259
|
+
updateProfile: ({
|
|
260
|
+
properties
|
|
261
|
+
}) => (0, _core.kRunWebAPI)(async () => {
|
|
262
|
+
await Kakao.API.request({
|
|
263
|
+
url: '/v1/user/update_profile',
|
|
264
|
+
data: {
|
|
265
|
+
properties
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
}),
|
|
269
|
+
me: ({
|
|
270
|
+
secureResource = true
|
|
271
|
+
} = {}) => (0, _core.kRunWebAPI)(async () => {
|
|
195
272
|
const ret = (0, _jsUtil.camelCaseObject)(await Kakao.API.request({
|
|
196
|
-
url: '/v2/user/me'
|
|
273
|
+
url: '/v2/user/me',
|
|
274
|
+
data: {
|
|
275
|
+
secure_resource: secureResource
|
|
276
|
+
}
|
|
197
277
|
}));
|
|
198
278
|
const kakaoAccount = ret.kakaoAccount ?? {};
|
|
199
279
|
const properties = ret.properties ?? {};
|
|
200
280
|
const profile = kakaoAccount.profile ?? {};
|
|
281
|
+
const legalGender = kakaoAccount.legalGender;
|
|
201
282
|
return {
|
|
202
283
|
id: ret.id,
|
|
284
|
+
hasSignedUp: ret.hasSignedUp ?? null,
|
|
285
|
+
uuid: ret.forPartner?.uuid ?? null,
|
|
286
|
+
groupUserToken: ret.groupUserToken ?? null,
|
|
287
|
+
isDefaultImage: profile.isDefaultImage ?? null,
|
|
288
|
+
isLeapMonth: kakaoAccount.isLeapMonth ?? null,
|
|
289
|
+
legalName: kakaoAccount.legalName ?? null,
|
|
290
|
+
legalNameNeedsAgreement: kakaoAccount.legalNameNeedsAgreement ?? null,
|
|
291
|
+
legalBirthDate: kakaoAccount.legalBirthDate ?? null,
|
|
292
|
+
legalBirthDateNeedsAgreement: kakaoAccount.legalBirthDateNeedsAgreement,
|
|
293
|
+
legalGender: legalGender === 'female' || legalGender === 'male' ? legalGender : null,
|
|
294
|
+
legalGenderNeedsAgreement: kakaoAccount.legalGenderNeedsAgreement ?? null,
|
|
203
295
|
email: kakaoAccount.email,
|
|
204
296
|
name: kakaoAccount.name,
|
|
205
297
|
nickname: profile.nickname ?? properties.nickname,
|
|
@@ -225,19 +317,23 @@ const KakaoUser = {
|
|
|
225
317
|
nameNeedsAgreement: kakaoAccount.nameNeedsAgreement,
|
|
226
318
|
profileImageNeedsAgreement: kakaoAccount.profileImageNeedsAgreement,
|
|
227
319
|
profileNicknameNeedsAgreement: kakaoAccount.profileNicknameNeedsAgreement,
|
|
228
|
-
legalBirthDateNeedsAgreement: kakaoAccount.legalBirthDateNeedsAgreement,
|
|
229
320
|
connectedAt: isoToUnix(ret.connectedAt),
|
|
230
321
|
synchedAt: isoToUnix(ret.synchedAt)
|
|
231
322
|
};
|
|
232
323
|
})
|
|
233
324
|
};
|
|
234
325
|
const {
|
|
326
|
+
loginWithKakao,
|
|
327
|
+
refreshToken,
|
|
328
|
+
issueAccessTokenWithCode,
|
|
235
329
|
isKakaoTalkLoginAvailable,
|
|
236
330
|
isLogined,
|
|
237
331
|
hasToken,
|
|
238
332
|
login,
|
|
333
|
+
signup,
|
|
239
334
|
logout,
|
|
240
335
|
me,
|
|
336
|
+
updateProfile,
|
|
241
337
|
revokeScopes,
|
|
242
338
|
scopes,
|
|
243
339
|
serviceTerms,
|
|
@@ -259,11 +355,16 @@ exports.revokeServiceTerms = revokeServiceTerms;
|
|
|
259
355
|
exports.serviceTerms = serviceTerms;
|
|
260
356
|
exports.scopes = scopes;
|
|
261
357
|
exports.revokeScopes = revokeScopes;
|
|
358
|
+
exports.updateProfile = updateProfile;
|
|
262
359
|
exports.me = me;
|
|
263
360
|
exports.logout = logout;
|
|
361
|
+
exports.signup = signup;
|
|
264
362
|
exports.login = login;
|
|
265
363
|
exports.hasToken = hasToken;
|
|
266
364
|
exports.isLogined = isLogined;
|
|
267
365
|
exports.isKakaoTalkLoginAvailable = isKakaoTalkLoginAvailable;
|
|
366
|
+
exports.issueAccessTokenWithCode = issueAccessTokenWithCode;
|
|
367
|
+
exports.refreshToken = refreshToken;
|
|
368
|
+
exports.loginWithKakao = loginWithKakao;
|
|
268
369
|
var _default = exports.default = KakaoUser;
|
|
269
370
|
//# sourceMappingURL=index.web.js.map
|