@react-native-kakao/user 2.2.3 → 2.2.5

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.
@@ -29,83 +29,87 @@ import net.mjstudio.rnkakao.core.util.rejectWith
29
29
  import net.mjstudio.rnkakao.core.util.unix
30
30
  import java.util.Date
31
31
 
32
- class RNCKakaoUserModule internal constructor(context: ReactApplicationContext) :
33
- KakaoUserSpec(context) {
34
- override fun getName(): String {
35
- return NAME
36
- }
32
+ class RNCKakaoUserModule internal constructor(
33
+ context: ReactApplicationContext,
34
+ ) : KakaoUserSpec(context) {
35
+ override fun getName(): String = NAME
37
36
 
38
- @ReactMethod
39
- override fun login(
40
- serviceTerms: ReadableArray?,
41
- prompts: ReadableArray?,
42
- useKakaoAccountLogin: Boolean,
43
- scopes: ReadableArray?,
44
- promise: Promise,
45
- ) = onMain {
46
- val context =
47
- currentActivity ?: run {
48
- promise.rejectWith(ActivityNotFoundException())
49
- return@onMain
50
- }
51
- val callback: (OAuthToken?, Throwable?) -> Unit = { token, error ->
52
- if (error != null) {
53
- promise.rejectWith(error)
54
- } else if (token == null) {
55
- promise.rejectWith(RNCKakaoResponseNotFoundException("token"))
56
- } else {
57
- promise.resolve(
58
- argMap().apply {
59
- putString("accessToken", token.accessToken)
60
- putString("refreshToken", token.refreshToken)
61
- putString("tokenType", null)
62
- putString("idToken", token.idToken)
63
- putDouble(
64
- "accessTokenExpiresAt",
65
- token.accessTokenExpiresAt.unix.toDouble(),
66
- )
67
- putDouble(
68
- "refreshTokenExpiresAt",
69
- token.refreshTokenExpiresAt.unix.toDouble(),
70
- )
71
- putDouble(
72
- "accessTokenExpiresIn",
73
- RNCKakaoUtil.diffSec(token.accessTokenExpiresAt, Date()).toDouble(),
74
- )
75
- putDouble(
76
- "refreshTokenExpiresIn",
77
- RNCKakaoUtil.diffSec(token.refreshTokenExpiresAt, Date()).toDouble(),
78
- )
79
- putArray(
80
- "scopes",
81
- argArr().apply {
82
- pushStringList(token.scopes ?: listOf())
83
- },
84
- )
85
- },
86
- )
87
- }
37
+ @ReactMethod
38
+ override fun login(
39
+ serviceTerms: ReadableArray?,
40
+ prompts: ReadableArray?,
41
+ useKakaoAccountLogin: Boolean,
42
+ scopes: ReadableArray?,
43
+ promise: Promise,
44
+ ) = onMain {
45
+ val context =
46
+ currentActivity ?: run {
47
+ promise.rejectWith(ActivityNotFoundException())
48
+ return@onMain
88
49
  }
89
-
90
- if (scopes?.filterIsInstance<String>()?.isEmpty() == false) {
91
- UserApiClient.instance.loginWithNewScopes(
92
- context,
93
- scopes = scopes.filterIsInstance<String>(),
94
- callback = callback,
95
- )
96
- } else if (UserApiClient.instance.isKakaoTalkLoginAvailable(context) && !useKakaoAccountLogin && scopes?.filterIsInstance<String>()
97
- ?.isEmpty() == true
98
- ) {
99
- UserApiClient.instance.loginWithKakaoTalk(
100
- context,
101
- serviceTerms = serviceTerms?.filterIsInstance<String>()?.ifEmpty { null },
102
- callback = callback,
103
- )
50
+ val callback: (OAuthToken?, Throwable?) -> Unit = { token, error ->
51
+ if (error != null) {
52
+ promise.rejectWith(error)
53
+ } else if (token == null) {
54
+ promise.rejectWith(RNCKakaoResponseNotFoundException("token"))
104
55
  } else {
105
- UserApiClient.instance.loginWithKakaoAccount(
106
- context,
107
- prompts =
108
- prompts?.filterIsInstance<String>()?.mapNotNull {
56
+ promise.resolve(
57
+ argMap().apply {
58
+ putString("accessToken", token.accessToken)
59
+ putString("refreshToken", token.refreshToken)
60
+ putString("tokenType", null)
61
+ putString("idToken", token.idToken)
62
+ putDouble(
63
+ "accessTokenExpiresAt",
64
+ token.accessTokenExpiresAt.unix.toDouble(),
65
+ )
66
+ putDouble(
67
+ "refreshTokenExpiresAt",
68
+ token.refreshTokenExpiresAt.unix.toDouble(),
69
+ )
70
+ putDouble(
71
+ "accessTokenExpiresIn",
72
+ RNCKakaoUtil.diffSec(token.accessTokenExpiresAt, Date()).toDouble(),
73
+ )
74
+ putDouble(
75
+ "refreshTokenExpiresIn",
76
+ RNCKakaoUtil.diffSec(token.refreshTokenExpiresAt, Date()).toDouble(),
77
+ )
78
+ putArray(
79
+ "scopes",
80
+ argArr().apply {
81
+ pushStringList(token.scopes ?: listOf())
82
+ },
83
+ )
84
+ },
85
+ )
86
+ }
87
+ }
88
+
89
+ if (scopes?.filterIsInstance<String>()?.isEmpty() == false) {
90
+ UserApiClient.instance.loginWithNewScopes(
91
+ context,
92
+ scopes = scopes.filterIsInstance<String>(),
93
+ callback = callback,
94
+ )
95
+ } else if (UserApiClient.instance.isKakaoTalkLoginAvailable(context) &&
96
+ !useKakaoAccountLogin &&
97
+ scopes
98
+ ?.filterIsInstance<String>()
99
+ ?.isEmpty() == true
100
+ ) {
101
+ UserApiClient.instance.loginWithKakaoTalk(
102
+ context,
103
+ serviceTerms = serviceTerms?.filterIsInstance<String>()?.ifEmpty { null },
104
+ callback = callback,
105
+ )
106
+ } else {
107
+ UserApiClient.instance.loginWithKakaoAccount(
108
+ context,
109
+ prompts =
110
+ prompts
111
+ ?.filterIsInstance<String>()
112
+ ?.mapNotNull {
109
113
  when (it) {
110
114
  "Login" -> LOGIN
111
115
  "Create" -> CREATE
@@ -115,282 +119,282 @@ class RNCKakaoUserModule internal constructor(context: ReactApplicationContext)
115
119
  else -> null
116
120
  }
117
121
  }?.ifEmpty { null },
118
- serviceTerms = serviceTerms?.filterIsInstance<String>()?.ifEmpty { null },
119
- callback = callback,
120
- )
121
- }
122
+ serviceTerms = serviceTerms?.filterIsInstance<String>()?.ifEmpty { null },
123
+ callback = callback,
124
+ )
125
+ }
126
+ }
127
+
128
+ @ReactMethod
129
+ override fun isKakaoTalkLoginAvailable(promise: Promise) =
130
+ onMain {
131
+ promise.resolve(UserApiClient.instance.isKakaoTalkLoginAvailable(reactApplicationContext))
122
132
  }
123
133
 
124
- @ReactMethod
125
- override fun isKakaoTalkLoginAvailable(promise: Promise) =
126
- onMain {
127
- promise.resolve(UserApiClient.instance.isKakaoTalkLoginAvailable(reactApplicationContext))
134
+ @ReactMethod
135
+ override fun logout(promise: Promise) =
136
+ onMain {
137
+ UserApiClient.instance.logout {
138
+ if (it != null) {
139
+ promise.rejectWith(it)
140
+ } else {
141
+ promise.resolve(42)
142
+ }
128
143
  }
144
+ }
129
145
 
130
- @ReactMethod
131
- override fun logout(promise: Promise) =
132
- onMain {
133
- UserApiClient.instance.logout {
134
- if (it != null) {
135
- promise.rejectWith(it)
136
- } else {
137
- promise.resolve(42)
138
- }
146
+ @ReactMethod
147
+ override fun unlink(promise: Promise) =
148
+ onMain {
149
+ UserApiClient.instance.unlink {
150
+ if (it != null) {
151
+ promise.rejectWith(it)
152
+ } else {
153
+ promise.resolve(42)
139
154
  }
140
155
  }
156
+ }
141
157
 
142
- @ReactMethod
143
- override fun unlink(promise: Promise) =
144
- onMain {
145
- UserApiClient.instance.unlink {
146
- if (it != null) {
147
- promise.rejectWith(it)
158
+ @ReactMethod
159
+ override fun isLogined(promise: Promise) =
160
+ onMain {
161
+ if (AuthApiClient.instance.hasToken()) {
162
+ UserApiClient.instance.accessTokenInfo { _, error ->
163
+ if (error != null) {
164
+ promise.rejectWith(error)
148
165
  } else {
149
- promise.resolve(42)
166
+ promise.resolve(true)
150
167
  }
151
168
  }
169
+ } else {
170
+ promise.resolve(false)
152
171
  }
172
+ }
153
173
 
154
- @ReactMethod
155
- override fun isLogined(promise: Promise) =
156
- onMain {
157
- if (AuthApiClient.instance.hasToken()) {
158
- UserApiClient.instance.accessTokenInfo { _, error ->
159
- if (error != null) {
160
- promise.rejectWith(error)
161
- } else {
162
- promise.resolve(true)
174
+ @ReactMethod
175
+ override fun scopes(
176
+ scopes: ReadableArray?,
177
+ promise: Promise,
178
+ ) = onMain {
179
+ UserApiClient.instance.scopes { scopeInfo, error ->
180
+ if (error != null) {
181
+ promise.rejectWith(error)
182
+ } else if (scopeInfo?.scopes == null) {
183
+ promise.rejectWith(RNCKakaoResponseNotFoundException("scopes"))
184
+ } else {
185
+ promise.resolve(
186
+ argArr().also { arr ->
187
+ scopeInfo.scopes!!.forEach { scope ->
188
+ arr.pushMap(
189
+ argMap().also { map ->
190
+ map.putString("id", scope.id)
191
+ map.putString("displayName", scope.displayName)
192
+ map.putString("type", scope.type.name)
193
+ map.putBoolean("using", scope.using)
194
+ map.putB("delegated", scope.delegated)
195
+ map.putBoolean("agreed", scope.agreed)
196
+ map.putB("revocable", scope.revocable)
197
+ },
198
+ )
163
199
  }
164
- }
165
- } else {
166
- promise.resolve(false)
167
- }
200
+ },
201
+ )
168
202
  }
203
+ }
204
+ }
169
205
 
170
- @ReactMethod
171
- override fun scopes(
172
- scopes: ReadableArray?,
173
- promise: Promise,
174
- ) = onMain {
175
- UserApiClient.instance.scopes { scopeInfo, error ->
206
+ @ReactMethod
207
+ override fun revokeScopes(
208
+ scopes: ReadableArray,
209
+ promise: Promise,
210
+ ) = onMain {
211
+ UserApiClient.instance.revokeScopes(
212
+ scopes = scopes.filterIsInstance<String>(),
213
+ ) { scopeInfo, error ->
214
+ if (error != null) {
215
+ promise.rejectWith(error)
216
+ } else if (scopeInfo == null) {
217
+ promise.rejectWith(RNCKakaoResponseNotFoundException("scopeInfo"))
218
+ } else {
219
+ promise.resolve(42)
220
+ }
221
+ }
222
+ }
223
+
224
+ @ReactMethod
225
+ override fun serviceTerms(promise: Promise) =
226
+ onMain {
227
+ UserApiClient.instance.serviceTerms { serviceTerms, error ->
176
228
  if (error != null) {
177
229
  promise.rejectWith(error)
178
- } else if (scopeInfo?.scopes == null) {
179
- promise.rejectWith(RNCKakaoResponseNotFoundException("scopes"))
230
+ } else if (serviceTerms?.serviceTerms == null) {
231
+ promise.rejectWith(RNCKakaoResponseNotFoundException("serviceTerms"))
180
232
  } else {
181
233
  promise.resolve(
182
- argArr().also { arr ->
183
- scopeInfo.scopes!!.forEach { scope ->
184
- arr.pushMap(
185
- argMap().also { map ->
186
- map.putString("id", scope.id)
187
- map.putString("displayName", scope.displayName)
188
- map.putString("type", scope.type.name)
189
- map.putBoolean("using", scope.using)
190
- map.putB("delegated", scope.delegated)
191
- map.putBoolean("agreed", scope.agreed)
192
- map.putB("revocable", scope.revocable)
193
- },
194
- )
195
- }
196
- },
234
+ argArr().pushMapList(
235
+ serviceTerms.serviceTerms?.map { term ->
236
+ argMap().apply {
237
+ putString("tag", term.tag)
238
+ putD("agreedAt", term.agreedAt?.unix?.toDouble())
239
+ putBoolean("agreed", term.agreed)
240
+ putBoolean("required", term.required)
241
+ putBoolean("revocable", term.revocable)
242
+ }
243
+ } ?: listOf(),
244
+ ),
197
245
  )
198
246
  }
199
247
  }
200
248
  }
201
249
 
202
- @ReactMethod
203
- override fun revokeScopes(
204
- scopes: ReadableArray,
205
- promise: Promise,
206
- ) = onMain {
207
- UserApiClient.instance.revokeScopes(
208
- scopes = scopes.filterIsInstance<String>(),
209
- ) { scopeInfo, error ->
250
+ @ReactMethod
251
+ override fun shippingAddresses(promise: Promise) =
252
+ onMain {
253
+ UserApiClient.instance.shippingAddresses { addrs, error ->
210
254
  if (error != null) {
211
255
  promise.rejectWith(error)
212
- } else if (scopeInfo == null) {
213
- promise.rejectWith(RNCKakaoResponseNotFoundException("scopeInfo"))
256
+ } else if (addrs == null) {
257
+ promise.rejectWith(RNCKakaoResponseNotFoundException("shippingAddresses"))
214
258
  } else {
215
- promise.resolve(42)
259
+ promise.resolve(
260
+ argMap().apply {
261
+ putD("userId", addrs.userId?.toDouble())
262
+ putB("needsAgreement", addrs.needsAgreement)
263
+ putArray(
264
+ "shippingAddresses",
265
+ argArr().apply {
266
+ pushMapList(
267
+ addrs.shippingAddresses?.map { addr ->
268
+ argMap().apply {
269
+ putDouble("id", addr.id.toDouble())
270
+ putString("name", addr.name)
271
+ putBoolean("isDefault", addr.isDefault)
272
+ putD("updatedAt", addr.updatedAt?.unix?.toDouble())
273
+ putString("type", addr.type?.name)
274
+ putString("baseAddress", addr.baseAddress)
275
+ putString("detailAddress", addr.detailAddress)
276
+ putString("receiverName", addr.receiverName)
277
+ putString("receiverPhoneNumber1", addr.receiverPhoneNumber1)
278
+ putString("receiverPhoneNumber2", addr.receiverPhoneNumber2)
279
+ putString("zoneNumber", addr.zoneNumber)
280
+ putString("zipCode", addr.zipCode)
281
+ }
282
+ } ?: listOf(),
283
+ )
284
+ },
285
+ )
286
+ },
287
+ )
216
288
  }
217
289
  }
218
290
  }
219
291
 
220
- @ReactMethod
221
- override fun serviceTerms(promise: Promise) =
222
- onMain {
223
- UserApiClient.instance.serviceTerms { serviceTerms, error ->
224
- if (error != null) {
225
- promise.rejectWith(error)
226
- } else if (serviceTerms?.serviceTerms == null) {
227
- promise.rejectWith(RNCKakaoResponseNotFoundException("serviceTerms"))
228
- } else {
229
- promise.resolve(
230
- argArr().pushMapList(
231
- serviceTerms.serviceTerms?.map { term ->
232
- argMap().apply {
233
- putString("tag", term.tag)
234
- putD("agreedAt", term.agreedAt?.unix?.toDouble())
235
- putBoolean("agreed", term.agreed)
236
- putBoolean("required", term.required)
237
- putBoolean("revocable", term.revocable)
238
- }
239
- } ?: listOf(),
240
- ),
241
- )
242
- }
243
- }
244
- }
245
-
246
- @ReactMethod
247
- override fun shippingAddresses(promise: Promise) =
248
- onMain {
249
- UserApiClient.instance.shippingAddresses { addrs, error ->
250
- if (error != null) {
251
- promise.rejectWith(error)
252
- } else if (addrs == null) {
253
- promise.rejectWith(RNCKakaoResponseNotFoundException("shippingAddresses"))
254
- } else {
255
- promise.resolve(
256
- argMap().apply {
257
- putD("userId", addrs.userId?.toDouble())
258
- putB("needsAgreement", addrs.needsAgreement)
259
- putArray(
260
- "shippingAddresses",
261
- argArr().apply {
262
- pushMapList(
263
- addrs.shippingAddresses?.map { addr ->
264
- argMap().apply {
265
- putDouble("id", addr.id.toDouble())
266
- putString("name", addr.name)
267
- putBoolean("isDefault", addr.isDefault)
268
- putD("updatedAt", addr.updatedAt?.unix?.toDouble())
269
- putString("type", addr.type?.name)
270
- putString("baseAddress", addr.baseAddress)
271
- putString("detailAddress", addr.detailAddress)
272
- putString("receiverName", addr.receiverName)
273
- putString("receiverPhoneNumber1", addr.receiverPhoneNumber1)
274
- putString("receiverPhoneNumber2", addr.receiverPhoneNumber2)
275
- putString("zoneNumber", addr.zoneNumber)
276
- putString("zipCode", addr.zipCode)
277
- }
278
- } ?: listOf(),
279
- )
280
- },
281
- )
282
- },
283
- )
284
- }
285
- }
286
- }
287
-
288
- @ReactMethod
289
- override fun me(promise: Promise) =
290
- onMain {
291
- UserApiClient.instance.me { user, error ->
292
- if (error != null) {
293
- promise.rejectWith(error)
294
- } else if (user == null) {
295
- promise.rejectWith(RNCKakaoResponseNotFoundException("user"))
296
- } else {
297
- promise.resolve(
298
- argMap().apply {
299
- putD("id", user.id?.toDouble())
300
- putString("name", user.kakaoAccount?.name)
292
+ @ReactMethod
293
+ override fun me(promise: Promise) =
294
+ onMain {
295
+ UserApiClient.instance.me { user, error ->
296
+ if (error != null) {
297
+ promise.rejectWith(error)
298
+ } else if (user == null) {
299
+ promise.rejectWith(RNCKakaoResponseNotFoundException("user"))
300
+ } else {
301
+ promise.resolve(
302
+ argMap().apply {
303
+ putD("id", user.id?.toDouble())
304
+ putString("name", user.kakaoAccount?.name)
301
305
 
302
- putString("email", user.kakaoAccount?.email)
303
- putString("nickname", user.kakaoAccount?.profile?.nickname)
304
- putString("profileImageUrl", user.kakaoAccount?.profile?.profileImageUrl)
305
- putString("thumbnailImageUrl", user.kakaoAccount?.profile?.thumbnailImageUrl)
306
- putString("phoneNumber", user.kakaoAccount?.phoneNumber)
307
- putString("ageRange", user.kakaoAccount?.ageRange?.name)
308
- putString("birthday", user.kakaoAccount?.birthday)
309
- putString("birthdayType", user.kakaoAccount?.birthdayType?.name)
310
- putString("birthyear", user.kakaoAccount?.birthyear)
311
- putString("gender", user.kakaoAccount?.gender?.name)
312
- putB("isEmailValid", user.kakaoAccount?.isEmailValid)
313
- putB("isEmailVerified", user.kakaoAccount?.isEmailVerified)
314
- putB("isKorean", user.kakaoAccount?.isKorean)
315
- putB(
316
- "ageRangeNeedsAgreement",
317
- user.kakaoAccount?.ageRangeNeedsAgreement,
318
- )
319
- putB(
320
- "birthdayNeedsAgreement",
321
- user.kakaoAccount?.birthdayNeedsAgreement,
322
- )
323
- putB(
324
- "birthyearNeedsAgreement",
325
- user.kakaoAccount?.birthyearNeedsAgreement,
326
- )
327
- putB(
328
- "emailNeedsAgreement",
329
- user.kakaoAccount?.emailNeedsAgreement,
330
- )
331
- putB(
332
- "genderNeedsAgreement",
333
- user.kakaoAccount?.genderNeedsAgreement,
334
- )
335
- putB(
336
- "isKoreanNeedsAgreement",
337
- user.kakaoAccount?.isKoreanNeedsAgreement,
338
- )
339
- putB(
340
- "phoneNumberNeedsAgreement",
341
- user.kakaoAccount?.phoneNumberNeedsAgreement,
342
- )
343
- putB(
344
- "profileNeedsAgreement",
345
- user.kakaoAccount?.profileNeedsAgreement,
346
- )
347
- putB(
348
- "ciNeedsAgreement",
349
- user.kakaoAccount?.ciNeedsAgreement,
350
- )
351
- putB(
352
- "nameNeedsAgreement",
353
- user.kakaoAccount?.nameNeedsAgreement,
354
- )
355
- putB(
356
- "profileImageNeedsAgreement",
357
- user.kakaoAccount?.profileImageNeedsAgreement,
358
- )
359
- putB(
360
- "profileNicknameNeedsAgreement",
361
- user.kakaoAccount?.profileNicknameNeedsAgreement,
362
- )
363
- putB(
364
- "legalBirthDateNeedsAgreement",
365
- user.kakaoAccount?.legalBirthDateNeedsAgreement,
366
- )
367
- },
368
- )
369
- }
306
+ putString("email", user.kakaoAccount?.email)
307
+ putString("nickname", user.kakaoAccount?.profile?.nickname)
308
+ putString("profileImageUrl", user.kakaoAccount?.profile?.profileImageUrl)
309
+ putString("thumbnailImageUrl", user.kakaoAccount?.profile?.thumbnailImageUrl)
310
+ putString("phoneNumber", user.kakaoAccount?.phoneNumber)
311
+ putString("ageRange", user.kakaoAccount?.ageRange?.name)
312
+ putString("birthday", user.kakaoAccount?.birthday)
313
+ putString("birthdayType", user.kakaoAccount?.birthdayType?.name)
314
+ putString("birthyear", user.kakaoAccount?.birthyear)
315
+ putString("gender", user.kakaoAccount?.gender?.name)
316
+ putB("isEmailValid", user.kakaoAccount?.isEmailValid)
317
+ putB("isEmailVerified", user.kakaoAccount?.isEmailVerified)
318
+ putB("isKorean", user.kakaoAccount?.isKorean)
319
+ putB(
320
+ "ageRangeNeedsAgreement",
321
+ user.kakaoAccount?.ageRangeNeedsAgreement,
322
+ )
323
+ putB(
324
+ "birthdayNeedsAgreement",
325
+ user.kakaoAccount?.birthdayNeedsAgreement,
326
+ )
327
+ putB(
328
+ "birthyearNeedsAgreement",
329
+ user.kakaoAccount?.birthyearNeedsAgreement,
330
+ )
331
+ putB(
332
+ "emailNeedsAgreement",
333
+ user.kakaoAccount?.emailNeedsAgreement,
334
+ )
335
+ putB(
336
+ "genderNeedsAgreement",
337
+ user.kakaoAccount?.genderNeedsAgreement,
338
+ )
339
+ putB(
340
+ "isKoreanNeedsAgreement",
341
+ user.kakaoAccount?.isKoreanNeedsAgreement,
342
+ )
343
+ putB(
344
+ "phoneNumberNeedsAgreement",
345
+ user.kakaoAccount?.phoneNumberNeedsAgreement,
346
+ )
347
+ putB(
348
+ "profileNeedsAgreement",
349
+ user.kakaoAccount?.profileNeedsAgreement,
350
+ )
351
+ putB(
352
+ "ciNeedsAgreement",
353
+ user.kakaoAccount?.ciNeedsAgreement,
354
+ )
355
+ putB(
356
+ "nameNeedsAgreement",
357
+ user.kakaoAccount?.nameNeedsAgreement,
358
+ )
359
+ putB(
360
+ "profileImageNeedsAgreement",
361
+ user.kakaoAccount?.profileImageNeedsAgreement,
362
+ )
363
+ putB(
364
+ "profileNicknameNeedsAgreement",
365
+ user.kakaoAccount?.profileNicknameNeedsAgreement,
366
+ )
367
+ putB(
368
+ "legalBirthDateNeedsAgreement",
369
+ user.kakaoAccount?.legalBirthDateNeedsAgreement,
370
+ )
371
+ },
372
+ )
370
373
  }
371
374
  }
375
+ }
372
376
 
373
- @ReactMethod
374
- override fun getAccessToken(promise: Promise) =
375
- onMain {
376
- UserApiClient.instance.accessTokenInfo { accessTokenInfo, error ->
377
- if (error != null) {
378
- promise.rejectWith(error)
379
- } else if (accessTokenInfo == null) {
380
- promise.rejectWith(RNCKakaoResponseNotFoundException("accessTokenInfo"))
381
- } else {
382
- promise.resolve(
383
- argMap().apply {
384
- putL("id", accessTokenInfo.id)
385
- putL("expiresIn", accessTokenInfo.expiresIn)
386
- putI("appID", accessTokenInfo.appId)
387
- },
388
- )
389
- }
377
+ @ReactMethod
378
+ override fun getAccessToken(promise: Promise) =
379
+ onMain {
380
+ UserApiClient.instance.accessTokenInfo { accessTokenInfo, error ->
381
+ if (error != null) {
382
+ promise.rejectWith(error)
383
+ } else if (accessTokenInfo == null) {
384
+ promise.rejectWith(RNCKakaoResponseNotFoundException("accessTokenInfo"))
385
+ } else {
386
+ promise.resolve(
387
+ argMap().apply {
388
+ putL("id", accessTokenInfo.id)
389
+ putL("expiresIn", accessTokenInfo.expiresIn)
390
+ putI("appID", accessTokenInfo.appId)
391
+ },
392
+ )
390
393
  }
391
394
  }
392
-
393
- companion object {
394
- const val NAME = "RNCKakaoUser"
395
395
  }
396
+
397
+ companion object {
398
+ const val NAME = "RNCKakaoUser"
396
399
  }
400
+ }
@@ -10,16 +10,15 @@ class RNCKakaoUserPackage : TurboReactPackage() {
10
10
  override fun getModule(
11
11
  name: String,
12
12
  reactContext: ReactApplicationContext,
13
- ): NativeModule? {
14
- return if (name == RNCKakaoUserModule.NAME) {
13
+ ): NativeModule? =
14
+ if (name == RNCKakaoUserModule.NAME) {
15
15
  RNCKakaoUserModule(reactContext)
16
16
  } else {
17
17
  null
18
18
  }
19
- }
20
19
 
21
- override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
22
- return ReactModuleInfoProvider {
20
+ override fun getReactModuleInfoProvider(): ReactModuleInfoProvider =
21
+ ReactModuleInfoProvider {
23
22
  val moduleInfos: MutableMap<String, ReactModuleInfo> = HashMap()
24
23
  val isTurboModule: Boolean = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
25
24
  moduleInfos[RNCKakaoUserModule.NAME] =
@@ -33,5 +32,4 @@ class RNCKakaoUserPackage : TurboReactPackage() {
33
32
  )
34
33
  moduleInfos
35
34
  }
36
- }
37
35
  }
@@ -2,5 +2,6 @@ package net.mjstudio.rnkakao.user
2
2
 
3
3
  import com.facebook.react.bridge.ReactApplicationContext
4
4
 
5
- abstract class KakaoUserSpec internal constructor(context: ReactApplicationContext) :
6
- NativeKakaoUserSpec(context)
5
+ abstract class KakaoUserSpec internal constructor(
6
+ context: ReactApplicationContext,
7
+ ) : NativeKakaoUserSpec(context)
@@ -5,39 +5,40 @@ import com.facebook.react.bridge.ReactApplicationContext
5
5
  import com.facebook.react.bridge.ReactContextBaseJavaModule
6
6
  import com.facebook.react.bridge.ReadableArray
7
7
 
8
- abstract class KakaoUserSpec internal constructor(context: ReactApplicationContext) :
9
- ReactContextBaseJavaModule(context) {
10
- abstract fun login(
11
- serviceTerms: ReadableArray?,
12
- prompts: ReadableArray?,
13
- useKakaoAccountLogin: Boolean,
14
- scopes: ReadableArray?,
15
- promise: Promise,
16
- )
8
+ abstract class KakaoUserSpec internal constructor(
9
+ context: ReactApplicationContext,
10
+ ) : ReactContextBaseJavaModule(context) {
11
+ abstract fun login(
12
+ serviceTerms: ReadableArray?,
13
+ prompts: ReadableArray?,
14
+ useKakaoAccountLogin: Boolean,
15
+ scopes: ReadableArray?,
16
+ promise: Promise,
17
+ )
17
18
 
18
- abstract fun isKakaoTalkLoginAvailable(promise: Promise)
19
+ abstract fun isKakaoTalkLoginAvailable(promise: Promise)
19
20
 
20
- abstract fun logout(promise: Promise)
21
+ abstract fun logout(promise: Promise)
21
22
 
22
- abstract fun unlink(promise: Promise)
23
+ abstract fun unlink(promise: Promise)
23
24
 
24
- abstract fun isLogined(promise: Promise)
25
+ abstract fun isLogined(promise: Promise)
25
26
 
26
- abstract fun scopes(
27
- scopes: ReadableArray?,
28
- promise: Promise,
29
- )
27
+ abstract fun scopes(
28
+ scopes: ReadableArray?,
29
+ promise: Promise,
30
+ )
30
31
 
31
- abstract fun revokeScopes(
32
- scopes: ReadableArray,
33
- promise: Promise,
34
- )
32
+ abstract fun revokeScopes(
33
+ scopes: ReadableArray,
34
+ promise: Promise,
35
+ )
35
36
 
36
- abstract fun serviceTerms(promise: Promise)
37
+ abstract fun serviceTerms(promise: Promise)
37
38
 
38
- abstract fun shippingAddresses(promise: Promise)
39
+ abstract fun shippingAddresses(promise: Promise)
39
40
 
40
- abstract fun me(promise: Promise)
41
+ abstract fun me(promise: Promise)
41
42
 
42
- abstract fun getAccessToken(promise: Promise)
43
- }
43
+ abstract fun getAccessToken(promise: Promise)
44
+ }
@@ -88,7 +88,7 @@ export interface KakaoAccessTokenInfo {
88
88
  }
89
89
  export declare function login({ serviceTerms, prompts, useKakaoAccountLogin, scopes, }?: {
90
90
  serviceTerms?: string[];
91
- prompts?: ('Loign' | 'Create' | 'Cert' | 'UnifyDaum' | 'SelectAccount')[];
91
+ prompts?: ('Login' | 'Create' | 'Cert' | 'UnifyDaum' | 'SelectAccount')[];
92
92
  scopes?: string[];
93
93
  useKakaoAccountLogin?: boolean;
94
94
  web?: {
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": "2.2.3",
4
+ "version": "2.2.5",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
7
7
  "types": "lib/typescript/src/index.d.ts",
@@ -62,7 +62,7 @@
62
62
  "access": "public"
63
63
  },
64
64
  "devDependencies": {
65
- "@react-native-kakao/core": "2.2.3",
65
+ "@react-native-kakao/core": "2.2.5",
66
66
  "@types/invariant": "^2",
67
67
  "@types/jest": "^29.5.5",
68
68
  "@types/react": "^18.2.44",
@@ -74,7 +74,7 @@
74
74
  "typescript": "5.1.6"
75
75
  },
76
76
  "peerDependencies": {
77
- "@react-native-kakao/core": "2.2.3",
77
+ "@react-native-kakao/core": "2.2.5",
78
78
  "react": "*",
79
79
  "react-native": "*"
80
80
  },
@@ -110,7 +110,7 @@
110
110
  "javaPackageName": "net.mjstudio.rnkakao.user"
111
111
  }
112
112
  },
113
- "gitHead": "2ed9d6e300920b7056a8f539ab11a2592e0064a2",
113
+ "gitHead": "0ecf72a2948e71f464fbc27f7369f13b77916cbd",
114
114
  "dependencies": {
115
115
  "@mj-studio/js-util": "1.1.3"
116
116
  }
package/src/index.ts CHANGED
@@ -122,7 +122,7 @@ export function login({
122
122
  scopes,
123
123
  }: {
124
124
  serviceTerms?: string[];
125
- prompts?: ('Loign' | 'Create' | 'Cert' | 'UnifyDaum' | 'SelectAccount')[];
125
+ prompts?: ('Login' | 'Create' | 'Cert' | 'UnifyDaum' | 'SelectAccount')[];
126
126
  scopes?: string[];
127
127
  useKakaoAccountLogin?: boolean;
128
128
  web?: {