@apps-in-toss/native-modules 2.4.2 → 2.4.4

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.
@@ -73,7 +73,7 @@
73
73
  },
74
74
  {
75
75
  "identifier": "eventLog",
76
- "dts": "export type Primitive = string | number | boolean | null | undefined | symbol;\nexport interface EventLogParams {\n\tlog_name: string;\n\tlog_type: \"debug\" | \"info\" | \"warn\" | \"error\" | \"event\" | \"screen\" | \"impression\" | \"click\";\n\tparams: Record<string, Primitive>;\n}\n/**\n * @category 로깅\n * @kind function\n * @name eventLog\n * @description\n * 이벤트 로그를 기록하는 함수예요.\n *\n * 이 함수는 앱 내에서 발생하는 다양한 이벤트를 로깅하는 데 사용돼요. 디버깅, 정보 제공, 경고, 오류 등 다양한 유형의 로그를 기록할 수 있어요. 샌드박스 환경에서는 콘솔에 로그가 출력되고, 실제 환경에서는 로그 시스템에 기록돼요.\n *\n * @param {Object} params 로그 기록에 필요한 매개변수 객체예요.\n * @param {string} params.log_name 로그의 이름이에요.\n * @param {'debug' | 'info' | 'warn' | 'error' | 'event' | 'screen' | 'impression' | 'click'} params.log_type 로그의 유형이에요.\n * @param {Record<string, Primitive>} params.params 로그에 포함할 추가 매개변수 객체예요.\n *\n * @returns {Promise<void>} 로그 기록이 완료되면 해결되는 Promise예요.\n *\n * @example\n * ### 이벤트 로그 기록하기\n *\n * ```tsx\n * import { eventLog } from '@apps-in-toss/framework';\n *\n * function logUserAction() {\n * eventLog({\n * log_name: 'user_action',\n * log_type: 'info',\n * params: {\n * action: 'button_click',\n * screen: 'main',\n * userId: 12345\n * }\n * });\n * }\n * ```\n */\nexport declare function eventLog(params: EventLogParams): Promise<void>;\n\nexport {};\n"
76
+ "dts": "export type Primitive = string | number | boolean | null | undefined | symbol;\nexport interface EventLogParams {\n\tlog_name: string;\n\tlog_type: \"debug\" | \"info\" | \"warn\" | \"error\" | \"event\" | \"screen\" | \"impression\" | \"click\" | \"popup\";\n\tparams: Record<string, Primitive>;\n}\n/**\n * @category 로깅\n * @kind function\n * @name eventLog\n * @description\n * 이벤트 로그를 기록하는 함수예요.\n *\n * 이 함수는 앱 내에서 발생하는 다양한 이벤트를 로깅하는 데 사용돼요. 디버깅, 정보 제공, 경고, 오류 등 다양한 유형의 로그를 기록할 수 있어요. 샌드박스 환경에서는 콘솔에 로그가 출력되고, 실제 환경에서는 로그 시스템에 기록돼요.\n *\n * @param {Object} params 로그 기록에 필요한 매개변수 객체예요.\n * @param {string} params.log_name 로그의 이름이에요.\n * @param {'debug' | 'info' | 'warn' | 'error' | 'event' | 'screen' | 'impression' | 'click'} params.log_type 로그의 유형이에요.\n * @param {Record<string, Primitive>} params.params 로그에 포함할 추가 매개변수 객체예요.\n *\n * @returns {Promise<void>} 로그 기록이 완료되면 해결되는 Promise예요.\n *\n * @example\n * ### 이벤트 로그 기록하기\n *\n * ```tsx\n * import { eventLog } from '@apps-in-toss/framework';\n *\n * function logUserAction() {\n * eventLog({\n * log_name: 'user_action',\n * log_type: 'info',\n * params: {\n * action: 'button_click',\n * screen: 'main',\n * userId: 12345\n * }\n * });\n * }\n * ```\n */\nexport declare function eventLog(params: EventLogParams): Promise<void>;\n\nexport {};\n"
77
77
  },
