@apps-in-toss/native-modules 1.8.0 → 1.9.0

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 CHANGED
@@ -1,5 +1,9 @@
1
1
  # @apps-in-toss/native-modules
2
2
 
3
+ ## 1.9.0
4
+
5
+ ## 1.8.1
6
+
3
7
  ## 1.8.0
4
8
 
5
9
  ### Minor Changes
@@ -119,6 +119,10 @@
119
119
  "identifier": "grantPromotionRewardForGame",
120
120
  "dts": "export interface GrantPromotionRewardForGameSuccessResponse {\n\tkey: string;\n}\nexport interface GrantPromotionRewardForGameErrorResponse {\n\tcode: string;\n\t[key: string]: any;\n}\nexport interface GrantPromotionRewardForGameErrorResult {\n\terrorCode: string;\n\tmessage: string;\n}\nexport type GrantPromotionRewardForGameResponse = GrantPromotionRewardForGameSuccessResponse | GrantPromotionRewardForGameErrorResponse;\nexport type GrantPromotionRewardForGameResult = GrantPromotionRewardForGameResponse | GrantPromotionRewardForGameErrorResult | \"ERROR\" | undefined;\n/**\n * @public\n * @category 게임\n * @name grantPromotionRewardForGame\n * @description\n * 이 함수를 사용하면 게임 카테고리 미니앱에서 프로모션 코드를 사용해서 유저에게 리워드를 지급할 수 있어요.\n * 게임 카테고리가 아닌 미니앱에서 호출할 수 없어요.\n * @param {{ params: { promotionCode: string; amount: number } }} params - 포인트를 지급하기 위해 필요한 정보예요.\n * @param {string} params.promotionCode - 프로모션 코드예요.\n * @param {number} params.amount - 지급할 포인트 금액이에요.\n * @returns {Promise<{ key: string } | { errorCode: string; message: string } | 'ERROR' | undefined>}\n * 포인트 지급 결과를 반환해요.\n * - `{ key: string }`: 포인트 지급에 성공했어요. key는 리워드 키를 의미해요.\n * - `{ errorCode: string, message: string }`: 포인트 지급에 실패했어요. 에러 코드는 다음과 같아요.\n * - `\"40000\"`: 게임이 아닌 미니앱에서 호출했을 때\n * - `\"4100\"`: 프로모션 정보를 찾을 수 없을 때\n * - `\"4104\"`: 프로모션이 중지되었을 때\n * - `\"4105\"`: 프로모션이 종료되었을 때\n * - `\"4108\"`: 프로모션이 승인되지 않았을 때\n * - `\"4109\"`: 프로모션이 실행중이 아닐 때\n * - `\"4110\"`: 리워드를 지급/회수할 수 없을 때\n * - `\"4112\"`: 프로모션 머니가 부족할 때\n * - `\"4113\"`: 이미 지급/회수된 내역일 때\n * - `\"4114\"`: 프로모션에 설정된 1회 지급 금액을 초과할 때\n * - `'ERROR'`: 알 수 없는 오류가 발생했어요.\n * - `undefined`: 앱 버전이 최소 지원 버전보다 낮아요.\n * @example\n * ```tsx\n * // react-native\n * import { Button } from 'react-native';\n * import { grantPromotionRewardForGame } from '@apps-in-toss/framework';\n *\n * function GrantRewardButton() {\n * async function handlePress() {\n * const result = await grantPromotionRewardForGame({\n * params: {\n * promotionCode: 'GAME_EVENT_2024',\n * amount: 1000,\n * },\n * });\n *\n * if (!result) {\n * console.warn('지원하지 않는 앱 버전이에요.');\n * return;\n * }\n *\n * if (result === 'ERROR') {\n * console.error('포인트 지급 중 알 수 없는 오류가 발생했어요.');\n * return;\n * }\n *\n * if ('key' in result) {\n * console.log('포인트 지급 성공!', result.key);\n * } else if ('errorCode' in result) {\n * console.error('포인트 지급 실패:', result.errorCode, result.message);\n * }\n * }\n *\n * return <Button onPress={handlePress} title=\"포인트 지급하기\" />;\n * }\n * ```\n *\n * @example\n * ```tsx\n * // webview\n * import { grantPromotionRewardForGame } from '@apps-in-toss/web-framework';\n *\n * function GrantRewardButton() {\n * async function handleClick() {\n * const result = await grantPromotionRewardForGame({\n * params: {\n * promotionCode: 'GAME_EVENT_2024',\n * amount: 1000,\n * },\n * });\n *\n * if (!result) {\n * console.warn('지원하지 않는 앱 버전이에요.');\n * return;\n * }\n *\n * if (result === 'ERROR') {\n * console.error('포인트 지급 중 알 수 없는 오류가 발생했어요.');\n * return;\n * }\n *\n * if ('key' in result) {\n * console.log('포인트 지급 성공!', result.key);\n * } else if ('errorCode' in result) {\n * console.error('포인트 지급 실패:', result.errorCode, result.message);\n * }\n * }\n *\n * return (\n * <button onClick={handleClick}>포인트 지급하기</button>\n * );\n * }\n * ```\n */\nexport declare function grantPromotionRewardForGame({ params, }: {\n\tparams: {\n\t\tpromotionCode: string;\n\t\tamount: number;\n\t};\n}): Promise<GrantPromotionRewardForGameResult>;\n\nexport {};\n"
