@apps-in-toss/native-modules 2.4.3 → 2.4.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.
- package/dist/bridges-meta.json +5 -1
- package/dist/index.cjs +12 -8
- package/dist/index.d.cts +58 -53
- package/dist/index.d.ts +58 -53
- package/dist/index.js +11 -8
- package/package.json +2 -2
- package/src/MiniAppModule/constants.ts +1 -1
- package/src/MiniAppModule/native-modules/getAnonymousKey.ts +103 -0
- package/src/MiniAppModule/native-modules/getUserKeyForGame.ts +15 -112
- package/src/MiniAppModule/native-modules/index.ts +1 -0
- package/src/MiniAppModule/postMessage.ts +2 -0
- package/src/async-bridges.ts +1 -0
package/dist/bridges-meta.json
CHANGED
|
@@ -107,9 +107,13 @@
|
|
|
107
107
|
"identifier": "submitGameCenterLeaderBoardScore",
|
|
108
108
|
"dts": "/**\n * @public\n * @category 게임센터\n * @name SubmitGameCenterLeaderBoardScoreResponse\n * @description\n * 토스게임센터 리더보드에 점수를 제출한 결과 정보를 담아서 반환해요. 반환된 정보를 사용해서 점수 제출 결과에 따라 적절한 에러 처리를 할 수 있어요.\n * @property {'SUCCESS' | 'LEADERBOARD_NOT_FOUND' | 'PROFILE_NOT_FOUND' | 'UNPARSABLE_SCORE'} statusCode\n * 점수 제출 결과를 나타내는 상태 코드예요.\n * - `'SUCCESS'`: 점수 제출이 성공했어요.\n * - `'LEADERBOARD_NOT_FOUND'`: `gameId`에 해당하는 리더보드를 찾을 수 없어요.\n * - `'PROFILE_NOT_FOUND'`: 사용자의 프로필이 없어요.\n * - `'UNPARSABLE_SCORE'`: 점수를 해석할 수 없어요. 점수는 실수(float) 형태의 문자열로 전달해야 해요.\n */\nexport interface SubmitGameCenterLeaderBoardScoreResponse {\n\tstatusCode: \"SUCCESS\" | \"LEADERBOARD_NOT_FOUND\" | \"PROFILE_NOT_FOUND\" | \"UNPARSABLE_SCORE\";\n}\n/**\n * @public\n * @category 게임센터\n * @name submitGameCenterLeaderBoardScore\n * @description\n * 사용자의 게임 점수를 토스게임센터 리더보드에 제출해요. 이 기능으로 사용자의 점수를 공식 리더보드에 기록하고 다른 사용자와 비교할 수 있어요.\n * @param {string} params.score\n * 제출할 게임 점수예요. 실수 형태의 숫자를 문자열로 전달해야 해요. 예를들어 `\"123.45\"` 또는 `\"9999\"` 예요.\n * @returns {Promise<SubmitGameCenterLeaderBoardScoreResponse | undefined>}\n * 점수 제출 결과를 반환해요. 앱 버전이 최소 지원 버전보다 낮으면 아무 동작도 하지 않고 `undefined`를 반환해요.\n *\n * @example\n * ### 게임 점수를 토스게임센터 리더보드에 제출하기\n * ```tsx\n * import { Button } from 'react-native';\n * import { submitGameCenterLeaderBoardScore } from '@apps-in-toss/framework';\n *\n * function GameCenterLeaderBoardScoreSubmitButton() {\n * async function handlePress() {\n * try {\n * const result = await submitGameCenterLeaderBoardScore({ score: '123.45' });\n *\n * if (!result) {\n * console.warn('지원하지 않는 앱 버전이에요.');\n * return;\n * }\n *\n * if (result.statusCode === 'SUCCESS') {\n * console.log('점수 제출 성공!');\n * } else {\n * console.error('점수 제출 실패:', result.statusCode);\n * }\n * } catch (error) {\n * console.error('점수 제출 중 오류가 발생했어요.', error);\n * }\n * }\n *\n * return (\n * <Button onPress={handlePress}>점수 제출하기</Button>\n * );\n * }\n * ```\n */\nexport declare function submitGameCenterLeaderBoardScore(params: {\n\tscore: string;\n}): Promise<SubmitGameCenterLeaderBoardScoreResponse | undefined>;\n\nexport {};\n"
|
|
109
109
|
},
|
|
110
|
+
{
|
|
111
|
+
"identifier": "getAnonymousKey",
|
|
112
|
+
"dts": "export interface GetAnonymousKeySuccessResponse {\n\thash: string;\n\ttype: \"HASH\";\n}\nexport type GetAnonymousKeyResponse = GetAnonymousKeySuccessResponse;\n/**\n * @public\n * @name getAnonymousKey\n * @description\n * 미니앱에서 사용자의 고유 키를 가져와요. 이 키를 사용해서 사용자를 식별하고 데이터를 관리할 수 있어요.\n * @returns {Promise<GetAnonymousKeyResponse | 'ERROR' | undefined>}\n * 사용자 키 조회 결과를 반환해요.\n * - `GetAnonymousKeyResponse`: 사용자 키 조회에 성공했어요. `{ type: 'HASH', hash: string }` 형태로 반환돼요.\n * - `'ERROR'`: 알 수 없는 오류가 발생했어요.\n * - `undefined`: 앱 버전이 최소 지원 버전보다 낮아요.\n *\n * @example\n * ```tsx\n * // react-native\n * import { Button } from 'react-native';\n * import { getAnonymousKey } from '@apps-in-toss/framework';\n *\n * function UserKeyButton() {\n * async function handlePress() {\n * const result = await getAnonymousKey();\n *\n * if (!result) {\n * console.warn('지원하지 않는 앱 버전이에요.');\n * return;\n * }\n *\n * if (result === 'ERROR') {\n * console.error('사용자 키 조회 중 오류가 발생했어요.');\n * return;\n * }\n *\n * if (result.type === 'HASH') {\n * console.log('사용자 키:', result.hash);\n * // 여기에서 사용자 키를 사용해 데이터를 관리할 수 있어요.\n * }\n * }\n *\n * return (\n * <Button onPress={handlePress} title=\"유저 키 가져오기\" />\n * );\n * }\n * ```\n *\n * @example\n * ```tsx\n * // webview\n * import { getAnonymousKey } from '@apps-in-toss/web-framework';\n *\n * function UserKeyButton() {\n * async function handleClick() {\n * const result = await getAnonymousKey();\n *\n * if (!result) {\n * console.warn('지원하지 않는 앱 버전이에요.');\n * return;\n * }\n *\n * if (result === 'ERROR') {\n * console.error('사용자 키 조회 중 오류가 발생했어요.');\n * return;\n * }\n *\n * if (result.type === 'HASH') {\n * console.log('사용자 키:', result.hash);\n * // 여기에서 사용자 키를 사용해 데이터를 관리할 수 있어요.\n * }\n * }\n *\n * return (\n * <button onClick={handleClick}>유저 키 가져오기</button>\n * );\n * }\n * ```\n */\nexport declare function getAnonymousKey(): Promise<GetAnonymousKeySuccessResponse | \"ERROR\" | undefined>;\n\nexport {};\n"
|
|
113
|
+
},
|
|
110
114
|
{
|
|
111
115
|
"identifier": "getUserKeyForGame",
|
|
112
|
-
"dts": "export interface
|
|
116
|
+
"dts": "export interface GetAnonymousKeySuccessResponse {\n\thash: string;\n\ttype: \"HASH\";\n}\nexport type GetAnonymousKeyResponse = GetAnonymousKeySuccessResponse;\n/**\n * @deprecated 이 타입은 더 이상 사용되지 않습니다. 대신 {@link GetAnonymousKeySuccessResponse}를 사용해주세요.\n */\nexport type GetUserKeyForGameSuccessResponse = GetAnonymousKeySuccessResponse;\n/**\n * @deprecated 이 타입은 더 이상 사용되지 않습니다.\n */\nexport type GetUserKeyForGameErrorResponse = {\n\ttype: \"NOT_AVAILABLE\";\n};\n/**\n * @deprecated 이 타입은 더 이상 사용되지 않습니다. 대신 {@link GetAnonymousKeyResponse}를 사용해주세요.\n */\nexport type GetUserKeyForGameResponse = GetAnonymousKeyResponse | GetUserKeyForGameErrorResponse;\n/**\n *\n * @deprecated 이 함수는 더 이상 사용되지 않습니다. 대신 {@link getAnonymousKey}를 사용해주세요.\n */\nexport declare function getUserKeyForGame(): Promise<GetUserKeyForGameSuccessResponse | \"INVALID_CATEGORY\" | \"ERROR\" | undefined>;\n\nexport {};\n"
|
|
113
117
|
},
|
|
114
118
|
{
|
|
115
119
|
"identifier": "grantPromotionReward",
|
package/dist/index.cjs
CHANGED
|
@@ -37,6 +37,7 @@ __export(index_exports, {
|
|
|
37
37
|
fetchAlbumPhotos: () => fetchAlbumPhotos,
|
|
38
38
|
fetchContacts: () => fetchContacts,
|
|
39
39
|
generateHapticFeedback: () => generateHapticFeedback,
|
|
40
|
+
getAnonymousKey: () => getAnonymousKey,
|
|
40
41
|
getClipboardText: () => getClipboardText,
|
|
41
42
|
getCurrentLocation: () => getCurrentLocation,
|
|
42
43
|
getDeviceId: () => getDeviceId,
|
|
@@ -888,7 +889,7 @@ var GAME_CENTER_MIN_VERSION = {
|
|
|
888
889
|
android: "5.221.0",
|
|
889
890
|
ios: "5.221.0"
|
|
890
891
|
};
|
|
891
|
-
var
|
|
892
|
+
var USER_KEY_MIN_VERSION = {
|
|
892
893
|
android: "5.232.0",
|
|
893
894
|
ios: "5.232.0"
|
|
894
895
|
};
|
|
@@ -938,9 +939,9 @@ async function submitGameCenterLeaderBoardScore(params) {
|
|
|
938
939
|
return safePostMessage("submitGameCenterLeaderBoardScore", params);
|
|
939
940
|
}
|
|
940
941
|
|
|
941
|
-
// src/MiniAppModule/native-modules/
|
|
942
|
-
async function
|
|
943
|
-
const isSupported = isMinVersionSupported(
|
|
942
|
+
// src/MiniAppModule/native-modules/getAnonymousKey.ts
|
|
943
|
+
async function getAnonymousKey() {
|
|
944
|
+
const isSupported = isMinVersionSupported(USER_KEY_MIN_VERSION);
|
|
944
945
|
if (!isSupported) {
|
|
945
946
|
return;
|
|
946
947
|
}
|
|
@@ -949,15 +950,17 @@ async function getUserKeyForGame() {
|
|
|
949
950
|
if (response.type === "HASH") {
|
|
950
951
|
return response;
|
|
951
952
|
}
|
|
952
|
-
if (response.type === "NOT_AVAILABLE") {
|
|
953
|
-
return "INVALID_CATEGORY";
|
|
954
|
-
}
|
|
955
953
|
return "ERROR";
|
|
956
|
-
} catch
|
|
954
|
+
} catch {
|
|
957
955
|
return "ERROR";
|
|
958
956
|
}
|
|
959
957
|
}
|
|
960
958
|
|
|
959
|
+
// src/MiniAppModule/native-modules/getUserKeyForGame.ts
|
|
960
|
+
async function getUserKeyForGame() {
|
|
961
|
+
return getAnonymousKey();
|
|
962
|
+
}
|
|
963
|
+
|
|
961
964
|
// src/MiniAppModule/native-modules/grantPromotionReward.ts
|
|
962
965
|
function isGrantPromotionRewardError(error) {
|
|
963
966
|
return typeof error === "object" && error !== null && "code" in error && typeof error.code === "string" && "message" in error && typeof error.message === "string";
|
|
@@ -1206,6 +1209,7 @@ var INTERNAL__module = {
|
|
|
1206
1209
|
fetchAlbumPhotos,
|
|
1207
1210
|
fetchContacts,
|
|
1208
1211
|
generateHapticFeedback,
|
|
1212
|
+
getAnonymousKey,
|
|
1209
1213
|
getClipboardText,
|
|
1210
1214
|
getCurrentLocation,
|
|
1211
1215
|
getDeviceId,
|
package/dist/index.d.cts
CHANGED
|
@@ -168,25 +168,19 @@ type GameCenterGameProfileResponse = {
|
|
|
168
168
|
*/
|
|
169
169
|
declare function getGameCenterGameProfile(): Promise<GameCenterGameProfileResponse | undefined>;
|
|
170
170
|
|
|
171
|
-
interface
|
|
171
|
+
interface GetAnonymousKeySuccessResponse {
|
|
172
172
|
hash: string;
|
|
173
173
|
type: 'HASH';
|
|
174
174
|
}
|
|
175
|
-
|
|
176
|
-
type: 'NOT_AVAILABLE';
|
|
177
|
-
}
|
|
178
|
-
type GetUserKeyForGameResponse = GetUserKeyForGameSuccessResponse | GetUserKeyForGameErrorResponse;
|
|
175
|
+
type GetAnonymousKeyResponse = GetAnonymousKeySuccessResponse;
|
|
179
176
|
/**
|
|
180
177
|
* @public
|
|
181
|
-
* @
|
|
182
|
-
* @name getUserKeyForGame
|
|
178
|
+
* @name getAnonymousKey
|
|
183
179
|
* @description
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
* @returns {Promise<GetUserKeyForGameSuccessResponse | 'INVALID_CATEGORY' | 'ERROR' | undefined>}
|
|
180
|
+
* 미니앱에서 사용자의 고유 키를 가져와요. 이 키를 사용해서 사용자를 식별하고 데이터를 관리할 수 있어요.
|
|
181
|
+
* @returns {Promise<GetAnonymousKeyResponse | 'ERROR' | undefined>}
|
|
187
182
|
* 사용자 키 조회 결과를 반환해요.
|
|
188
|
-
* - `
|
|
189
|
-
* - `'INVALID_CATEGORY'`: 게임 카테고리가 아닌 미니앱에서 호출했어요.
|
|
183
|
+
* - `GetAnonymousKeyResponse`: 사용자 키 조회에 성공했어요. `{ type: 'HASH', hash: string }` 형태로 반환돼요.
|
|
190
184
|
* - `'ERROR'`: 알 수 없는 오류가 발생했어요.
|
|
191
185
|
* - `undefined`: 앱 버전이 최소 지원 버전보다 낮아요.
|
|
192
186
|
*
|
|
@@ -194,31 +188,26 @@ type GetUserKeyForGameResponse = GetUserKeyForGameSuccessResponse | GetUserKeyFo
|
|
|
194
188
|
* ```tsx
|
|
195
189
|
* // react-native
|
|
196
190
|
* import { Button } from 'react-native';
|
|
197
|
-
* import {
|
|
191
|
+
* import { getAnonymousKey } from '@apps-in-toss/framework';
|
|
198
192
|
*
|
|
199
|
-
* function
|
|
193
|
+
* function UserKeyButton() {
|
|
200
194
|
* async function handlePress() {
|
|
201
|
-
*
|
|
202
|
-
*
|
|
203
|
-
* if (!result) {
|
|
204
|
-
* console.warn('지원하지 않는 앱 버전이에요.');
|
|
205
|
-
* return;
|
|
206
|
-
* }
|
|
195
|
+
* const result = await getAnonymousKey();
|
|
207
196
|
*
|
|
208
|
-
*
|
|
209
|
-
*
|
|
210
|
-
*
|
|
211
|
-
*
|
|
197
|
+
* if (!result) {
|
|
198
|
+
* console.warn('지원하지 않는 앱 버전이에요.');
|
|
199
|
+
* return;
|
|
200
|
+
* }
|
|
212
201
|
*
|
|
213
|
-
*
|
|
214
|
-
*
|
|
215
|
-
*
|
|
216
|
-
*
|
|
202
|
+
* if (result === 'ERROR') {
|
|
203
|
+
* console.error('사용자 키 조회 중 오류가 발생했어요.');
|
|
204
|
+
* return;
|
|
205
|
+
* }
|
|
217
206
|
*
|
|
218
|
-
*
|
|
219
|
-
*
|
|
220
|
-
*
|
|
221
|
-
*
|
|
207
|
+
* if (result.type === 'HASH') {
|
|
208
|
+
* console.log('사용자 키:', result.hash);
|
|
209
|
+
* // 여기에서 사용자 키를 사용해 데이터를 관리할 수 있어요.
|
|
210
|
+
* }
|
|
222
211
|
* }
|
|
223
212
|
*
|
|
224
213
|
* return (
|
|
@@ -230,31 +219,26 @@ type GetUserKeyForGameResponse = GetUserKeyForGameSuccessResponse | GetUserKeyFo
|
|
|
230
219
|
* @example
|
|
231
220
|
* ```tsx
|
|
232
221
|
* // webview
|
|
233
|
-
* import {
|
|
222
|
+
* import { getAnonymousKey } from '@apps-in-toss/web-framework';
|
|
234
223
|
*
|
|
235
|
-
* function
|
|
224
|
+
* function UserKeyButton() {
|
|
236
225
|
* async function handleClick() {
|
|
237
|
-
*
|
|
238
|
-
*
|
|
239
|
-
* if (!result) {
|
|
240
|
-
* console.warn('지원하지 않는 앱 버전이에요.');
|
|
241
|
-
* return;
|
|
242
|
-
* }
|
|
226
|
+
* const result = await getAnonymousKey();
|
|
243
227
|
*
|
|
244
|
-
*
|
|
245
|
-
*
|
|
246
|
-
*
|
|
247
|
-
*
|
|
228
|
+
* if (!result) {
|
|
229
|
+
* console.warn('지원하지 않는 앱 버전이에요.');
|
|
230
|
+
* return;
|
|
231
|
+
* }
|
|
248
232
|
*
|
|
249
|
-
*
|
|
250
|
-
*
|
|
251
|
-
*
|
|
252
|
-
*
|
|
233
|
+
* if (result === 'ERROR') {
|
|
234
|
+
* console.error('사용자 키 조회 중 오류가 발생했어요.');
|
|
235
|
+
* return;
|
|
236
|
+
* }
|
|
253
237
|
*
|
|
254
|
-
*
|
|
255
|
-
*
|
|
256
|
-
*
|
|
257
|
-
*
|
|
238
|
+
* if (result.type === 'HASH') {
|
|
239
|
+
* console.log('사용자 키:', result.hash);
|
|
240
|
+
* // 여기에서 사용자 키를 사용해 데이터를 관리할 수 있어요.
|
|
241
|
+
* }
|
|
258
242
|
* }
|
|
259
243
|
*
|
|
260
244
|
* return (
|
|
@@ -263,6 +247,26 @@ type GetUserKeyForGameResponse = GetUserKeyForGameSuccessResponse | GetUserKeyFo
|
|
|
263
247
|
* }
|
|
264
248
|
* ```
|
|
265
249
|
*/
|
|
250
|
+
declare function getAnonymousKey(): Promise<GetAnonymousKeySuccessResponse | 'ERROR' | undefined>;
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* @deprecated 이 타입은 더 이상 사용되지 않습니다. 대신 {@link GetAnonymousKeySuccessResponse}를 사용해주세요.
|
|
254
|
+
*/
|
|
255
|
+
type GetUserKeyForGameSuccessResponse = GetAnonymousKeySuccessResponse;
|
|
256
|
+
/**
|
|
257
|
+
* @deprecated 이 타입은 더 이상 사용되지 않습니다.
|
|
258
|
+
*/
|
|
259
|
+
type GetUserKeyForGameErrorResponse = {
|
|
260
|
+
type: 'NOT_AVAILABLE';
|
|
261
|
+
};
|
|
262
|
+
/**
|
|
263
|
+
* @deprecated 이 타입은 더 이상 사용되지 않습니다. 대신 {@link GetAnonymousKeyResponse}를 사용해주세요.
|
|
264
|
+
*/
|
|
265
|
+
type GetUserKeyForGameResponse = GetAnonymousKeyResponse | GetUserKeyForGameErrorResponse;
|
|
266
|
+
/**
|
|
267
|
+
*
|
|
268
|
+
* @deprecated 이 함수는 더 이상 사용되지 않습니다. 대신 {@link getAnonymousKey}를 사용해주세요.
|
|
269
|
+
*/
|
|
266
270
|
declare function getUserKeyForGame(): Promise<GetUserKeyForGameSuccessResponse | 'INVALID_CATEGORY' | 'ERROR' | undefined>;
|
|
267
271
|
|
|
268
272
|
interface GrantPromotionRewardForGameSuccessResponse {
|
|
@@ -1104,6 +1108,7 @@ interface AsyncMethodsMap {
|
|
|
1104
1108
|
appsInTossSignTossCert: (params: AppsInTossSignTossCertParams) => Promise<void>;
|
|
1105
1109
|
getGameCenterGameProfile: (params: CompatiblePlaceholderArgument) => Promise<GameCenterGameProfileResponse | undefined>;
|
|
1106
1110
|
getUserKeyForGame: (params: CompatiblePlaceholderArgument) => Promise<GetUserKeyForGameResponse | undefined>;
|
|
1111
|
+
getUserKey: (params: CompatiblePlaceholderArgument) => Promise<GetAnonymousKeyResponse | undefined>;
|
|
1107
1112
|
grantPromotionRewardForGame: (params: {
|
|
1108
1113
|
promotionCode: string;
|
|
1109
1114
|
amount: number;
|
|
@@ -3310,4 +3315,4 @@ declare const INTERNAL__module: {
|
|
|
3310
3315
|
tossCoreEventLog: typeof tossCoreEventLog;
|
|
3311
3316
|
};
|
|
3312
3317
|
|
|
3313
|
-
export { type AppsInTossSignTossCertParams, type CheckoutPaymentOptions, type CheckoutPaymentResult, type CompletedOrRefundedOrdersResult, type ConsumableProductListItem, type ContactsViralParams, type CreateSubscriptionPurchaseOrderOptions, type EventLogParams, type GameCenterGameProfileResponse, type GetUserKeyForGameErrorResponse, type GetUserKeyForGameResponse, type GetUserKeyForGameSuccessResponse, GoogleAdMob, type GrantPromotionRewardErrorResponse, type GrantPromotionRewardErrorResult, type GrantPromotionRewardForGameErrorResponse, type GrantPromotionRewardForGameErrorResult, type GrantPromotionRewardForGameResponse, type GrantPromotionRewardForGameSuccessResponse, type GrantPromotionRewardResponse, type GrantPromotionRewardSuccessResponse, type HapticFeedbackType, IAP, INTERNAL__appBridgeHandler, INTERNAL__module, type IapCreateOneTimePurchaseOrderOptions, type IapCreateOneTimePurchaseOrderResult, type IapCreateSubscriptionPurchaseOrderResult, type IapProductListItem, type IapSubscriptionInfoResult, type NetworkStatus, type NonConsumableProductListItem, type Primitive, type SaveBase64DataParams, Storage, type SubmitGameCenterLeaderBoardScoreResponse, type SubscriptionProductListItem, TossPay, type UpdateLocationEventEmitter, appLogin, appsInTossEvent, appsInTossSignTossCert, checkoutPayment, closeView, contactsViral, eventLog, fetchAlbumPhotos, fetchContacts, generateHapticFeedback, getClipboardText, getCurrentLocation, getDeviceId, getGameCenterGameProfile, getGroupId, getIsTossLoginIntegratedService, getLocale, getNetworkStatus, getOperationalEnvironment, getPlatformOS, getSchemeUri, getServerTime, getTossAppVersion, getTossShareLink, getUserKeyForGame, grantPromotionReward, grantPromotionRewardForGame, iapCreateOneTimePurchaseOrder, isMinVersionSupported, onVisibilityChangedByTransparentServiceWeb, openCamera, openGameCenterLeaderboard, openURL, processProductGrant, requestOneTimePurchase, requestReview, safePostMessage, safeSyncPostMessage, saveBase64Data, setClipboardText, setDeviceOrientation, setIosSwipeGestureEnabled, setScreenAwakeMode, setSecureScreen, share, shareWithScheme, startUpdateLocation, submitGameCenterLeaderBoardScore };
|
|
3318
|
+
export { type AppsInTossSignTossCertParams, type CheckoutPaymentOptions, type CheckoutPaymentResult, type CompletedOrRefundedOrdersResult, type ConsumableProductListItem, type ContactsViralParams, type CreateSubscriptionPurchaseOrderOptions, type EventLogParams, type GameCenterGameProfileResponse, type GetAnonymousKeyResponse, type GetAnonymousKeySuccessResponse, type GetUserKeyForGameErrorResponse, type GetUserKeyForGameResponse, type GetUserKeyForGameSuccessResponse, GoogleAdMob, type GrantPromotionRewardErrorResponse, type GrantPromotionRewardErrorResult, type GrantPromotionRewardForGameErrorResponse, type GrantPromotionRewardForGameErrorResult, type GrantPromotionRewardForGameResponse, type GrantPromotionRewardForGameSuccessResponse, type GrantPromotionRewardResponse, type GrantPromotionRewardSuccessResponse, type HapticFeedbackType, IAP, INTERNAL__appBridgeHandler, INTERNAL__module, type IapCreateOneTimePurchaseOrderOptions, type IapCreateOneTimePurchaseOrderResult, type IapCreateSubscriptionPurchaseOrderResult, type IapProductListItem, type IapSubscriptionInfoResult, type NetworkStatus, type NonConsumableProductListItem, type Primitive, type SaveBase64DataParams, Storage, type SubmitGameCenterLeaderBoardScoreResponse, type SubscriptionProductListItem, TossPay, type UpdateLocationEventEmitter, appLogin, appsInTossEvent, appsInTossSignTossCert, checkoutPayment, closeView, contactsViral, eventLog, fetchAlbumPhotos, fetchContacts, generateHapticFeedback, getAnonymousKey, getClipboardText, getCurrentLocation, getDeviceId, getGameCenterGameProfile, getGroupId, getIsTossLoginIntegratedService, getLocale, getNetworkStatus, getOperationalEnvironment, getPlatformOS, getSchemeUri, getServerTime, getTossAppVersion, getTossShareLink, getUserKeyForGame, grantPromotionReward, grantPromotionRewardForGame, iapCreateOneTimePurchaseOrder, isMinVersionSupported, onVisibilityChangedByTransparentServiceWeb, openCamera, openGameCenterLeaderboard, openURL, processProductGrant, requestOneTimePurchase, requestReview, safePostMessage, safeSyncPostMessage, saveBase64Data, setClipboardText, setDeviceOrientation, setIosSwipeGestureEnabled, setScreenAwakeMode, setSecureScreen, share, shareWithScheme, startUpdateLocation, submitGameCenterLeaderBoardScore };
|
package/dist/index.d.ts
CHANGED
|
@@ -168,25 +168,19 @@ type GameCenterGameProfileResponse = {
|
|
|
168
168
|
*/
|
|
169
169
|
declare function getGameCenterGameProfile(): Promise<GameCenterGameProfileResponse | undefined>;
|
|
170
170
|
|
|
171
|
-
interface
|
|
171
|
+
interface GetAnonymousKeySuccessResponse {
|
|
172
172
|
hash: string;
|
|
173
173
|
type: 'HASH';
|
|
174
174
|
}
|
|
175
|
-
|
|
176
|
-
type: 'NOT_AVAILABLE';
|
|
177
|
-
}
|
|
178
|
-
type GetUserKeyForGameResponse = GetUserKeyForGameSuccessResponse | GetUserKeyForGameErrorResponse;
|
|
175
|
+
type GetAnonymousKeyResponse = GetAnonymousKeySuccessResponse;
|
|
179
176
|
/**
|
|
180
177
|
* @public
|
|
181
|
-
* @
|
|
182
|
-
* @name getUserKeyForGame
|
|
178
|
+
* @name getAnonymousKey
|
|
183
179
|
* @description
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
* @returns {Promise<GetUserKeyForGameSuccessResponse | 'INVALID_CATEGORY' | 'ERROR' | undefined>}
|
|
180
|
+
* 미니앱에서 사용자의 고유 키를 가져와요. 이 키를 사용해서 사용자를 식별하고 데이터를 관리할 수 있어요.
|
|
181
|
+
* @returns {Promise<GetAnonymousKeyResponse | 'ERROR' | undefined>}
|
|
187
182
|
* 사용자 키 조회 결과를 반환해요.
|
|
188
|
-
* - `
|
|
189
|
-
* - `'INVALID_CATEGORY'`: 게임 카테고리가 아닌 미니앱에서 호출했어요.
|
|
183
|
+
* - `GetAnonymousKeyResponse`: 사용자 키 조회에 성공했어요. `{ type: 'HASH', hash: string }` 형태로 반환돼요.
|
|
190
184
|
* - `'ERROR'`: 알 수 없는 오류가 발생했어요.
|
|
191
185
|
* - `undefined`: 앱 버전이 최소 지원 버전보다 낮아요.
|
|
192
186
|
*
|
|
@@ -194,31 +188,26 @@ type GetUserKeyForGameResponse = GetUserKeyForGameSuccessResponse | GetUserKeyFo
|
|
|
194
188
|
* ```tsx
|
|
195
189
|
* // react-native
|
|
196
190
|
* import { Button } from 'react-native';
|
|
197
|
-
* import {
|
|
191
|
+
* import { getAnonymousKey } from '@apps-in-toss/framework';
|
|
198
192
|
*
|
|
199
|
-
* function
|
|
193
|
+
* function UserKeyButton() {
|
|
200
194
|
* async function handlePress() {
|
|
201
|
-
*
|
|
202
|
-
*
|
|
203
|
-
* if (!result) {
|
|
204
|
-
* console.warn('지원하지 않는 앱 버전이에요.');
|
|
205
|
-
* return;
|
|
206
|
-
* }
|
|
195
|
+
* const result = await getAnonymousKey();
|
|
207
196
|
*
|
|
208
|
-
*
|
|
209
|
-
*
|
|
210
|
-
*
|
|
211
|
-
*
|
|
197
|
+
* if (!result) {
|
|
198
|
+
* console.warn('지원하지 않는 앱 버전이에요.');
|
|
199
|
+
* return;
|
|
200
|
+
* }
|
|
212
201
|
*
|
|
213
|
-
*
|
|
214
|
-
*
|
|
215
|
-
*
|
|
216
|
-
*
|
|
202
|
+
* if (result === 'ERROR') {
|
|
203
|
+
* console.error('사용자 키 조회 중 오류가 발생했어요.');
|
|
204
|
+
* return;
|
|
205
|
+
* }
|
|
217
206
|
*
|
|
218
|
-
*
|
|
219
|
-
*
|
|
220
|
-
*
|
|
221
|
-
*
|
|
207
|
+
* if (result.type === 'HASH') {
|
|
208
|
+
* console.log('사용자 키:', result.hash);
|
|
209
|
+
* // 여기에서 사용자 키를 사용해 데이터를 관리할 수 있어요.
|
|
210
|
+
* }
|
|
222
211
|
* }
|
|
223
212
|
*
|
|
224
213
|
* return (
|
|
@@ -230,31 +219,26 @@ type GetUserKeyForGameResponse = GetUserKeyForGameSuccessResponse | GetUserKeyFo
|
|
|
230
219
|
* @example
|
|
231
220
|
* ```tsx
|
|
232
221
|
* // webview
|
|
233
|
-
* import {
|
|
222
|
+
* import { getAnonymousKey } from '@apps-in-toss/web-framework';
|
|
234
223
|
*
|
|
235
|
-
* function
|
|
224
|
+
* function UserKeyButton() {
|
|
236
225
|
* async function handleClick() {
|
|
237
|
-
*
|
|
238
|
-
*
|
|
239
|
-
* if (!result) {
|
|
240
|
-
* console.warn('지원하지 않는 앱 버전이에요.');
|
|
241
|
-
* return;
|
|
242
|
-
* }
|
|
226
|
+
* const result = await getAnonymousKey();
|
|
243
227
|
*
|
|
244
|
-
*
|
|
245
|
-
*
|
|
246
|
-
*
|
|
247
|
-
*
|
|
228
|
+
* if (!result) {
|
|
229
|
+
* console.warn('지원하지 않는 앱 버전이에요.');
|
|
230
|
+
* return;
|
|
231
|
+
* }
|
|
248
232
|
*
|
|
249
|
-
*
|
|
250
|
-
*
|
|
251
|
-
*
|
|
252
|
-
*
|
|
233
|
+
* if (result === 'ERROR') {
|
|
234
|
+
* console.error('사용자 키 조회 중 오류가 발생했어요.');
|
|
235
|
+
* return;
|
|
236
|
+
* }
|
|
253
237
|
*
|
|
254
|
-
*
|
|
255
|
-
*
|
|
256
|
-
*
|
|
257
|
-
*
|
|
238
|
+
* if (result.type === 'HASH') {
|
|
239
|
+
* console.log('사용자 키:', result.hash);
|
|
240
|
+
* // 여기에서 사용자 키를 사용해 데이터를 관리할 수 있어요.
|
|
241
|
+
* }
|
|
258
242
|
* }
|
|
259
243
|
*
|
|
260
244
|
* return (
|
|
@@ -263,6 +247,26 @@ type GetUserKeyForGameResponse = GetUserKeyForGameSuccessResponse | GetUserKeyFo
|
|
|
263
247
|
* }
|
|
264
248
|
* ```
|
|
265
249
|
*/
|
|
250
|
+
declare function getAnonymousKey(): Promise<GetAnonymousKeySuccessResponse | 'ERROR' | undefined>;
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* @deprecated 이 타입은 더 이상 사용되지 않습니다. 대신 {@link GetAnonymousKeySuccessResponse}를 사용해주세요.
|
|
254
|
+
*/
|
|
255
|
+
type GetUserKeyForGameSuccessResponse = GetAnonymousKeySuccessResponse;
|
|
256
|
+
/**
|
|
257
|
+
* @deprecated 이 타입은 더 이상 사용되지 않습니다.
|
|
258
|
+
*/
|
|
259
|
+
type GetUserKeyForGameErrorResponse = {
|
|
260
|
+
type: 'NOT_AVAILABLE';
|
|
261
|
+
};
|
|
262
|
+
/**
|
|
263
|
+
* @deprecated 이 타입은 더 이상 사용되지 않습니다. 대신 {@link GetAnonymousKeyResponse}를 사용해주세요.
|
|
264
|
+
*/
|
|
265
|
+
type GetUserKeyForGameResponse = GetAnonymousKeyResponse | GetUserKeyForGameErrorResponse;
|
|
266
|
+
/**
|
|
267
|
+
*
|
|
268
|
+
* @deprecated 이 함수는 더 이상 사용되지 않습니다. 대신 {@link getAnonymousKey}를 사용해주세요.
|
|
269
|
+
*/
|
|
266
270
|
declare function getUserKeyForGame(): Promise<GetUserKeyForGameSuccessResponse | 'INVALID_CATEGORY' | 'ERROR' | undefined>;
|
|
267
271
|
|
|
268
272
|
interface GrantPromotionRewardForGameSuccessResponse {
|
|
@@ -1104,6 +1108,7 @@ interface AsyncMethodsMap {
|
|
|
1104
1108
|
appsInTossSignTossCert: (params: AppsInTossSignTossCertParams) => Promise<void>;
|
|
1105
1109
|
getGameCenterGameProfile: (params: CompatiblePlaceholderArgument) => Promise<GameCenterGameProfileResponse | undefined>;
|
|
1106
1110
|
getUserKeyForGame: (params: CompatiblePlaceholderArgument) => Promise<GetUserKeyForGameResponse | undefined>;
|
|
1111
|
+
getUserKey: (params: CompatiblePlaceholderArgument) => Promise<GetAnonymousKeyResponse | undefined>;
|
|
1107
1112
|
grantPromotionRewardForGame: (params: {
|
|
1108
1113
|
promotionCode: string;
|
|
1109
1114
|
amount: number;
|
|
@@ -3310,4 +3315,4 @@ declare const INTERNAL__module: {
|
|
|
3310
3315
|
tossCoreEventLog: typeof tossCoreEventLog;
|
|
3311
3316
|
};
|
|
3312
3317
|
|
|
3313
|
-
export { type AppsInTossSignTossCertParams, type CheckoutPaymentOptions, type CheckoutPaymentResult, type CompletedOrRefundedOrdersResult, type ConsumableProductListItem, type ContactsViralParams, type CreateSubscriptionPurchaseOrderOptions, type EventLogParams, type GameCenterGameProfileResponse, type GetUserKeyForGameErrorResponse, type GetUserKeyForGameResponse, type GetUserKeyForGameSuccessResponse, GoogleAdMob, type GrantPromotionRewardErrorResponse, type GrantPromotionRewardErrorResult, type GrantPromotionRewardForGameErrorResponse, type GrantPromotionRewardForGameErrorResult, type GrantPromotionRewardForGameResponse, type GrantPromotionRewardForGameSuccessResponse, type GrantPromotionRewardResponse, type GrantPromotionRewardSuccessResponse, type HapticFeedbackType, IAP, INTERNAL__appBridgeHandler, INTERNAL__module, type IapCreateOneTimePurchaseOrderOptions, type IapCreateOneTimePurchaseOrderResult, type IapCreateSubscriptionPurchaseOrderResult, type IapProductListItem, type IapSubscriptionInfoResult, type NetworkStatus, type NonConsumableProductListItem, type Primitive, type SaveBase64DataParams, Storage, type SubmitGameCenterLeaderBoardScoreResponse, type SubscriptionProductListItem, TossPay, type UpdateLocationEventEmitter, appLogin, appsInTossEvent, appsInTossSignTossCert, checkoutPayment, closeView, contactsViral, eventLog, fetchAlbumPhotos, fetchContacts, generateHapticFeedback, getClipboardText, getCurrentLocation, getDeviceId, getGameCenterGameProfile, getGroupId, getIsTossLoginIntegratedService, getLocale, getNetworkStatus, getOperationalEnvironment, getPlatformOS, getSchemeUri, getServerTime, getTossAppVersion, getTossShareLink, getUserKeyForGame, grantPromotionReward, grantPromotionRewardForGame, iapCreateOneTimePurchaseOrder, isMinVersionSupported, onVisibilityChangedByTransparentServiceWeb, openCamera, openGameCenterLeaderboard, openURL, processProductGrant, requestOneTimePurchase, requestReview, safePostMessage, safeSyncPostMessage, saveBase64Data, setClipboardText, setDeviceOrientation, setIosSwipeGestureEnabled, setScreenAwakeMode, setSecureScreen, share, shareWithScheme, startUpdateLocation, submitGameCenterLeaderBoardScore };
|
|
3318
|
+
export { type AppsInTossSignTossCertParams, type CheckoutPaymentOptions, type CheckoutPaymentResult, type CompletedOrRefundedOrdersResult, type ConsumableProductListItem, type ContactsViralParams, type CreateSubscriptionPurchaseOrderOptions, type EventLogParams, type GameCenterGameProfileResponse, type GetAnonymousKeyResponse, type GetAnonymousKeySuccessResponse, type GetUserKeyForGameErrorResponse, type GetUserKeyForGameResponse, type GetUserKeyForGameSuccessResponse, GoogleAdMob, type GrantPromotionRewardErrorResponse, type GrantPromotionRewardErrorResult, type GrantPromotionRewardForGameErrorResponse, type GrantPromotionRewardForGameErrorResult, type GrantPromotionRewardForGameResponse, type GrantPromotionRewardForGameSuccessResponse, type GrantPromotionRewardResponse, type GrantPromotionRewardSuccessResponse, type HapticFeedbackType, IAP, INTERNAL__appBridgeHandler, INTERNAL__module, type IapCreateOneTimePurchaseOrderOptions, type IapCreateOneTimePurchaseOrderResult, type IapCreateSubscriptionPurchaseOrderResult, type IapProductListItem, type IapSubscriptionInfoResult, type NetworkStatus, type NonConsumableProductListItem, type Primitive, type SaveBase64DataParams, Storage, type SubmitGameCenterLeaderBoardScoreResponse, type SubscriptionProductListItem, TossPay, type UpdateLocationEventEmitter, appLogin, appsInTossEvent, appsInTossSignTossCert, checkoutPayment, closeView, contactsViral, eventLog, fetchAlbumPhotos, fetchContacts, generateHapticFeedback, getAnonymousKey, getClipboardText, getCurrentLocation, getDeviceId, getGameCenterGameProfile, getGroupId, getIsTossLoginIntegratedService, getLocale, getNetworkStatus, getOperationalEnvironment, getPlatformOS, getSchemeUri, getServerTime, getTossAppVersion, getTossShareLink, getUserKeyForGame, grantPromotionReward, grantPromotionRewardForGame, iapCreateOneTimePurchaseOrder, isMinVersionSupported, onVisibilityChangedByTransparentServiceWeb, openCamera, openGameCenterLeaderboard, openURL, processProductGrant, requestOneTimePurchase, requestReview, safePostMessage, safeSyncPostMessage, saveBase64Data, setClipboardText, setDeviceOrientation, setIosSwipeGestureEnabled, setScreenAwakeMode, setSecureScreen, share, shareWithScheme, startUpdateLocation, submitGameCenterLeaderBoardScore };
|
package/dist/index.js
CHANGED
|
@@ -808,7 +808,7 @@ var GAME_CENTER_MIN_VERSION = {
|
|
|
808
808
|
android: "5.221.0",
|
|
809
809
|
ios: "5.221.0"
|
|
810
810
|
};
|
|
811
|
-
var
|
|
811
|
+
var USER_KEY_MIN_VERSION = {
|
|
812
812
|
android: "5.232.0",
|
|
813
813
|
ios: "5.232.0"
|
|
814
814
|
};
|
|
@@ -858,9 +858,9 @@ async function submitGameCenterLeaderBoardScore(params) {
|
|
|
858
858
|
return safePostMessage("submitGameCenterLeaderBoardScore", params);
|
|
859
859
|
}
|
|
860
860
|
|
|
861
|
-
// src/MiniAppModule/native-modules/
|
|
862
|
-
async function
|
|
863
|
-
const isSupported = isMinVersionSupported(
|
|
861
|
+
// src/MiniAppModule/native-modules/getAnonymousKey.ts
|
|
862
|
+
async function getAnonymousKey() {
|
|
863
|
+
const isSupported = isMinVersionSupported(USER_KEY_MIN_VERSION);
|
|
864
864
|
if (!isSupported) {
|
|
865
865
|
return;
|
|
866
866
|
}
|
|
@@ -869,15 +869,17 @@ async function getUserKeyForGame() {
|
|
|
869
869
|
if (response.type === "HASH") {
|
|
870
870
|
return response;
|
|
871
871
|
}
|
|
872
|
-
if (response.type === "NOT_AVAILABLE") {
|
|
873
|
-
return "INVALID_CATEGORY";
|
|
874
|
-
}
|
|
875
872
|
return "ERROR";
|
|
876
|
-
} catch
|
|
873
|
+
} catch {
|
|
877
874
|
return "ERROR";
|
|
878
875
|
}
|
|
879
876
|
}
|
|
880
877
|
|
|
878
|
+
// src/MiniAppModule/native-modules/getUserKeyForGame.ts
|
|
879
|
+
async function getUserKeyForGame() {
|
|
880
|
+
return getAnonymousKey();
|
|
881
|
+
}
|
|
882
|
+
|
|
881
883
|
// src/MiniAppModule/native-modules/grantPromotionReward.ts
|
|
882
884
|
function isGrantPromotionRewardError(error) {
|
|
883
885
|
return typeof error === "object" && error !== null && "code" in error && typeof error.code === "string" && "message" in error && typeof error.message === "string";
|
|
@@ -1125,6 +1127,7 @@ export {
|
|
|
1125
1127
|
fetchAlbumPhotos,
|
|
1126
1128
|
fetchContacts,
|
|
1127
1129
|
generateHapticFeedback,
|
|
1130
|
+
getAnonymousKey,
|
|
1128
1131
|
getClipboardText,
|
|
1129
1132
|
getCurrentLocation,
|
|
1130
1133
|
getDeviceId,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apps-in-toss/native-modules",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.4.
|
|
4
|
+
"version": "2.4.5",
|
|
5
5
|
"description": "Native Modules for Apps In Toss",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"typecheck": "tsc --noEmit",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"vitest": "^3.2.4"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@apps-in-toss/types": "2.4.
|
|
45
|
+
"@apps-in-toss/types": "2.4.5",
|
|
46
46
|
"brick-module": "0.5.0",
|
|
47
47
|
"es-toolkit": "^1.39.3"
|
|
48
48
|
},
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { isMinVersionSupported } from './isMinVersionSupported';
|
|
2
|
+
import { safePostMessage } from '../../natives';
|
|
3
|
+
import { USER_KEY_MIN_VERSION } from '../constants';
|
|
4
|
+
|
|
5
|
+
export interface GetAnonymousKeySuccessResponse {
|
|
6
|
+
hash: string;
|
|
7
|
+
type: 'HASH';
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export type GetAnonymousKeyResponse = GetAnonymousKeySuccessResponse;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @public
|
|
14
|
+
* @name getAnonymousKey
|
|
15
|
+
* @description
|
|
16
|
+
* 미니앱에서 사용자의 고유 키를 가져와요. 이 키를 사용해서 사용자를 식별하고 데이터를 관리할 수 있어요.
|
|
17
|
+
* @returns {Promise<GetAnonymousKeyResponse | 'ERROR' | undefined>}
|
|
18
|
+
* 사용자 키 조회 결과를 반환해요.
|
|
19
|
+
* - `GetAnonymousKeyResponse`: 사용자 키 조회에 성공했어요. `{ type: 'HASH', hash: string }` 형태로 반환돼요.
|
|
20
|
+
* - `'ERROR'`: 알 수 없는 오류가 발생했어요.
|
|
21
|
+
* - `undefined`: 앱 버전이 최소 지원 버전보다 낮아요.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```tsx
|
|
25
|
+
* // react-native
|
|
26
|
+
* import { Button } from 'react-native';
|
|
27
|
+
* import { getAnonymousKey } from '@apps-in-toss/framework';
|
|
28
|
+
*
|
|
29
|
+
* function UserKeyButton() {
|
|
30
|
+
* async function handlePress() {
|
|
31
|
+
* const result = await getAnonymousKey();
|
|
32
|
+
*
|
|
33
|
+
* if (!result) {
|
|
34
|
+
* console.warn('지원하지 않는 앱 버전이에요.');
|
|
35
|
+
* return;
|
|
36
|
+
* }
|
|
37
|
+
*
|
|
38
|
+
* if (result === 'ERROR') {
|
|
39
|
+
* console.error('사용자 키 조회 중 오류가 발생했어요.');
|
|
40
|
+
* return;
|
|
41
|
+
* }
|
|
42
|
+
*
|
|
43
|
+
* if (result.type === 'HASH') {
|
|
44
|
+
* console.log('사용자 키:', result.hash);
|
|
45
|
+
* // 여기에서 사용자 키를 사용해 데이터를 관리할 수 있어요.
|
|
46
|
+
* }
|
|
47
|
+
* }
|
|
48
|
+
*
|
|
49
|
+
* return (
|
|
50
|
+
* <Button onPress={handlePress} title="유저 키 가져오기" />
|
|
51
|
+
* );
|
|
52
|
+
* }
|
|
53
|
+
* ```
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```tsx
|
|
57
|
+
* // webview
|
|
58
|
+
* import { getAnonymousKey } from '@apps-in-toss/web-framework';
|
|
59
|
+
*
|
|
60
|
+
* function UserKeyButton() {
|
|
61
|
+
* async function handleClick() {
|
|
62
|
+
* const result = await getAnonymousKey();
|
|
63
|
+
*
|
|
64
|
+
* if (!result) {
|
|
65
|
+
* console.warn('지원하지 않는 앱 버전이에요.');
|
|
66
|
+
* return;
|
|
67
|
+
* }
|
|
68
|
+
*
|
|
69
|
+
* if (result === 'ERROR') {
|
|
70
|
+
* console.error('사용자 키 조회 중 오류가 발생했어요.');
|
|
71
|
+
* return;
|
|
72
|
+
* }
|
|
73
|
+
*
|
|
74
|
+
* if (result.type === 'HASH') {
|
|
75
|
+
* console.log('사용자 키:', result.hash);
|
|
76
|
+
* // 여기에서 사용자 키를 사용해 데이터를 관리할 수 있어요.
|
|
77
|
+
* }
|
|
78
|
+
* }
|
|
79
|
+
*
|
|
80
|
+
* return (
|
|
81
|
+
* <button onClick={handleClick}>유저 키 가져오기</button>
|
|
82
|
+
* );
|
|
83
|
+
* }
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
export async function getAnonymousKey(): Promise<GetAnonymousKeySuccessResponse | 'ERROR' | undefined> {
|
|
87
|
+
const isSupported = isMinVersionSupported(USER_KEY_MIN_VERSION);
|
|
88
|
+
|
|
89
|
+
if (!isSupported) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
try {
|
|
94
|
+
const response = (await safePostMessage('getUserKeyForGame', {})) as GetAnonymousKeyResponse;
|
|
95
|
+
if (response.type === 'HASH') {
|
|
96
|
+
return response;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return 'ERROR';
|
|
100
|
+
} catch {
|
|
101
|
+
return 'ERROR';
|
|
102
|
+
}
|
|
103
|
+
}
|
|
@@ -1,125 +1,28 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { safePostMessage } from '../../natives';
|
|
3
|
-
import { GAME_USER_KEY_MIN_VERSION } from '../constants';
|
|
1
|
+
import { getAnonymousKey, GetAnonymousKeyResponse, GetAnonymousKeySuccessResponse } from './getAnonymousKey';
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated 이 타입은 더 이상 사용되지 않습니다. 대신 {@link GetAnonymousKeySuccessResponse}를 사용해주세요.
|
|
5
|
+
*/
|
|
6
|
+
export type GetUserKeyForGameSuccessResponse = GetAnonymousKeySuccessResponse;
|
|
9
7
|
|
|
10
|
-
|
|
8
|
+
/**
|
|
9
|
+
* @deprecated 이 타입은 더 이상 사용되지 않습니다.
|
|
10
|
+
*/
|
|
11
|
+
export type GetUserKeyForGameErrorResponse = {
|
|
11
12
|
type: 'NOT_AVAILABLE';
|
|
12
13
|
}
|
|
13
14
|
|
|
14
|
-
|
|
15
|
+
/**
|
|
16
|
+
* @deprecated 이 타입은 더 이상 사용되지 않습니다. 대신 {@link GetAnonymousKeyResponse}를 사용해주세요.
|
|
17
|
+
*/
|
|
18
|
+
export type GetUserKeyForGameResponse = GetAnonymousKeyResponse | GetUserKeyForGameErrorResponse;
|
|
15
19
|
|
|
16
20
|
/**
|
|
17
|
-
* @public
|
|
18
|
-
* @category 게임
|
|
19
|
-
* @name getUserKeyForGame
|
|
20
|
-
* @description
|
|
21
|
-
* 게임 카테고리 미니앱에서 사용자의 고유 키를 가져와요. 이 키를 사용해서 사용자를 식별하고 게임 데이터를 관리할 수 있어요.
|
|
22
|
-
* 게임 카테고리가 아닌 미니앱에서 호출하면 `'INVALID_CATEGORY'`를 반환해요.
|
|
23
|
-
* @returns {Promise<GetUserKeyForGameSuccessResponse | 'INVALID_CATEGORY' | 'ERROR' | undefined>}
|
|
24
|
-
* 사용자 키 조회 결과를 반환해요.
|
|
25
|
-
* - `GetUserKeyForGameSuccessResponse`: 사용자 키 조회에 성공했어요. `{ type: 'HASH', hash: string }` 형태로 반환돼요.
|
|
26
|
-
* - `'INVALID_CATEGORY'`: 게임 카테고리가 아닌 미니앱에서 호출했어요.
|
|
27
|
-
* - `'ERROR'`: 알 수 없는 오류가 발생했어요.
|
|
28
|
-
* - `undefined`: 앱 버전이 최소 지원 버전보다 낮아요.
|
|
29
|
-
*
|
|
30
|
-
* @example
|
|
31
|
-
* ```tsx
|
|
32
|
-
* // react-native
|
|
33
|
-
* import { Button } from 'react-native';
|
|
34
|
-
* import { getUserKeyForGame } from '@apps-in-toss/framework';
|
|
35
|
-
*
|
|
36
|
-
* function GameUserKeyButton() {
|
|
37
|
-
* async function handlePress() {
|
|
38
|
-
* const result = await getUserKeyForGame();
|
|
39
|
-
*
|
|
40
|
-
* if (!result) {
|
|
41
|
-
* console.warn('지원하지 않는 앱 버전이에요.');
|
|
42
|
-
* return;
|
|
43
|
-
* }
|
|
44
|
-
*
|
|
45
|
-
* if (result === 'INVALID_CATEGORY') {
|
|
46
|
-
* console.error('게임 카테고리가 아닌 미니앱이에요.');
|
|
47
|
-
* return;
|
|
48
|
-
* }
|
|
49
21
|
*
|
|
50
|
-
*
|
|
51
|
-
* console.error('사용자 키 조회 중 오류가 발생했어요.');
|
|
52
|
-
* return;
|
|
53
|
-
* }
|
|
54
|
-
*
|
|
55
|
-
* if (result.type === 'HASH') {
|
|
56
|
-
* console.log('사용자 키:', result.hash);
|
|
57
|
-
* // 여기에서 사용자 키를 사용해 게임 데이터를 관리할 수 있어요.
|
|
58
|
-
* }
|
|
59
|
-
* }
|
|
60
|
-
*
|
|
61
|
-
* return (
|
|
62
|
-
* <Button onPress={handlePress} title="유저 키 가져오기" />
|
|
63
|
-
* );
|
|
64
|
-
* }
|
|
65
|
-
* ```
|
|
66
|
-
*
|
|
67
|
-
* @example
|
|
68
|
-
* ```tsx
|
|
69
|
-
* // webview
|
|
70
|
-
* import { getUserKeyForGame } from '@apps-in-toss/web-framework';
|
|
71
|
-
*
|
|
72
|
-
* function GameUserKeyButton() {
|
|
73
|
-
* async function handleClick() {
|
|
74
|
-
* const result = await getUserKeyForGame();
|
|
75
|
-
*
|
|
76
|
-
* if (!result) {
|
|
77
|
-
* console.warn('지원하지 않는 앱 버전이에요.');
|
|
78
|
-
* return;
|
|
79
|
-
* }
|
|
80
|
-
*
|
|
81
|
-
* if (result === 'INVALID_CATEGORY') {
|
|
82
|
-
* console.error('게임 카테고리가 아닌 미니앱이에요.');
|
|
83
|
-
* return;
|
|
84
|
-
* }
|
|
85
|
-
*
|
|
86
|
-
* if (result === 'ERROR') {
|
|
87
|
-
* console.error('사용자 키 조회 중 오류가 발생했어요.');
|
|
88
|
-
* return;
|
|
89
|
-
* }
|
|
90
|
-
*
|
|
91
|
-
* if (result.type === 'HASH') {
|
|
92
|
-
* console.log('사용자 키:', result.hash);
|
|
93
|
-
* // 여기에서 사용자 키를 사용해 게임 데이터를 관리할 수 있어요.
|
|
94
|
-
* }
|
|
95
|
-
* }
|
|
96
|
-
*
|
|
97
|
-
* return (
|
|
98
|
-
* <button onClick={handleClick}>유저 키 가져오기</button>
|
|
99
|
-
* );
|
|
100
|
-
* }
|
|
101
|
-
* ```
|
|
22
|
+
* @deprecated 이 함수는 더 이상 사용되지 않습니다. 대신 {@link getAnonymousKey}를 사용해주세요.
|
|
102
23
|
*/
|
|
103
24
|
export async function getUserKeyForGame(): Promise<
|
|
104
25
|
GetUserKeyForGameSuccessResponse | 'INVALID_CATEGORY' | 'ERROR' | undefined
|
|
105
26
|
> {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
if (!isSupported) {
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
try {
|
|
113
|
-
const response = (await safePostMessage('getUserKeyForGame', {})) as GetUserKeyForGameResponse;
|
|
114
|
-
if (response.type === 'HASH') {
|
|
115
|
-
return response;
|
|
116
|
-
}
|
|
117
|
-
if (response.type === 'NOT_AVAILABLE') {
|
|
118
|
-
return 'INVALID_CATEGORY';
|
|
119
|
-
}
|
|
120
|
-
return 'ERROR';
|
|
121
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
122
|
-
} catch (_) {
|
|
123
|
-
return 'ERROR';
|
|
124
|
-
}
|
|
27
|
+
return getAnonymousKey();
|
|
125
28
|
}
|
|
@@ -37,6 +37,7 @@ export * from './storage';
|
|
|
37
37
|
export * from './openGameCenterLeaderboard';
|
|
38
38
|
export * from './getGameCenterGameProfile';
|
|
39
39
|
export * from './submitGameCenterLeaderBoardScore';
|
|
40
|
+
export * from './getAnonymousKey';
|
|
40
41
|
export * from './getUserKeyForGame';
|
|
41
42
|
export * from './grantPromotionReward';
|
|
42
43
|
export * from './grantPromotionRewardForGame';
|
|
@@ -10,6 +10,7 @@ import type {
|
|
|
10
10
|
import type { AppsInTossSignTossCertParams } from './native-modules/appsInTossSignTossCert';
|
|
11
11
|
import type { CheckoutPaymentOptions, CheckoutPaymentResult } from './native-modules/checkoutPayment';
|
|
12
12
|
import type { GameCenterGameProfileResponse } from './native-modules/getGameCenterGameProfile';
|
|
13
|
+
import type { GetAnonymousKeyResponse } from './native-modules/getAnonymousKey';
|
|
13
14
|
import type { GetUserKeyForGameResponse } from './native-modules/getUserKeyForGame';
|
|
14
15
|
import type { GrantPromotionRewardForGameResponse } from './native-modules/grantPromotionRewardForGame';
|
|
15
16
|
import type { IapCreateOneTimePurchaseOrderResult, IapSubscriptionInfoResult } from './native-modules/iap';
|
|
@@ -72,6 +73,7 @@ export interface AsyncMethodsMap {
|
|
|
72
73
|
params: CompatiblePlaceholderArgument
|
|
73
74
|
) => Promise<GameCenterGameProfileResponse | undefined>;
|
|
74
75
|
getUserKeyForGame: (params: CompatiblePlaceholderArgument) => Promise<GetUserKeyForGameResponse | undefined>;
|
|
76
|
+
getUserKey: (params: CompatiblePlaceholderArgument) => Promise<GetAnonymousKeyResponse | undefined>;
|
|
75
77
|
grantPromotionRewardForGame: (params: {
|
|
76
78
|
promotionCode: string;
|
|
77
79
|
amount: number;
|
package/src/async-bridges.ts
CHANGED
|
@@ -28,6 +28,7 @@ export * from './MiniAppModule/native-modules/appsInTossSignTossCert';
|
|
|
28
28
|
export * from './MiniAppModule/native-modules/getGameCenterGameProfile';
|
|
29
29
|
export * from './MiniAppModule/native-modules/openGameCenterLeaderboard';
|
|
30
30
|
export * from './MiniAppModule/native-modules/submitGameCenterLeaderBoardScore';
|
|
31
|
+
export * from './MiniAppModule/native-modules/getAnonymousKey';
|
|
31
32
|
export * from './MiniAppModule/native-modules/getUserKeyForGame';
|
|
32
33
|
export * from './MiniAppModule/native-modules/grantPromotionReward';
|
|
33
34
|
export * from './MiniAppModule/native-modules/grantPromotionRewardForGame';
|