@react-native-kakao/user 3.1.0-next.1 → 3.1.0-next.2
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 +13 -0
- package/android/src/main/java/net/mjstudio/rnkakao/user/RNCKakaoUserModule.kt +37 -23
- package/ios/RNCKakaoUser.mm +6 -5
- package/ios/RNCKakaoUserManager.swift +36 -18
- package/lib/commonjs/index.js +31 -13
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/index.web.js +30 -16
- package/lib/commonjs/index.web.js.map +1 -1
- package/lib/commonjs/spec/NativeKakaoUser.ts +3 -2
- package/lib/module/index.js +31 -14
- package/lib/module/index.js.map +1 -1
- package/lib/module/index.web.js +27 -15
- package/lib/module/index.web.js.map +1 -1
- package/lib/module/spec/NativeKakaoUser.ts +3 -2
- package/lib/typescript/src/index.d.ts +35 -26
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/spec/NativeKakaoUser.d.ts +3 -3
- package/lib/typescript/src/spec/NativeKakaoUser.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/index.ts +62 -37
- package/src/index.web.ts +45 -21
- package/src/spec/NativeKakaoUser.ts +3 -2
package/src/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { is } from '@mj-studio/js-util';
|
|
2
|
-
import { kAssert } from '@react-native-kakao/core';
|
|
2
|
+
import { kAssert, kCreateWebError } from '@react-native-kakao/core';
|
|
3
3
|
|
|
4
4
|
import Native from './spec/NativeKakaoUser';
|
|
5
5
|
import { validateShippingAddressOptions } from './validateShippingAddressOptions';
|
|
@@ -25,13 +25,18 @@ export type KakaoCodeTokenOptions = {
|
|
|
25
25
|
const minActivityRequestCode = -2147483648;
|
|
26
26
|
const maxActivityRequestCode = 2147483647;
|
|
27
27
|
|
|
28
|
+
export type KakaoTalkLaunchMethod = 'UniversalLink' | 'CustomScheme';
|
|
29
|
+
|
|
30
|
+
const defaultTalkLaunchMethod: KakaoTalkLaunchMethod = 'UniversalLink';
|
|
31
|
+
const webOnlyErrorCode = 'Package-UnsupportedPlatform';
|
|
32
|
+
|
|
28
33
|
export interface KakaoScopeInfo {
|
|
29
34
|
id: string;
|
|
30
35
|
agreed: boolean;
|
|
31
36
|
displayName: string;
|
|
32
|
-
revocable?: boolean;
|
|
37
|
+
revocable?: boolean | null;
|
|
33
38
|
using: boolean;
|
|
34
|
-
delegated?: boolean;
|
|
39
|
+
delegated?: boolean | null;
|
|
35
40
|
type: string;
|
|
36
41
|
}
|
|
37
42
|
export interface KakaoServiceTerms {
|
|
@@ -40,6 +45,7 @@ export interface KakaoServiceTerms {
|
|
|
40
45
|
agreed: boolean;
|
|
41
46
|
required: boolean;
|
|
42
47
|
revocable: boolean;
|
|
48
|
+
agreedBy?: 'KAUTH' | 'KAPI' | 'unknown';
|
|
43
49
|
}
|
|
44
50
|
export type KakaoRevokedServiceTerms = {
|
|
45
51
|
tag: string;
|
|
@@ -71,14 +77,15 @@ export interface KakaoShippingAddress {
|
|
|
71
77
|
}
|
|
72
78
|
export interface KakaoUser {
|
|
73
79
|
id: number;
|
|
80
|
+
properties: Record<string, string>;
|
|
74
81
|
hasSignedUp?: boolean | null;
|
|
75
82
|
uuid?: string | null;
|
|
76
83
|
groupUserToken?: string | null;
|
|
77
|
-
email
|
|
84
|
+
email?: string | null;
|
|
78
85
|
name?: string | null;
|
|
79
|
-
nickname
|
|
80
|
-
profileImageUrl
|
|
81
|
-
thumbnailImageUrl
|
|
86
|
+
nickname?: string | null;
|
|
87
|
+
profileImageUrl?: string | null;
|
|
88
|
+
thumbnailImageUrl?: string | null;
|
|
82
89
|
isDefaultImage?: boolean | null;
|
|
83
90
|
phoneNumber?: string | null;
|
|
84
91
|
ageRange?: string | null;
|
|
@@ -87,28 +94,28 @@ export interface KakaoUser {
|
|
|
87
94
|
isLeapMonth?: boolean | null;
|
|
88
95
|
birthyear?: string | null;
|
|
89
96
|
gender?: string | null;
|
|
90
|
-
isEmailValid
|
|
91
|
-
isEmailVerified
|
|
92
|
-
isKorean?: boolean;
|
|
93
|
-
ageRangeNeedsAgreement?: boolean;
|
|
94
|
-
birthdayNeedsAgreement?: boolean;
|
|
95
|
-
birthyearNeedsAgreement?: boolean;
|
|
96
|
-
emailNeedsAgreement?: boolean;
|
|
97
|
-
genderNeedsAgreement?: boolean;
|
|
98
|
-
isKoreanNeedsAgreement?: boolean;
|
|
99
|
-
phoneNumberNeedsAgreement?: boolean;
|
|
100
|
-
profileNeedsAgreement?: boolean;
|
|
101
|
-
nameNeedsAgreement?: boolean;
|
|
102
|
-
profileImageNeedsAgreement?: boolean;
|
|
103
|
-
profileNicknameNeedsAgreement?: boolean;
|
|
97
|
+
isEmailValid?: boolean | null;
|
|
98
|
+
isEmailVerified?: boolean | null;
|
|
99
|
+
isKorean?: boolean | null;
|
|
100
|
+
ageRangeNeedsAgreement?: boolean | null;
|
|
101
|
+
birthdayNeedsAgreement?: boolean | null;
|
|
102
|
+
birthyearNeedsAgreement?: boolean | null;
|
|
103
|
+
emailNeedsAgreement?: boolean | null;
|
|
104
|
+
genderNeedsAgreement?: boolean | null;
|
|
105
|
+
isKoreanNeedsAgreement?: boolean | null;
|
|
106
|
+
phoneNumberNeedsAgreement?: boolean | null;
|
|
107
|
+
profileNeedsAgreement?: boolean | null;
|
|
108
|
+
nameNeedsAgreement?: boolean | null;
|
|
109
|
+
profileImageNeedsAgreement?: boolean | null;
|
|
110
|
+
profileNicknameNeedsAgreement?: boolean | null;
|
|
104
111
|
legalName?: string | null;
|
|
105
112
|
legalNameNeedsAgreement?: boolean | null;
|
|
106
113
|
legalBirthDate?: string | null;
|
|
107
|
-
legalBirthDateNeedsAgreement?: boolean;
|
|
114
|
+
legalBirthDateNeedsAgreement?: boolean | null;
|
|
108
115
|
legalGender?: 'female' | 'male' | null;
|
|
109
116
|
legalGenderNeedsAgreement?: boolean | null;
|
|
110
|
-
connectedAt?: number;
|
|
111
|
-
synchedAt?: number;
|
|
117
|
+
connectedAt?: number | null;
|
|
118
|
+
synchedAt?: number | null;
|
|
112
119
|
}
|
|
113
120
|
export interface KakaoAccessTokenInfo {
|
|
114
121
|
id?: number;
|
|
@@ -124,6 +131,7 @@ export function login({
|
|
|
124
131
|
loginHint,
|
|
125
132
|
channelPublicIds,
|
|
126
133
|
android,
|
|
134
|
+
ios,
|
|
127
135
|
}: {
|
|
128
136
|
serviceTerms?: string[];
|
|
129
137
|
prompts?: ('Login' | 'Create' | 'Cert' | 'SelectAccount')[];
|
|
@@ -133,6 +141,7 @@ export function login({
|
|
|
133
141
|
loginHint?: string;
|
|
134
142
|
channelPublicIds?: string[];
|
|
135
143
|
android?: { requestCode?: number };
|
|
144
|
+
ios?: { launchMethod?: KakaoTalkLaunchMethod };
|
|
136
145
|
web?: {
|
|
137
146
|
redirectUri: string;
|
|
138
147
|
scope?: string[];
|
|
@@ -179,6 +188,7 @@ export function login({
|
|
|
179
188
|
serviceTerms ?? [],
|
|
180
189
|
prompts ?? [],
|
|
181
190
|
useKakaoAccountLogin ?? false,
|
|
191
|
+
ios?.launchMethod ?? defaultTalkLaunchMethod,
|
|
182
192
|
scopes ?? [],
|
|
183
193
|
nonce,
|
|
184
194
|
loginHint,
|
|
@@ -208,13 +218,13 @@ export function loginWithKakao({
|
|
|
208
218
|
serviceTerms?: string[];
|
|
209
219
|
ios?: {
|
|
210
220
|
orientation?: 'auto' | 'portrait' | 'landscape';
|
|
211
|
-
launchMethod?:
|
|
221
|
+
launchMethod?: KakaoTalkLaunchMethod;
|
|
212
222
|
};
|
|
213
223
|
} = {}): Promise<KakaoLoginToken> {
|
|
214
224
|
return Native.loginWithKakao(
|
|
215
225
|
uiMode,
|
|
216
226
|
ios?.orientation ?? 'auto',
|
|
217
|
-
ios?.launchMethod ??
|
|
227
|
+
ios?.launchMethod ?? defaultTalkLaunchMethod,
|
|
218
228
|
prompts ?? [],
|
|
219
229
|
loginHint,
|
|
220
230
|
nonce,
|
|
@@ -264,12 +274,12 @@ export function refreshToken({
|
|
|
264
274
|
return Native.refreshToken(token, ios?.loggingEnabled ?? true);
|
|
265
275
|
}
|
|
266
276
|
|
|
267
|
-
export function logout() {
|
|
268
|
-
|
|
277
|
+
export async function logout() {
|
|
278
|
+
await Native.logout();
|
|
269
279
|
}
|
|
270
280
|
|
|
271
|
-
export function unlink() {
|
|
272
|
-
|
|
281
|
+
export async function unlink() {
|
|
282
|
+
await Native.unlink();
|
|
273
283
|
}
|
|
274
284
|
|
|
275
285
|
export function isLogined() {
|
|
@@ -286,7 +296,11 @@ export function scopes(scopes?: string[]): Promise<KakaoScopeInfo[]> {
|
|
|
286
296
|
return Native.scopes(scopes);
|
|
287
297
|
}
|
|
288
298
|
|
|
289
|
-
export function revokeScopes(scopes: string[]): Promise<void> {
|
|
299
|
+
export async function revokeScopes(scopes: string[]): Promise<void> {
|
|
300
|
+
await Native.revokeScopes(scopes);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
export function revokeScopesWithResult(scopes: string[]): Promise<KakaoScopeInfo[]> {
|
|
290
304
|
return Native.revokeScopes(scopes);
|
|
291
305
|
}
|
|
292
306
|
|
|
@@ -323,9 +337,10 @@ export function selectShippingAddress(): Promise<number> {
|
|
|
323
337
|
}
|
|
324
338
|
|
|
325
339
|
export function me({
|
|
340
|
+
propertyKeys,
|
|
326
341
|
secureResource = true,
|
|
327
|
-
}: { secureResource?: boolean } = {}): Promise<KakaoUser> {
|
|
328
|
-
return Native.me(secureResource);
|
|
342
|
+
}: { propertyKeys?: string[]; secureResource?: boolean } = {}): Promise<KakaoUser> {
|
|
343
|
+
return Native.me(propertyKeys, secureResource);
|
|
329
344
|
}
|
|
330
345
|
|
|
331
346
|
export async function issueAccessTokenWithCode({
|
|
@@ -342,16 +357,22 @@ export function getAccessToken(): Promise<KakaoAccessTokenInfo> {
|
|
|
342
357
|
return Native.getAccessToken();
|
|
343
358
|
}
|
|
344
359
|
|
|
345
|
-
export function updateProfile({
|
|
360
|
+
export async function updateProfile({
|
|
346
361
|
properties,
|
|
347
362
|
}: {
|
|
348
363
|
properties: Record<string, string>;
|
|
349
364
|
}): Promise<void> {
|
|
350
|
-
|
|
365
|
+
await Native.updateProfile(properties);
|
|
351
366
|
}
|
|
352
367
|
|
|
353
368
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
354
|
-
export function setAccessTokenWeb(token: string) {
|
|
369
|
+
export function setAccessTokenWeb(token: string): void {
|
|
370
|
+
kCreateWebError({
|
|
371
|
+
code: webOnlyErrorCode,
|
|
372
|
+
message: '[setAccessTokenWeb] This API is only supported on web.',
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
|
|
355
376
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
356
377
|
export async function issueAccessTokenWithCodeWeb(params: {
|
|
357
378
|
redirectUri: string;
|
|
@@ -367,7 +388,10 @@ export async function issueAccessTokenWithCodeWeb(params: {
|
|
|
367
388
|
refreshTokenExpiresIn: number;
|
|
368
389
|
scope?: string;
|
|
369
390
|
}> {
|
|
370
|
-
|
|
391
|
+
kCreateWebError({
|
|
392
|
+
code: webOnlyErrorCode,
|
|
393
|
+
message: '[issueAccessTokenWithCodeWeb] This API is only supported on web.',
|
|
394
|
+
});
|
|
371
395
|
}
|
|
372
396
|
|
|
373
397
|
const KakaoUser = {
|
|
@@ -383,6 +407,7 @@ const KakaoUser = {
|
|
|
383
407
|
isKakaoTalkLoginAvailable,
|
|
384
408
|
scopes,
|
|
385
409
|
revokeScopes,
|
|
410
|
+
revokeScopesWithResult,
|
|
386
411
|
serviceTerms,
|
|
387
412
|
revokeServiceTerms,
|
|
388
413
|
shippingAddresses,
|
package/src/index.web.ts
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
import {
|
|
12
12
|
type KakaoLoginToken,
|
|
13
13
|
type KakaoScopeInfo,
|
|
14
|
+
type KakaoServiceTerms,
|
|
14
15
|
type KakaoShippingAddressResult,
|
|
15
16
|
type KakaoUser as KakaoUserProfile,
|
|
16
17
|
type KakaoUserAPI,
|
|
@@ -211,17 +212,12 @@ const KakaoUser: KakaoUserAPI = {
|
|
|
211
212
|
data: scopes?.length ? { scopes } : undefined,
|
|
212
213
|
});
|
|
213
214
|
|
|
214
|
-
return camelCaseObject(response.scopes) as KakaoScopeInfo[];
|
|
215
|
-
}),
|
|
216
|
-
revokeScopes: (scopes: string[]) =>
|
|
217
|
-
kRunWebAPI(async () => {
|
|
218
|
-
await Kakao.API.request({
|
|
219
|
-
url: '/v2/user/revoke/scopes',
|
|
220
|
-
data: {
|
|
221
|
-
scopes,
|
|
222
|
-
},
|
|
223
|
-
});
|
|
215
|
+
return camelCaseObject(response.scopes ?? []) as KakaoScopeInfo[];
|
|
224
216
|
}),
|
|
217
|
+
revokeScopes: async (scopes: string[]) => {
|
|
218
|
+
await revokeScopesWithResult(scopes);
|
|
219
|
+
},
|
|
220
|
+
revokeScopesWithResult,
|
|
225
221
|
serviceTerms: ({ result, tags } = {}) =>
|
|
226
222
|
kRunWebAPI(async () => {
|
|
227
223
|
const response: {
|
|
@@ -232,6 +228,7 @@ const KakaoUser: KakaoUserAPI = {
|
|
|
232
228
|
agreed: boolean;
|
|
233
229
|
required: boolean;
|
|
234
230
|
revocable: boolean;
|
|
231
|
+
agreed_by?: string | null;
|
|
235
232
|
}[]
|
|
236
233
|
| null;
|
|
237
234
|
} = await Kakao.API.request({
|
|
@@ -239,13 +236,22 @@ const KakaoUser: KakaoUserAPI = {
|
|
|
239
236
|
data: filterNonNullishKeys({ result, tags: tags?.join(',') }),
|
|
240
237
|
});
|
|
241
238
|
|
|
242
|
-
return (response.service_terms ?? []).map(
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
239
|
+
return (response.service_terms ?? []).map(
|
|
240
|
+
(term): KakaoServiceTerms =>
|
|
241
|
+
filterNonNullishKeys({
|
|
242
|
+
tag: term.tag,
|
|
243
|
+
agreedAt: term.agreed_at ? isoToUnix(term.agreed_at) : undefined,
|
|
244
|
+
agreed: term.agreed,
|
|
245
|
+
required: term.required,
|
|
246
|
+
revocable: term.revocable,
|
|
247
|
+
agreedBy:
|
|
248
|
+
term.agreed_by == null
|
|
249
|
+
? undefined
|
|
250
|
+
: term.agreed_by === 'KAUTH' || term.agreed_by === 'KAPI'
|
|
251
|
+
? term.agreed_by
|
|
252
|
+
: 'unknown',
|
|
253
|
+
}),
|
|
254
|
+
);
|
|
249
255
|
}),
|
|
250
256
|
revokeServiceTerms: (tags) =>
|
|
251
257
|
kRunWebAPI(async () => {
|
|
@@ -318,11 +324,17 @@ const KakaoUser: KakaoUserAPI = {
|
|
|
318
324
|
kRunWebAPI(async () => {
|
|
319
325
|
await Kakao.API.request({ url: '/v1/user/update_profile', data: { properties } });
|
|
320
326
|
}),
|
|
321
|
-
me: ({ secureResource = true } = {}) =>
|
|
327
|
+
me: ({ propertyKeys, secureResource = true } = {}) =>
|
|
322
328
|
kRunWebAPI(async () => {
|
|
323
|
-
const
|
|
324
|
-
|
|
325
|
-
|
|
329
|
+
const response: { properties?: Record<string, string> } = await Kakao.API.request({
|
|
330
|
+
url: '/v2/user/me',
|
|
331
|
+
data: filterNonNullishKeys({
|
|
332
|
+
property_keys: propertyKeys,
|
|
333
|
+
secure_resource: secureResource,
|
|
334
|
+
}),
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
const ret = camelCaseObject(response) as {
|
|
326
338
|
id: number;
|
|
327
339
|
hasSignedUp?: boolean | null;
|
|
328
340
|
forPartner?: { uuid?: string };
|
|
@@ -346,6 +358,7 @@ const KakaoUser: KakaoUserAPI = {
|
|
|
346
358
|
|
|
347
359
|
return {
|
|
348
360
|
id: ret.id,
|
|
361
|
+
properties: response.properties ?? {},
|
|
349
362
|
hasSignedUp: ret.hasSignedUp ?? null,
|
|
350
363
|
uuid: ret.forPartner?.uuid ?? null,
|
|
351
364
|
groupUserToken: ret.groupUserToken ?? null,
|
|
@@ -388,6 +401,17 @@ const KakaoUser: KakaoUserAPI = {
|
|
|
388
401
|
}),
|
|
389
402
|
};
|
|
390
403
|
|
|
404
|
+
export function revokeScopesWithResult(scopes: string[]): Promise<KakaoScopeInfo[]> {
|
|
405
|
+
return kRunWebAPI(async () => {
|
|
406
|
+
const response = await Kakao.API.request({
|
|
407
|
+
url: '/v2/user/revoke/scopes',
|
|
408
|
+
data: { scopes },
|
|
409
|
+
});
|
|
410
|
+
|
|
411
|
+
return camelCaseObject(response.scopes ?? []) as KakaoScopeInfo[];
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
|
|
391
415
|
export const {
|
|
392
416
|
loginWithKakao,
|
|
393
417
|
refreshToken,
|
|
@@ -18,6 +18,7 @@ export interface Spec extends TurboModule {
|
|
|
18
18
|
serviceTerms: string[],
|
|
19
19
|
prompts: string[],
|
|
20
20
|
useKakaoAccountLogin: boolean,
|
|
21
|
+
iosLaunchMethod: string,
|
|
21
22
|
scopes?: string[],
|
|
22
23
|
nonce?: string,
|
|
23
24
|
loginHint?: string,
|
|
@@ -46,7 +47,7 @@ export interface Spec extends TurboModule {
|
|
|
46
47
|
isLogined(): Promise<boolean>;
|
|
47
48
|
hasToken(): Promise<boolean>;
|
|
48
49
|
scopes(scopes?: string[]): Promise<KakaoScopeInfo[]>;
|
|
49
|
-
revokeScopes(scopes: string[]): Promise<
|
|
50
|
+
revokeScopes(scopes: string[]): Promise<KakaoScopeInfo[]>;
|
|
50
51
|
serviceTerms(result?: string, tags?: string[]): Promise<KakaoServiceTerms[]>;
|
|
51
52
|
revokeServiceTerms(tags: string[]): Promise<KakaoRevokedServiceTerms[]>;
|
|
52
53
|
shippingAddresses(
|
|
@@ -55,7 +56,7 @@ export interface Spec extends TurboModule {
|
|
|
55
56
|
pageSize?: number,
|
|
56
57
|
): Promise<KakaoShippingAddressResult>;
|
|
57
58
|
selectShippingAddress(): Promise<number>;
|
|
58
|
-
me(secureResource?: boolean): Promise<KakaoUser>;
|
|
59
|
+
me(propertyKeys?: string[], secureResource?: boolean): Promise<KakaoUser>;
|
|
59
60
|
updateProfile(properties: UnsafeObject): Promise<void>;
|
|
60
61
|
getAccessToken(): Promise<KakaoAccessTokenInfo>;
|
|
61
62
|
}
|