121
121
  },
122
+ {
123
+ "identifier": "getServerTime",
124
+ "dts": "/**\n * @public\n * @category 시간\n * @name getServerTime\n * @description\n * 토스 앱 서버의 현재 시간을 Unix timestamp 형식으로 가져와요.\n * 디바이스 시간이 아닌 서버 기준 시간을 반환하므로 클라이언트 시간 조작에 따른 보상 중복 수령 등의 치팅을 방지할 수 있어요.\n *\n * @returns {Promise<number | undefined>} 서버 시간을 Unix timestamp 밀리초 단위로 반환해요. (예: 1705123456789) 지원하지 않는 버전에서는 `undefined`를 반환해요.\n * @property {() => boolean} isSupported 현재 앱 버전이 이 기능을 지원하는지 확인하는 함수예요.\n *\n * @example\n * ```tsx\n * import { getServerTime } from '@apps-in-toss/framework';\n *\n * async function checkRewardEligibility() {\n * // 버전 체크를 먼저 수행하는 것을 권장해요\n * if (!getServerTime.isSupported()) {\n * console.log('이 기능은 지원되지 않는 버전입니다.');\n * return;\n * }\n *\n * const serverTime = await getServerTime();\n * const rewardDeadline = 1705200000000;\n *\n * if (serverTime && serverTime > rewardDeadline) {\n * console.log('보상 수령 기간이 지났습니다.');\n * }\n * }\n * ```\n */\nexport declare function getServerTime(): Promise<number | undefined>;\nexport declare namespace getServerTime {\n\tvar isSupported: () => boolean;\n}\n\nexport {};\n"
125
+ },
122
126
  {
123
127
  "identifier": "getLocale",
124
128
  "dts": "/**\n * @public\n * @category 언어\n * @kind function\n * @name getLocale\n * @description\n * 사용자의 로케일(locale) 정보를 반환해요. 네이티브 모듈에서 로케일 정보를 가져올 수 없을 때는 기본값으로 'ko-KR'을 반환합니다. 앱의 현지화 및 언어 설정과 관련된 기능을 구현할 때 사용하세요.\n *\n * @returns {string} 사용자의 로케일 정보를 반환해요.\n *\n * @example\n * ### 현재 사용자의 로케일 정보 가져오기\n *\n * ```tsx\n * import { getLocale } from '@apps-in-toss/native-modules';\n * import { Text } from 'react-native';\n *\n * function MyPage() {\n * const locale = getLocale();\n *\n * return (\n * <Text>사용자의 로케일 정보: {locale}</Text>\n * )\n * }\n *\n * ```\n */\nexport declare function getLocale(): string;\n\nexport {};\n"
package/dist/index.cjs CHANGED
@@ -50,6 +50,7 @@ __export(index_exports, {
50
50
  getOperationalEnvironment: () => getOperationalEnvironment,
51
51
  getPlatformOS: () => getPlatformOS,
52
52
  getSchemeUri: () => getSchemeUri2,
53
+ getServerTime: () => getServerTime,
53
54
  getTossAppVersion: () => getTossAppVersion,
54
55
  getTossShareLink: () => getTossShareLink,
55
56
  getUserKeyForGame: () => getUserKeyForGame,
@@ -853,6 +854,10 @@ var GET_IS_TOSS_LOGIN_INTEGRATED_SERVICE_MIN_VERSION = {
853
854
  android: "5.237.0",
854
855
  ios: "5.237.0"
855
856
  };
857
+ var GET_SERVER_TIME_MIN_VERSION = {
858
+ android: "5.245.0",
859
+ ios: "5.245.0"
860
+ };
856
861
 
857
862
  // src/AppsInTossModule/native-modules/openGameCenterLeaderboard.ts
858
863
  async function openGameCenterLeaderboard() {
@@ -989,6 +994,16 @@ async function appsInTossSignTossCert(params) {
989
994
  await AppsInTossModule.appsInTossSignTossCert({ params });
990
995
  }
991
996
 
997
+ // src/AppsInTossModule/native-modules/getServerTime.ts
998
+ async function getServerTime() {
999
+ const isSupported = isMinVersionSupported(GET_SERVER_TIME_MIN_VERSION);
1000
+ if (!isSupported) {
1001
+ return;
1002
+ }
1003
+ return (await AppsInTossModule.getServerTime({})).serverTime;
1004
+ }
1005
+ getServerTime.isSupported = () => isMinVersionSupported(GET_SERVER_TIME_MIN_VERSION);
1006
+
992
1007
  // src/AppsInTossModule/native-modules/index.ts
993
1008
  var TossPay = {
994
1009
  checkoutPayment
@@ -1144,6 +1159,7 @@ var INTERNAL__module = {
1144
1159
  getOperationalEnvironment,
1145
1160
  getPlatformOS,
1146
1161
  getSchemeUri,
1162
+ getServerTime,
1147
1163
  getTossAppVersion,
1148
1164
  getTossShareLink,
1149
1165
  getUserKeyForGame,
package/dist/index.d.cts CHANGED
@@ -1662,6 +1662,9 @@ interface Spec extends TurboModule {
1662
1662
  appsInTossSignTossCert: (params: {
1663
1663
  params: AppsInTossSignTossCertParams;
1664
1664
  }) => void;
1665
+ getServerTime: (arg: CompatiblePlaceholderArgument) => Promise<{
1666
+ serverTime: number;
1667
+ }>;
1665
1668
  }
1666
1669
  declare const AppsInTossModuleInstance: any;
1667
1670
  declare const AppsInTossModule: Spec;
@@ -2632,6 +2635,42 @@ declare function openGameCenterLeaderboard(): Promise<void>;
2632
2635
  */
2633
2636
  declare function getIsTossLoginIntegratedService(): Promise<boolean | undefined>;
2634
2637
 
2638
+ /**
2639
+ * @public
2640
+ * @category 시간
2641
+ * @name getServerTime
2642
+ * @description
2643
+ * 토스 앱 서버의 현재 시간을 Unix timestamp 형식으로 가져와요.
2644
+ * 디바이스 시간이 아닌 서버 기준 시간을 반환하므로 클라이언트 시간 조작에 따른 보상 중복 수령 등의 치팅을 방지할 수 있어요.
2645
+ *
2646
+ * @returns {Promise<number | undefined>} 서버 시간을 Unix timestamp 밀리초 단위로 반환해요. (예: 1705123456789) 지원하지 않는 버전에서는 `undefined`를 반환해요.
2647
+ * @property {() => boolean} isSupported 현재 앱 버전이 이 기능을 지원하는지 확인하는 함수예요.
2648
+ *
2649
+ * @example
2650
+ * ```tsx
2651
+ * import { getServerTime } from '@apps-in-toss/framework';
2652
+ *
2653
+ * async function checkRewardEligibility() {
2654
+ * // 버전 체크를 먼저 수행하는 것을 권장해요
2655
+ * if (!getServerTime.isSupported()) {
2656
+ * console.log('이 기능은 지원되지 않는 버전입니다.');
2657
+ * return;
2658
+ * }
2659
+ *
2660
+ * const serverTime = await getServerTime();
2661
+ * const rewardDeadline = 1705200000000;
2662
+ *
2663
+ * if (serverTime && serverTime > rewardDeadline) {
2664
+ * console.log('보상 수령 기간이 지났습니다.');
2665
+ * }
2666
+ * }
2667
+ * ```
2668
+ */
2669
+ declare function getServerTime(): Promise<number | undefined>;
2670
+ declare namespace getServerTime {
2671
+ var isSupported: () => boolean;
2672
+ }
2673
+
2635
2674
  /**
2636
2675
  * @public
2637
2676
  * @category 토스페이
@@ -3122,4 +3161,4 @@ declare const INTERNAL__module: {
3122
3161
  tossCoreEventLog: typeof tossCoreEventLog;
3123
3162
  };
3124
3163
 
3125
- export { AppsInTossModule, type AppsInTossSignTossCertParams, BedrockCoreModule, BedrockModule, type CheckoutPaymentOptions, type CheckoutPaymentResult, type CompletedOrRefundedOrdersResult, type ContactsViralParams, type EventLogParams, type GameCenterGameProfileResponse, type GetUserKeyForGameErrorResponse, type GetUserKeyForGameResponse, type GetUserKeyForGameSuccessResponse, GoogleAdMob, type GrantPromotionRewardForGameErrorResponse, type GrantPromotionRewardForGameErrorResult, type GrantPromotionRewardForGameResponse, type GrantPromotionRewardForGameSuccessResponse, type HapticFeedbackType, IAP, AppsInTossModuleInstance as INTERNAL__AppsInTossModule, INTERNAL__appBridgeHandler, INTERNAL__module, type IapCreateOneTimePurchaseOrderOptions, type IapCreateOneTimePurchaseOrderResult, type IapProductListItem, type IsAdMobLoadedOptions, type LoadAdMobEvent, type LoadAdMobOptions, type LoadAdMobParams, type NetworkStatus, type Primitive, type SaveBase64DataParams, type ShowAdMobEvent, type ShowAdMobOptions, type ShowAdMobParams, Storage, type SubmitGameCenterLeaderBoardScoreResponse, TossPay, type UpdateLocationEventEmitter, appLogin, appsInTossEvent, appsInTossSignTossCert, closeView, contactsViral, eventLog, fetchAlbumPhotos, fetchContacts, generateHapticFeedback, getClipboardText, getCurrentLocation, getDeviceId, getGameCenterGameProfile, getIsTossLoginIntegratedService, getLocale, getNetworkStatus, getOperationalEnvironment, getPlatformOS, getSchemeUri, getTossAppVersion, getTossShareLink, getUserKeyForGame, grantPromotionRewardForGame, iapCreateOneTimePurchaseOrder, isMinVersionSupported, onVisibilityChangedByTransparentServiceWeb, openCamera, openGameCenterLeaderboard, openURL, processProductGrant, requestOneTimePurchase, saveBase64Data, setClipboardText, setDeviceOrientation, setIosSwipeGestureEnabled, setScreenAwakeMode, setSecureScreen, share, startUpdateLocation, submitGameCenterLeaderBoardScore };
3164
+ export { AppsInTossModule, type AppsInTossSignTossCertParams, BedrockCoreModule, BedrockModule, type CheckoutPaymentOptions, type CheckoutPaymentResult, type CompletedOrRefundedOrdersResult, type ContactsViralParams, type EventLogParams, type GameCenterGameProfileResponse, type GetUserKeyForGameErrorResponse, type GetUserKeyForGameResponse, type GetUserKeyForGameSuccessResponse, GoogleAdMob, type GrantPromotionRewardForGameErrorResponse, type GrantPromotionRewardForGameErrorResult, type GrantPromotionRewardForGameResponse, type GrantPromotionRewardForGameSuccessResponse, type HapticFeedbackType, IAP, AppsInTossModuleInstance as INTERNAL__AppsInTossModule, INTERNAL__appBridgeHandler, INTERNAL__module, type IapCreateOneTimePurchaseOrderOptions, type IapCreateOneTimePurchaseOrderResult, type IapProductListItem, type IsAdMobLoadedOptions, type LoadAdMobEvent, type LoadAdMobOptions, type LoadAdMobParams, type NetworkStatus, type Primitive, type SaveBase64DataParams, type ShowAdMobEvent, type ShowAdMobOptions, type ShowAdMobParams, Storage, type SubmitGameCenterLeaderBoardScoreResponse, TossPay, type UpdateLocationEventEmitter, appLogin, appsInTossEvent, appsInTossSignTossCert, closeView, contactsViral, eventLog, fetchAlbumPhotos, fetchContacts, generateHapticFeedback, getClipboardText, getCurrentLocation, getDeviceId, getGameCenterGameProfile, getIsTossLoginIntegratedService, getLocale, getNetworkStatus, getOperationalEnvironment, getPlatformOS, getSchemeUri, getServerTime, getTossAppVersion, getTossShareLink, getUserKeyForGame, grantPromotionRewardForGame, iapCreateOneTimePurchaseOrder, isMinVersionSupported, onVisibilityChangedByTransparentServiceWeb, openCamera, openGameCenterLeaderboard, openURL, processProductGrant, requestOneTimePurchase, saveBase64Data, setClipboardText, setDeviceOrientation, setIosSwipeGestureEnabled, setScreenAwakeMode, setSecureScreen, share, startUpdateLocation, submitGameCenterLeaderBoardScore };
package/dist/index.d.ts CHANGED
@@ -1662,6 +1662,9 @@ interface Spec extends TurboModule {
1662
1662
  appsInTossSignTossCert: (params: {
1663
1663
  params: AppsInTossSignTossCertParams;
1664
1664
  }) => void;
1665
+ getServerTime: (arg: CompatiblePlaceholderArgument) => Promise<{
1666
+ serverTime: number;
1667
+ }>;
1665
1668
  }
1666
1669
  declare const AppsInTossModuleInstance: any;
1667
1670
  declare const AppsInTossModule: Spec;
@@ -2632,6 +2635,42 @@ declare function openGameCenterLeaderboard(): Promise<void>;
2632
2635
  */
2633
2636
  declare function getIsTossLoginIntegratedService(): Promise<boolean | undefined>;
2634
2637
 
2638
+ /**
2639
+ * @public
2640
+ * @category 시간
2641
+ * @name getServerTime
2642
+ * @description
2643
+ * 토스 앱 서버의 현재 시간을 Unix timestamp 형식으로 가져와요.
2644
+ * 디바이스 시간이 아닌 서버 기준 시간을 반환하므로 클라이언트 시간 조작에 따른 보상 중복 수령 등의 치팅을 방지할 수 있어요.
2645
+ *
2646
+ * @returns {Promise<number | undefined>} 서버 시간을 Unix timestamp 밀리초 단위로 반환해요. (예: 1705123456789) 지원하지 않는 버전에서는 `undefined`를 반환해요.
2647
+ * @property {() => boolean} isSupported 현재 앱 버전이 이 기능을 지원하는지 확인하는 함수예요.
2648
+ *
2649
+ * @example
2650
+ * ```tsx
2651
+ * import { getServerTime } from '@apps-in-toss/framework';
2652
+ *
2653
+ * async function checkRewardEligibility() {
2654
+ * // 버전 체크를 먼저 수행하는 것을 권장해요
2655
+ * if (!getServerTime.isSupported()) {
2656
+ * console.log('이 기능은 지원되지 않는 버전입니다.');
2657
+ * return;
2658
+ * }
2659
+ *
2660
+ * const serverTime = await getServerTime();
2661
+ * const rewardDeadline = 1705200000000;
2662
+ *
2663
+ * if (serverTime && serverTime > rewardDeadline) {
2664
+ * console.log('보상 수령 기간이 지났습니다.');
2665
+ * }
2666
+ * }
2667
+ * ```
2668
+ */
2669
+ declare function getServerTime(): Promise<number | undefined>;
2670
+ declare namespace getServerTime {
2671
+ var isSupported: () => boolean;
2672
+ }
2673
+
2635
2674
  /**
2636
2675
  * @public
2637
2676
  * @category 토스페이
@@ -3122,4 +3161,4 @@ declare const INTERNAL__module: {
3122
3161
  tossCoreEventLog: typeof tossCoreEventLog;
3123
3162
  };
3124
3163
 
3125
- export { AppsInTossModule, type AppsInTossSignTossCertParams, BedrockCoreModule, BedrockModule, type CheckoutPaymentOptions, type CheckoutPaymentResult, type CompletedOrRefundedOrdersResult, type ContactsViralParams, type EventLogParams, type GameCenterGameProfileResponse, type GetUserKeyForGameErrorResponse, type GetUserKeyForGameResponse, type GetUserKeyForGameSuccessResponse, GoogleAdMob, type GrantPromotionRewardForGameErrorResponse, type GrantPromotionRewardForGameErrorResult, type GrantPromotionRewardForGameResponse, type GrantPromotionRewardForGameSuccessResponse, type HapticFeedbackType, IAP, AppsInTossModuleInstance as INTERNAL__AppsInTossModule, INTERNAL__appBridgeHandler, INTERNAL__module, type IapCreateOneTimePurchaseOrderOptions, type IapCreateOneTimePurchaseOrderResult, type IapProductListItem, type IsAdMobLoadedOptions, type LoadAdMobEvent, type LoadAdMobOptions, type LoadAdMobParams, type NetworkStatus, type Primitive, type SaveBase64DataParams, type ShowAdMobEvent, type ShowAdMobOptions, type ShowAdMobParams, Storage, type SubmitGameCenterLeaderBoardScoreResponse, TossPay, type UpdateLocationEventEmitter, appLogin, appsInTossEvent, appsInTossSignTossCert, closeView, contactsViral, eventLog, fetchAlbumPhotos, fetchContacts, generateHapticFeedback, getClipboardText, getCurrentLocation, getDeviceId, getGameCenterGameProfile, getIsTossLoginIntegratedService, getLocale, getNetworkStatus, getOperationalEnvironment, getPlatformOS, getSchemeUri, getTossAppVersion, getTossShareLink, getUserKeyForGame, grantPromotionRewardForGame, iapCreateOneTimePurchaseOrder, isMinVersionSupported, onVisibilityChangedByTransparentServiceWeb, openCamera, openGameCenterLeaderboard, openURL, processProductGrant, requestOneTimePurchase, saveBase64Data, setClipboardText, setDeviceOrientation, setIosSwipeGestureEnabled, setScreenAwakeMode, setSecureScreen, share, startUpdateLocation, submitGameCenterLeaderBoardScore };
3164
+ export { AppsInTossModule, type AppsInTossSignTossCertParams, BedrockCoreModule, BedrockModule, type CheckoutPaymentOptions, type CheckoutPaymentResult, type CompletedOrRefundedOrdersResult, type ContactsViralParams, type EventLogParams, type GameCenterGameProfileResponse, type GetUserKeyForGameErrorResponse, type GetUserKeyForGameResponse, type GetUserKeyForGameSuccessResponse, GoogleAdMob, type GrantPromotionRewardForGameErrorResponse, type GrantPromotionRewardForGameErrorResult, type GrantPromotionRewardForGameResponse, type GrantPromotionRewardForGameSuccessResponse, type HapticFeedbackType, IAP, AppsInTossModuleInstance as INTERNAL__AppsInTossModule, INTERNAL__appBridgeHandler, INTERNAL__module, type IapCreateOneTimePurchaseOrderOptions, type IapCreateOneTimePurchaseOrderResult, type IapProductListItem, type IsAdMobLoadedOptions, type LoadAdMobEvent, type LoadAdMobOptions, type LoadAdMobParams, type NetworkStatus, type Primitive, type SaveBase64DataParams, type ShowAdMobEvent, type ShowAdMobOptions, type ShowAdMobParams, Storage, type SubmitGameCenterLeaderBoardScoreResponse, TossPay, type UpdateLocationEventEmitter, appLogin, appsInTossEvent, appsInTossSignTossCert, closeView, contactsViral, eventLog, fetchAlbumPhotos, fetchContacts, generateHapticFeedback, getClipboardText, getCurrentLocation, getDeviceId, getGameCenterGameProfile, getIsTossLoginIntegratedService, getLocale, getNetworkStatus, getOperationalEnvironment, getPlatformOS, getSchemeUri, getServerTime, getTossAppVersion, getTossShareLink, getUserKeyForGame, grantPromotionRewardForGame, iapCreateOneTimePurchaseOrder, isMinVersionSupported, onVisibilityChangedByTransparentServiceWeb, openCamera, openGameCenterLeaderboard, openURL, processProductGrant, requestOneTimePurchase, saveBase64Data, setClipboardText, setDeviceOrientation, setIosSwipeGestureEnabled, setScreenAwakeMode, setSecureScreen, share, startUpdateLocation, submitGameCenterLeaderBoardScore };
package/dist/index.js CHANGED
@@ -777,6 +777,10 @@ var GET_IS_TOSS_LOGIN_INTEGRATED_SERVICE_MIN_VERSION = {
777
777
  android: "5.237.0",
778
778
  ios: "5.237.0"
779
779
  };
780
+ var GET_SERVER_TIME_MIN_VERSION = {
781
+ android: "5.245.0",
782
+ ios: "5.245.0"
783
+ };
780
784
 
781
785
  // src/AppsInTossModule/native-modules/openGameCenterLeaderboard.ts
782
786
  async function openGameCenterLeaderboard() {
@@ -913,6 +917,16 @@ async function appsInTossSignTossCert(params) {
913
917
  await AppsInTossModule.appsInTossSignTossCert({ params });
914
918
  }
915
919
 
920
+ // src/AppsInTossModule/native-modules/getServerTime.ts
921
+ async function getServerTime() {
922
+ const isSupported = isMinVersionSupported(GET_SERVER_TIME_MIN_VERSION);
923
+ if (!isSupported) {
924
+ return;
925
+ }
926
+ return (await AppsInTossModule.getServerTime({})).serverTime;
927
+ }
928
+ getServerTime.isSupported = () => isMinVersionSupported(GET_SERVER_TIME_MIN_VERSION);
929
+
916
930
  // src/AppsInTossModule/native-modules/index.ts
917
931
  var TossPay = {
918
932
  checkoutPayment
@@ -1067,6 +1081,7 @@ export {
1067
1081
  getOperationalEnvironment,
1068
1082
  getPlatformOS,
1069
1083
  getSchemeUri2 as getSchemeUri,
1084
+ getServerTime,
1070
1085
  getTossAppVersion,
1071
1086
  getTossShareLink,
1072
1087
  getUserKeyForGame,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@apps-in-toss/native-modules",
3
3
  "type": "module",
4
- "version": "1.8.0",
4
+ "version": "1.9.0",
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": "^1.8.0",
45
+ "@apps-in-toss/types": "^1.9.0",
46
46
  "es-toolkit": "^1.39.3"
47
47
  },
48
48
  "peerDependencies": {
@@ -19,3 +19,8 @@ export const GET_IS_TOSS_LOGIN_INTEGRATED_SERVICE_MIN_VERSION = {
19
19
  android: '5.237.0',
20
20
  ios: '5.237.0',
21
21
  } as const;
22
+
23
+ export const GET_SERVER_TIME_MIN_VERSION = {
24
+ android: '5.245.0',
25
+ ios: '5.245.0',
26
+ } as const;
@@ -93,6 +93,8 @@ interface Spec extends __TurboModule {
93
93
 
94
94
  /** 토스인증 */
95
95
  appsInTossSignTossCert: (params: { params: AppsInTossSignTossCertParams }) => void;
96
+
97
+ getServerTime: (arg: CompatiblePlaceholderArgument) => Promise<{ serverTime: number }>;
96
98
  }
97
99
 
98
100
  const Module = TurboModuleRegistry.getEnforcing<Spec>('AppsInTossModule');
@@ -0,0 +1,46 @@
1
+ import { AppsInTossModule } from './AppsInTossModule';
2
+ import { isMinVersionSupported } from './isMinVersionSupported';
3
+ import { GET_SERVER_TIME_MIN_VERSION } from '../constants';
4
+
5
+ /**
6
+ * @public
7
+ * @category 시간
8
+ * @name getServerTime
9
+ * @description
10
+ * 토스 앱 서버의 현재 시간을 Unix timestamp 형식으로 가져와요.
11
+ * 디바이스 시간이 아닌 서버 기준 시간을 반환하므로 클라이언트 시간 조작에 따른 보상 중복 수령 등의 치팅을 방지할 수 있어요.
12
+ *
13
+ * @returns {Promise<number | undefined>} 서버 시간을 Unix timestamp 밀리초 단위로 반환해요. (예: 1705123456789) 지원하지 않는 버전에서는 `undefined`를 반환해요.
14
+ * @property {() => boolean} isSupported 현재 앱 버전이 이 기능을 지원하는지 확인하는 함수예요.
15
+ *
16
+ * @example
17
+ * ```tsx
18
+ * import { getServerTime } from '@apps-in-toss/framework';
19
+ *
20
+ * async function checkRewardEligibility() {
21
+ * // 버전 체크를 먼저 수행하는 것을 권장해요
22
+ * if (!getServerTime.isSupported()) {
23
+ * console.log('이 기능은 지원되지 않는 버전입니다.');
24
+ * return;
25
+ * }
26
+ *
27
+ * const serverTime = await getServerTime();
28
+ * const rewardDeadline = 1705200000000;
29
+ *
30
+ * if (serverTime && serverTime > rewardDeadline) {
31
+ * console.log('보상 수령 기간이 지났습니다.');
32
+ * }
33
+ * }
34
+ * ```
35
+ */
36
+ export async function getServerTime(): Promise<number | undefined> {
37
+ const isSupported = isMinVersionSupported(GET_SERVER_TIME_MIN_VERSION);
38
+
39
+ if (!isSupported) {
40
+ return;
41
+ }
42
+
43
+ return (await AppsInTossModule.getServerTime({})).serverTime;
44
+ }
45
+
46
+ getServerTime.isSupported = () => isMinVersionSupported(GET_SERVER_TIME_MIN_VERSION);
@@ -45,6 +45,7 @@ export * from './grantPromotionRewardForGame';
45
45
  export * from './getIsTossLoginIntegratedService';
46
46
  export * from '../native-event-emitter/contactsViral';
47
47
  export * from './appsInTossSignTossCert';
48
+ export * from './getServerTime';
48
49
 
49
50
  export type {
50
51
  CheckoutPaymentOptions,
@@ -31,3 +31,4 @@ export * from './AppsInTossModule/native-modules/submitGameCenterLeaderBoardScor
31
31
  export * from './AppsInTossModule/native-modules/getUserKeyForGame';
32
32
  export * from './AppsInTossModule/native-modules/getIsTossLoginIntegratedService';
33
33
  export * from './AppsInTossModule/native-modules/grantPromotionRewardForGame';
34
+ export * from './AppsInTossModule/native-modules/getServerTime';