78
78
  {
79
79
  "identifier": "getTossShareLink",
@@ -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": "getUserKey",
112
+ "dts": "export interface GetUserKeySuccessResponse {\n\thash: string;\n\ttype: \"HASH\";\n}\nexport interface GetUserKeyErrorResponse {\n\ttype: \"NOT_AVAILABLE\";\n}\nexport type GetUserKeyResponse = GetUserKeySuccessResponse | GetUserKeyErrorResponse;\n/**\n * @public\n * @name getUserKey\n * @description\n * 미니앱에서 사용자의 고유 키를 가져와요. 이 키를 사용해서 사용자를 식별하고 게임 데이터를 관리할 수 있어요.\n * @returns {Promise<GetUserKeySuccessResponse | 'ERROR' | undefined>}\n * 사용자 키 조회 결과를 반환해요.\n * - `GetUserKeySuccessResponse`: 사용자 키 조회에 성공했어요. `{ type: 'HASH', hash: string }` 형태로 반환돼요.\n * - `'ERROR'`: 알 수 없는 오류가 발생했어요.\n * - `undefined`: 앱 버전이 최소 지원 버전보다 낮아요.\n *\n * @example\n * ```tsx\n * // react-native\n * import { Button } from 'react-native';\n * import { getUserKey } from '@apps-in-toss/framework';\n *\n * function UserKeyButton() {\n * async function handlePress() {\n * const result = await getUserKey();\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 { getUserKey } from '@apps-in-toss/web-framework';\n *\n * function UserKeyButton() {\n * async function handleClick() {\n * const result = await getUserKey();\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 getUserKey(): Promise<GetUserKeySuccessResponse | \"ERROR\" | undefined>;\n\nexport {};\n"
113
+ },
110
114
  {
111
115
  "identifier": "getUserKeyForGame",
112
- "dts": "export interface GetUserKeyForGameSuccessResponse {\n\thash: string;\n\ttype: \"HASH\";\n}\nexport interface GetUserKeyForGameErrorResponse {\n\ttype: \"NOT_AVAILABLE\";\n}\nexport type GetUserKeyForGameResponse = GetUserKeyForGameSuccessResponse | GetUserKeyForGameErrorResponse;\n/**\n * @public\n * @category 게임\n * @name getUserKeyForGame\n * @description\n * 게임 카테고리 미니앱에서 사용자의 고유 키를 가져와요. 키를 사용해서 사용자를 식별하고 게임 데이터를 관리할 수 있어요.\n * 게임 카테고리가 아닌 미니앱에서 호출하면 `'INVALID_CATEGORY'`를 반환해요.\n * @returns {Promise<GetUserKeyForGameSuccessResponse | 'INVALID_CATEGORY' | 'ERROR' | undefined>}\n * 사용자 키 조회 결과를 반환해요.\n * - `GetUserKeyForGameSuccessResponse`: 사용자 키 조회에 성공했어요. `{ type: 'HASH', hash: string }` 형태로 반환돼요.\n * - `'INVALID_CATEGORY'`: 게임 카테고리가 아닌 미니앱에서 호출했어요.\n * - `'ERROR'`: 알 수 없는 오류가 발생했어요.\n * - `undefined`: 앱 버전이 최소 지원 버전보다 낮아요.\n *\n * @example\n * ```tsx\n * // react-native\n * import { Button } from 'react-native';\n * import { getUserKeyForGame } from '@apps-in-toss/framework';\n *\n * function GameUserKeyButton() {\n * async function handlePress() {\n * const result = await getUserKeyForGame();\n *\n * if (!result) {\n * console.warn('지원하지 않는 버전이에요.');\n * return;\n * }\n *\n * if (result === 'INVALID_CATEGORY') {\n * console.error('게임 카테고리가 아닌 미니앱이에요.');\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 { getUserKeyForGame } from '@apps-in-toss/web-framework';\n *\n * function GameUserKeyButton() {\n * async function handleClick() {\n * const result = await getUserKeyForGame();\n *\n * if (!result) {\n * console.warn('지원하지 않는 앱 버전이에요.');\n * return;\n * }\n *\n * if (result === 'INVALID_CATEGORY') {\n * console.error('게임 카테고리가 아닌 미니앱이에요.');\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 getUserKeyForGame(): Promise<GetUserKeyForGameSuccessResponse | \"INVALID_CATEGORY\" | \"ERROR\" | undefined>;\n\nexport {};\n"
116
+ "dts": "export interface GetUserKeySuccessResponse {\n\thash: string;\n\ttype: \"HASH\";\n}\nexport interface GetUserKeyErrorResponse {\n\ttype: \"NOT_AVAILABLE\";\n}\nexport type GetUserKeyResponse = GetUserKeySuccessResponse | GetUserKeyErrorResponse;\n/**\n * @deprecated타입은 이상 사용되지 않습니다. 대신 {@link GetUserKeySuccessResponse} 사용해주세요.\n */\nexport type GetUserKeyForGameSuccessResponse = GetUserKeySuccessResponse;\n/**\n * @deprecated 타입은 이상 사용되지 않습니다. 대신 {@link GetUserKeyErrorResponse} 사용해주세요.\n */\nexport type GetUserKeyForGameErrorResponse = GetUserKeyErrorResponse;\n/**\n * @deprecated 타입은 이상 사용되지 않습니다. 대신 {@link GetUserKeyResponse} 사용해주세요.\n */\nexport type GetUserKeyForGameResponse = GetUserKeyResponse;\n/**\n *\n * @deprecated 함수는 이상 사용되지 않습니다. 대신 {@link getUserKey} 사용해주세요.\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
@@ -51,6 +51,7 @@ __export(index_exports, {
51
51
  getServerTime: () => getServerTime,
52
52
  getTossAppVersion: () => getTossAppVersion,
53
53
  getTossShareLink: () => getTossShareLink,
54
+ getUserKey: () => getUserKey,
54
55
  getUserKeyForGame: () => getUserKeyForGame,
55
56
  grantPromotionReward: () => grantPromotionReward,
56
57
  grantPromotionRewardForGame: () => grantPromotionRewardForGame,
@@ -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 GAME_USER_KEY_MIN_VERSION = {
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/getUserKeyForGame.ts
942
- async function getUserKeyForGame() {
943
- const isSupported = isMinVersionSupported(GAME_USER_KEY_MIN_VERSION);
942
+ // src/MiniAppModule/native-modules/getUserKey.ts
943
+ async function getUserKey() {
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 getUserKey();
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";
@@ -1220,6 +1223,7 @@ var INTERNAL__module = {
1220
1223
  getServerTime,
1221
1224
  getTossAppVersion,
1222
1225
  getTossShareLink,
1226
+ getUserKey,
1223
1227
  getUserKeyForGame,
1224
1228
  grantPromotionReward,
1225
1229
  grantPromotionRewardForGame,
package/dist/index.d.cts CHANGED
@@ -168,25 +168,22 @@ type GameCenterGameProfileResponse = {
168
168
  */
169
169
  declare function getGameCenterGameProfile(): Promise<GameCenterGameProfileResponse | undefined>;
170
170
 
171
- interface GetUserKeyForGameSuccessResponse {
171
+ interface GetUserKeySuccessResponse {
172
172
  hash: string;
173
173
  type: 'HASH';
174
174
  }
175
- interface GetUserKeyForGameErrorResponse {
175
+ interface GetUserKeyErrorResponse {
176
176
  type: 'NOT_AVAILABLE';
177
177
  }
178
- type GetUserKeyForGameResponse = GetUserKeyForGameSuccessResponse | GetUserKeyForGameErrorResponse;
178
+ type GetUserKeyResponse = GetUserKeySuccessResponse | GetUserKeyErrorResponse;
179
179
  /**
180
180
  * @public
181
- * @category 게임
182
- * @name getUserKeyForGame
181
+ * @name getUserKey
183
182
  * @description
184
- * 게임 카테고리 미니앱에서 사용자의 고유 키를 가져와요. 이 키를 사용해서 사용자를 식별하고 게임 데이터를 관리할 수 있어요.
185
- * 게임 카테고리가 아닌 미니앱에서 호출하면 `'INVALID_CATEGORY'`를 반환해요.
186
- * @returns {Promise<GetUserKeyForGameSuccessResponse | 'INVALID_CATEGORY' | 'ERROR' | undefined>}
183
+ * 미니앱에서 사용자의 고유 키를 가져와요. 이 키를 사용해서 사용자를 식별하고 게임 데이터를 관리할 수 있어요.
184
+ * @returns {Promise<GetUserKeySuccessResponse | 'ERROR' | undefined>}
187
185
  * 사용자 키 조회 결과를 반환해요.
188
- * - `GetUserKeyForGameSuccessResponse`: 사용자 키 조회에 성공했어요. `{ type: 'HASH', hash: string }` 형태로 반환돼요.
189
- * - `'INVALID_CATEGORY'`: 게임 카테고리가 아닌 미니앱에서 호출했어요.
186
+ * - `GetUserKeySuccessResponse`: 사용자 키 조회에 성공했어요. `{ type: 'HASH', hash: string }` 형태로 반환돼요.
190
187
  * - `'ERROR'`: 알 수 없는 오류가 발생했어요.
191
188
  * - `undefined`: 앱 버전이 최소 지원 버전보다 낮아요.
192
189
  *
@@ -194,31 +191,26 @@ type GetUserKeyForGameResponse = GetUserKeyForGameSuccessResponse | GetUserKeyFo
194
191
  * ```tsx
195
192
  * // react-native
196
193
  * import { Button } from 'react-native';
197
- * import { getUserKeyForGame } from '@apps-in-toss/framework';
194
+ * import { getUserKey } from '@apps-in-toss/framework';
198
195
  *
199
- * function GameUserKeyButton() {
196
+ * function UserKeyButton() {
200
197
  * async function handlePress() {
201
- * const result = await getUserKeyForGame();
198
+ * const result = await getUserKey();
202
199
  *
203
- * if (!result) {
204
- * console.warn('지원하지 않는 앱 버전이에요.');
205
- * return;
206
- * }
207
- *
208
- * if (result === 'INVALID_CATEGORY') {
209
- * console.error('게임 카테고리가 아닌 미니앱이에요.');
210
- * return;
211
- * }
200
+ * if (!result) {
201
+ * console.warn('지원하지 않는 앱 버전이에요.');
202
+ * return;
203
+ * }
212
204
  *
213
- * if (result === 'ERROR') {
214
- * console.error('사용자 키 조회 중 오류가 발생했어요.');
215
- * return;
216
- * }
205
+ * if (result === 'ERROR') {
206
+ * console.error('사용자 키 조회 중 오류가 발생했어요.');
207
+ * return;
208
+ * }
217
209
  *
218
- * if (result.type === 'HASH') {
219
- * console.log('사용자 키:', result.hash);
220
- * // 여기에서 사용자 키를 사용해 게임 데이터를 관리할 수 있어요.
221
- * }
210
+ * if (result.type === 'HASH') {
211
+ * console.log('사용자 키:', result.hash);
212
+ * // 여기에서 사용자 키를 사용해 데이터를 관리할 수 있어요.
213
+ * }
222
214
  * }
223
215
  *
224
216
  * return (
@@ -230,31 +222,26 @@ type GetUserKeyForGameResponse = GetUserKeyForGameSuccessResponse | GetUserKeyFo
230
222
  * @example
231
223
  * ```tsx
232
224
  * // webview
233
- * import { getUserKeyForGame } from '@apps-in-toss/web-framework';
225
+ * import { getUserKey } from '@apps-in-toss/web-framework';
234
226
  *
235
- * function GameUserKeyButton() {
227
+ * function UserKeyButton() {
236
228
  * async function handleClick() {
237
- * const result = await getUserKeyForGame();
238
- *
239
- * if (!result) {
240
- * console.warn('지원하지 않는 앱 버전이에요.');
241
- * return;
242
- * }
229
+ * const result = await getUserKey();
243
230
  *
244
- * if (result === 'INVALID_CATEGORY') {
245
- * console.error('게임 카테고리가 아닌 미니앱이에요.');
246
- * return;
247
- * }
231
+ * if (!result) {
232
+ * console.warn('지원하지 않는 버전이에요.');
233
+ * return;
234
+ * }
248
235
  *
249
- * if (result === 'ERROR') {
250
- * console.error('사용자 키 조회 중 오류가 발생했어요.');
251
- * return;
252
- * }
236
+ * if (result === 'ERROR') {
237
+ * console.error('사용자 키 조회 중 오류가 발생했어요.');
238
+ * return;
239
+ * }
253
240
  *
254
- * if (result.type === 'HASH') {
255
- * console.log('사용자 키:', result.hash);
256
- * // 여기에서 사용자 키를 사용해 게임 데이터를 관리할 수 있어요.
257
- * }
241
+ * if (result.type === 'HASH') {
242
+ * console.log('사용자 키:', result.hash);
243
+ * // 여기에서 사용자 키를 사용해 데이터를 관리할 수 있어요.
244
+ * }
258
245
  * }
259
246
  *
260
247
  * return (
@@ -263,6 +250,24 @@ type GetUserKeyForGameResponse = GetUserKeyForGameSuccessResponse | GetUserKeyFo
263
250
  * }
264
251
  * ```
265
252
  */
253
+ declare function getUserKey(): Promise<GetUserKeySuccessResponse | 'ERROR' | undefined>;
254
+
255
+ /**
256
+ * @deprecated 이 타입은 더 이상 사용되지 않습니다. 대신 {@link GetUserKeySuccessResponse}를 사용해주세요.
257
+ */
258
+ type GetUserKeyForGameSuccessResponse = GetUserKeySuccessResponse;
259
+ /**
260
+ * @deprecated 이 타입은 더 이상 사용되지 않습니다. 대신 {@link GetUserKeyErrorResponse}를 사용해주세요.
261
+ */
262
+ type GetUserKeyForGameErrorResponse = GetUserKeyErrorResponse;
263
+ /**
264
+ * @deprecated 이 타입은 더 이상 사용되지 않습니다. 대신 {@link GetUserKeyResponse}를 사용해주세요.
265
+ */
266
+ type GetUserKeyForGameResponse = GetUserKeyResponse;
267
+ /**
268
+ *
269
+ * @deprecated 이 함수는 더 이상 사용되지 않습니다. 대신 {@link getUserKey}를 사용해주세요.
270
+ */
266
271
  declare function getUserKeyForGame(): Promise<GetUserKeyForGameSuccessResponse | 'INVALID_CATEGORY' | 'ERROR' | undefined>;
267
272
 
268
273
  interface GrantPromotionRewardForGameSuccessResponse {
@@ -1104,6 +1109,7 @@ interface AsyncMethodsMap {
1104
1109
  appsInTossSignTossCert: (params: AppsInTossSignTossCertParams) => Promise<void>;
1105
1110
  getGameCenterGameProfile: (params: CompatiblePlaceholderArgument) => Promise<GameCenterGameProfileResponse | undefined>;
1106
1111
  getUserKeyForGame: (params: CompatiblePlaceholderArgument) => Promise<GetUserKeyForGameResponse | undefined>;
1112
+ getUserKey: (params: CompatiblePlaceholderArgument) => Promise<GetUserKeyResponse | undefined>;
1107
1113
  grantPromotionRewardForGame: (params: {
1108
1114
  promotionCode: string;
1109
1115
  amount: number;
@@ -1763,7 +1769,7 @@ type Primitive = string | number | boolean | null | undefined | symbol;
1763
1769
 
1764
1770
  interface EventLogParams {
1765
1771
  log_name: string;
1766
- log_type: 'debug' | 'info' | 'warn' | 'error' | 'event' | 'screen' | 'impression' | 'click';
1772
+ log_type: 'debug' | 'info' | 'warn' | 'error' | 'event' | 'screen' | 'impression' | 'click' | 'popup';
1767
1773
  params: Record<string, Primitive>;
1768
1774
  }
1769
1775
  /**
@@ -3310,4 +3316,4 @@ declare const INTERNAL__module: {
3310
3316
  tossCoreEventLog: typeof tossCoreEventLog;
3311
3317
  };
3312
3318
 
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 };
3319
+ export { type AppsInTossSignTossCertParams, type CheckoutPaymentOptions, type CheckoutPaymentResult, type CompletedOrRefundedOrdersResult, type ConsumableProductListItem, type ContactsViralParams, type CreateSubscriptionPurchaseOrderOptions, type EventLogParams, type GameCenterGameProfileResponse, type GetUserKeyErrorResponse, type GetUserKeyForGameErrorResponse, type GetUserKeyForGameResponse, type GetUserKeyForGameSuccessResponse, type GetUserKeyResponse, type GetUserKeySuccessResponse, 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, getUserKey, 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,22 @@ type GameCenterGameProfileResponse = {
168
168
  */
169
169
  declare function getGameCenterGameProfile(): Promise<GameCenterGameProfileResponse | undefined>;
170
170
 
171
- interface GetUserKeyForGameSuccessResponse {
171
+ interface GetUserKeySuccessResponse {
172
172
  hash: string;
173
173
  type: 'HASH';
174
174
  }
175
- interface GetUserKeyForGameErrorResponse {
175
+ interface GetUserKeyErrorResponse {
176
176
  type: 'NOT_AVAILABLE';
177
177
  }
178
- type GetUserKeyForGameResponse = GetUserKeyForGameSuccessResponse | GetUserKeyForGameErrorResponse;
178
+ type GetUserKeyResponse = GetUserKeySuccessResponse | GetUserKeyErrorResponse;
179
179
  /**
180
180
  * @public
181
- * @category 게임
182
- * @name getUserKeyForGame
181
+ * @name getUserKey
183
182
  * @description
184
- * 게임 카테고리 미니앱에서 사용자의 고유 키를 가져와요. 이 키를 사용해서 사용자를 식별하고 게임 데이터를 관리할 수 있어요.
185
- * 게임 카테고리가 아닌 미니앱에서 호출하면 `'INVALID_CATEGORY'`를 반환해요.
186
- * @returns {Promise<GetUserKeyForGameSuccessResponse | 'INVALID_CATEGORY' | 'ERROR' | undefined>}
183
+ * 미니앱에서 사용자의 고유 키를 가져와요. 이 키를 사용해서 사용자를 식별하고 게임 데이터를 관리할 수 있어요.
184
+ * @returns {Promise<GetUserKeySuccessResponse | 'ERROR' | undefined>}
187
185
  * 사용자 키 조회 결과를 반환해요.
188
- * - `GetUserKeyForGameSuccessResponse`: 사용자 키 조회에 성공했어요. `{ type: 'HASH', hash: string }` 형태로 반환돼요.
189
- * - `'INVALID_CATEGORY'`: 게임 카테고리가 아닌 미니앱에서 호출했어요.
186
+ * - `GetUserKeySuccessResponse`: 사용자 키 조회에 성공했어요. `{ type: 'HASH', hash: string }` 형태로 반환돼요.
190
187
  * - `'ERROR'`: 알 수 없는 오류가 발생했어요.
191
188
  * - `undefined`: 앱 버전이 최소 지원 버전보다 낮아요.
192
189
  *
@@ -194,31 +191,26 @@ type GetUserKeyForGameResponse = GetUserKeyForGameSuccessResponse | GetUserKeyFo
194
191
  * ```tsx
195
192
  * // react-native
196
193
  * import { Button } from 'react-native';
197
- * import { getUserKeyForGame } from '@apps-in-toss/framework';
194
+ * import { getUserKey } from '@apps-in-toss/framework';
198
195
  *
199
- * function GameUserKeyButton() {
196
+ * function UserKeyButton() {
200
197
  * async function handlePress() {
201
- * const result = await getUserKeyForGame();
198
+ * const result = await getUserKey();
202
199
  *
203
- * if (!result) {
204
- * console.warn('지원하지 않는 앱 버전이에요.');
205
- * return;
206
- * }
207
- *
208
- * if (result === 'INVALID_CATEGORY') {
209
- * console.error('게임 카테고리가 아닌 미니앱이에요.');
210
- * return;
211
- * }
200
+ * if (!result) {
201
+ * console.warn('지원하지 않는 앱 버전이에요.');
202
+ * return;
203
+ * }
212
204
  *
213
- * if (result === 'ERROR') {
214
- * console.error('사용자 키 조회 중 오류가 발생했어요.');
215
- * return;
216
- * }
205
+ * if (result === 'ERROR') {
206
+ * console.error('사용자 키 조회 중 오류가 발생했어요.');
207
+ * return;
208
+ * }
217
209
  *
218
- * if (result.type === 'HASH') {
219
- * console.log('사용자 키:', result.hash);
220
- * // 여기에서 사용자 키를 사용해 게임 데이터를 관리할 수 있어요.
221
- * }
210
+ * if (result.type === 'HASH') {
211
+ * console.log('사용자 키:', result.hash);
212
+ * // 여기에서 사용자 키를 사용해 데이터를 관리할 수 있어요.
213
+ * }
222
214
  * }
223
215
  *
224
216
  * return (
@@ -230,31 +222,26 @@ type GetUserKeyForGameResponse = GetUserKeyForGameSuccessResponse | GetUserKeyFo
230
222
  * @example
231
223
  * ```tsx
232
224
  * // webview
233
- * import { getUserKeyForGame } from '@apps-in-toss/web-framework';
225
+ * import { getUserKey } from '@apps-in-toss/web-framework';
234
226
  *
235
- * function GameUserKeyButton() {
227
+ * function UserKeyButton() {
236
228
  * async function handleClick() {
237
- * const result = await getUserKeyForGame();
238
- *
239
- * if (!result) {
240
- * console.warn('지원하지 않는 앱 버전이에요.');
241
- * return;
242
- * }
229
+ * const result = await getUserKey();
243
230
  *
244
- * if (result === 'INVALID_CATEGORY') {
245
- * console.error('게임 카테고리가 아닌 미니앱이에요.');
246
- * return;
247
- * }
231
+ * if (!result) {
232
+ * console.warn('지원하지 않는 버전이에요.');
233
+ * return;
234
+ * }
248
235
  *
249
- * if (result === 'ERROR') {
250
- * console.error('사용자 키 조회 중 오류가 발생했어요.');
251
- * return;
252
- * }
236
+ * if (result === 'ERROR') {
237
+ * console.error('사용자 키 조회 중 오류가 발생했어요.');
238
+ * return;
239
+ * }
253
240
  *
254
- * if (result.type === 'HASH') {
255
- * console.log('사용자 키:', result.hash);
256
- * // 여기에서 사용자 키를 사용해 게임 데이터를 관리할 수 있어요.
257
- * }
241
+ * if (result.type === 'HASH') {
242
+ * console.log('사용자 키:', result.hash);
243
+ * // 여기에서 사용자 키를 사용해 데이터를 관리할 수 있어요.
244
+ * }
258
245
  * }
259
246
  *
260
247
  * return (
@@ -263,6 +250,24 @@ type GetUserKeyForGameResponse = GetUserKeyForGameSuccessResponse | GetUserKeyFo
263
250
  * }
264
251
  * ```
265
252
  */
253
+ declare function getUserKey(): Promise<GetUserKeySuccessResponse | 'ERROR' | undefined>;
254
+
255
+ /**
256
+ * @deprecated 이 타입은 더 이상 사용되지 않습니다. 대신 {@link GetUserKeySuccessResponse}를 사용해주세요.
257
+ */
258
+ type GetUserKeyForGameSuccessResponse = GetUserKeySuccessResponse;
259
+ /**
260
+ * @deprecated 이 타입은 더 이상 사용되지 않습니다. 대신 {@link GetUserKeyErrorResponse}를 사용해주세요.
261
+ */
262
+ type GetUserKeyForGameErrorResponse = GetUserKeyErrorResponse;
263
+ /**
264
+ * @deprecated 이 타입은 더 이상 사용되지 않습니다. 대신 {@link GetUserKeyResponse}를 사용해주세요.
265
+ */
266
+ type GetUserKeyForGameResponse = GetUserKeyResponse;
267
+ /**
268
+ *
269
+ * @deprecated 이 함수는 더 이상 사용되지 않습니다. 대신 {@link getUserKey}를 사용해주세요.
270
+ */
266
271
  declare function getUserKeyForGame(): Promise<GetUserKeyForGameSuccessResponse | 'INVALID_CATEGORY' | 'ERROR' | undefined>;
267
272
 
268
273
  interface GrantPromotionRewardForGameSuccessResponse {
@@ -1104,6 +1109,7 @@ interface AsyncMethodsMap {
1104
1109
  appsInTossSignTossCert: (params: AppsInTossSignTossCertParams) => Promise<void>;
1105
1110
  getGameCenterGameProfile: (params: CompatiblePlaceholderArgument) => Promise<GameCenterGameProfileResponse | undefined>;
1106
1111
  getUserKeyForGame: (params: CompatiblePlaceholderArgument) => Promise<GetUserKeyForGameResponse | undefined>;
1112
+ getUserKey: (params: CompatiblePlaceholderArgument) => Promise<GetUserKeyResponse | undefined>;
1107
1113
  grantPromotionRewardForGame: (params: {
1108
1114
  promotionCode: string;
1109
1115
  amount: number;
@@ -1763,7 +1769,7 @@ type Primitive = string | number | boolean | null | undefined | symbol;
1763
1769
 
1764
1770
  interface EventLogParams {
1765
1771
  log_name: string;
1766
- log_type: 'debug' | 'info' | 'warn' | 'error' | 'event' | 'screen' | 'impression' | 'click';
1772
+ log_type: 'debug' | 'info' | 'warn' | 'error' | 'event' | 'screen' | 'impression' | 'click' | 'popup';
1767
1773
  params: Record<string, Primitive>;
1768
1774
  }
1769
1775
  /**
@@ -3310,4 +3316,4 @@ declare const INTERNAL__module: {
3310
3316
  tossCoreEventLog: typeof tossCoreEventLog;
3311
3317
  };
3312
3318
 
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 };
3319
+ export { type AppsInTossSignTossCertParams, type CheckoutPaymentOptions, type CheckoutPaymentResult, type CompletedOrRefundedOrdersResult, type ConsumableProductListItem, type ContactsViralParams, type CreateSubscriptionPurchaseOrderOptions, type EventLogParams, type GameCenterGameProfileResponse, type GetUserKeyErrorResponse, type GetUserKeyForGameErrorResponse, type GetUserKeyForGameResponse, type GetUserKeyForGameSuccessResponse, type GetUserKeyResponse, type GetUserKeySuccessResponse, 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, getUserKey, 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 GAME_USER_KEY_MIN_VERSION = {
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/getUserKeyForGame.ts
862
- async function getUserKeyForGame() {
863
- const isSupported = isMinVersionSupported(GAME_USER_KEY_MIN_VERSION);
861
+ // src/MiniAppModule/native-modules/getUserKey.ts
862
+ async function getUserKey() {
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 getUserKey();
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";
@@ -1139,6 +1141,7 @@ export {
1139
1141
  getServerTime,
1140
1142
  getTossAppVersion,
1141
1143
  getTossShareLink,
1144
+ getUserKey,
1142
1145
  getUserKeyForGame,
1143
1146
  grantPromotionReward,
1144
1147
  grantPromotionRewardForGame,
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.2",
4
+ "version": "2.4.4",
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.2",
45
+ "@apps-in-toss/types": "2.4.4",
46
46
  "brick-module": "0.5.0",
47
47
  "es-toolkit": "^1.39.3"
48
48
  },
@@ -5,7 +5,7 @@ export const GAME_CENTER_MIN_VERSION = {
5
5
  ios: '5.221.0',
6
6
  } as const;
7
7
 
8
- export const GAME_USER_KEY_MIN_VERSION = {
8
+ export const USER_KEY_MIN_VERSION = {
9
9
  android: '5.232.0',
10
10
  ios: '5.232.0',
11
11
  } as const;
@@ -12,7 +12,7 @@ function normalizeParams(params: Record<string, Primitive>): Record<string, stri
12
12
 
13
13
  export interface EventLogParams {
14
14
  log_name: string;
15
- log_type: 'debug' | 'info' | 'warn' | 'error' | 'event' | 'screen' | 'impression' | 'click';
15
+ log_type: 'debug' | 'info' | 'warn' | 'error' | 'event' | 'screen' | 'impression' | 'click' | 'popup';
16
16
  params: Record<string, Primitive>;
17
17
  }
18
18
 
@@ -0,0 +1,107 @@
1
+ import { isMinVersionSupported } from './isMinVersionSupported';
2
+ import { safePostMessage } from '../../natives';
3
+ import { USER_KEY_MIN_VERSION } from '../constants';
4
+
5
+ export interface GetUserKeySuccessResponse {
6
+ hash: string;
7
+ type: 'HASH';
8
+ }
9
+
10
+ export interface GetUserKeyErrorResponse {
11
+ type: 'NOT_AVAILABLE';
12
+ }
13
+
14
+ export type GetUserKeyResponse = GetUserKeySuccessResponse | GetUserKeyErrorResponse;
15
+
16
+ /**
17
+ * @public
18
+ * @name getUserKey
19
+ * @description
20
+ * 미니앱에서 사용자의 고유 키를 가져와요. 이 키를 사용해서 사용자를 식별하고 게임 데이터를 관리할 수 있어요.
21
+ * @returns {Promise<GetUserKeySuccessResponse | 'ERROR' | undefined>}
22
+ * 사용자 키 조회 결과를 반환해요.
23
+ * - `GetUserKeySuccessResponse`: 사용자 키 조회에 성공했어요. `{ type: 'HASH', hash: string }` 형태로 반환돼요.
24
+ * - `'ERROR'`: 알 수 없는 오류가 발생했어요.
25
+ * - `undefined`: 앱 버전이 최소 지원 버전보다 낮아요.
26
+ *
27
+ * @example
28
+ * ```tsx
29
+ * // react-native
30
+ * import { Button } from 'react-native';
31
+ * import { getUserKey } from '@apps-in-toss/framework';
32
+ *
33
+ * function UserKeyButton() {
34
+ * async function handlePress() {
35
+ * const result = await getUserKey();
36
+ *
37
+ * if (!result) {
38
+ * console.warn('지원하지 않는 앱 버전이에요.');
39
+ * return;
40
+ * }
41
+ *
42
+ * if (result === 'ERROR') {
43
+ * console.error('사용자 키 조회 중 오류가 발생했어요.');
44
+ * return;
45
+ * }
46
+ *
47
+ * if (result.type === 'HASH') {
48
+ * console.log('사용자 키:', result.hash);
49
+ * // 여기에서 사용자 키를 사용해 데이터를 관리할 수 있어요.
50
+ * }
51
+ * }
52
+ *
53
+ * return (
54
+ * <Button onPress={handlePress} title="유저 키 가져오기" />
55
+ * );
56
+ * }
57
+ * ```
58
+ *
59
+ * @example
60
+ * ```tsx
61
+ * // webview
62
+ * import { getUserKey } from '@apps-in-toss/web-framework';
63
+ *
64
+ * function UserKeyButton() {
65
+ * async function handleClick() {
66
+ * const result = await getUserKey();
67
+ *
68
+ * if (!result) {
69
+ * console.warn('지원하지 않는 앱 버전이에요.');
70
+ * return;
71
+ * }
72
+ *
73
+ * if (result === 'ERROR') {
74
+ * console.error('사용자 키 조회 중 오류가 발생했어요.');
75
+ * return;
76
+ * }
77
+ *
78
+ * if (result.type === 'HASH') {
79
+ * console.log('사용자 키:', result.hash);
80
+ * // 여기에서 사용자 키를 사용해 데이터를 관리할 수 있어요.
81
+ * }
82
+ * }
83
+ *
84
+ * return (
85
+ * <button onClick={handleClick}>유저 키 가져오기</button>
86
+ * );
87
+ * }
88
+ * ```
89
+ */
90
+ export async function getUserKey(): Promise<GetUserKeySuccessResponse | 'ERROR' | undefined> {
91
+ const isSupported = isMinVersionSupported(USER_KEY_MIN_VERSION);
92
+
93
+ if (!isSupported) {
94
+ return;
95
+ }
96
+
97
+ try {
98
+ const response = (await safePostMessage('getUserKeyForGame', {})) as GetUserKeyResponse;
99
+ if (response.type === 'HASH') {
100
+ return response;
101
+ }
102
+
103
+ return 'ERROR';
104
+ } catch {
105
+ return 'ERROR';
106
+ }
107
+ }
@@ -1,125 +1,26 @@
1
- import { isMinVersionSupported } from './isMinVersionSupported';
2
- import { safePostMessage } from '../../natives';
3
- import { GAME_USER_KEY_MIN_VERSION } from '../constants';
1
+ import { getUserKey, GetUserKeyErrorResponse, GetUserKeyResponse, GetUserKeySuccessResponse } from './getUserKey';
4
2
 
5
- export interface GetUserKeyForGameSuccessResponse {
6
- hash: string;
7
- type: 'HASH';
8
- }
3
+ /**
4
+ * @deprecated 이 타입은 더 이상 사용되지 않습니다. 대신 {@link GetUserKeySuccessResponse}를 사용해주세요.
5
+ */
6
+ export type GetUserKeyForGameSuccessResponse = GetUserKeySuccessResponse;
9
7
 
10
- export interface GetUserKeyForGameErrorResponse {
11
- type: 'NOT_AVAILABLE';
12
- }
8
+ /**
9
+ * @deprecated 이 타입은 더 이상 사용되지 않습니다. 대신 {@link GetUserKeyErrorResponse}를 사용해주세요.
10
+ */
11
+ export type GetUserKeyForGameErrorResponse = GetUserKeyErrorResponse;
13
12
 
14
- export type GetUserKeyForGameResponse = GetUserKeyForGameSuccessResponse | GetUserKeyForGameErrorResponse;
13
+ /**
14
+ * @deprecated 이 타입은 더 이상 사용되지 않습니다. 대신 {@link GetUserKeyResponse}를 사용해주세요.
15
+ */
16
+ export type GetUserKeyForGameResponse = GetUserKeyResponse;
15
17
 
16
18
  /**
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
19
  *
50
- * if (result === 'ERROR') {
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
- * ```
20
+ * @deprecated 함수는 더 이상 사용되지 않습니다. 대신 {@link getUserKey}를 사용해주세요.
102
21
  */
103
22
  export async function getUserKeyForGame(): Promise<
104
23
  GetUserKeyForGameSuccessResponse | 'INVALID_CATEGORY' | 'ERROR' | undefined
105
24
  > {
106
- const isSupported = isMinVersionSupported(GAME_USER_KEY_MIN_VERSION);
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
- }
25
+ return getUserKey();
125
26
  }
@@ -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 './getUserKey';
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 { GetUserKeyResponse } from './native-modules/getUserKey';
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<GetUserKeyResponse | undefined>;
75
77
  grantPromotionRewardForGame: (params: {
76
78
  promotionCode: string;
77
79
  amount: number;
@@ -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/getUserKey';
31
32
  export * from './MiniAppModule/native-modules/getUserKeyForGame';
32
33
  export * from './MiniAppModule/native-modules/grantPromotionReward';
33
34
  export * from './MiniAppModule/native-modules/grantPromotionRewardForGame';