@apps-in-toss/native-modules 2.6.2 → 2.7.1
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 +4 -0
- package/dist/index.cjs +11 -0
- package/dist/index.d.cts +69 -1
- package/dist/index.d.ts +69 -1
- package/dist/index.js +10 -0
- package/package.json +2 -2
- package/src/MiniAppModule/native-modules/getConsentedUserData.ts +96 -0
- 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
|
@@ -143,6 +143,10 @@
|
|
|
143
143
|
"identifier": "getServerTime",
|
|
144
144
|
"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"
|
|
145
145
|
},
|
|
146
|
+
{
|
|
147
|
+
"identifier": "getConsentedUserData",
|
|
148
|
+
"dts": "/**\n * @public\n * @category 사용자 데이터\n * @name GetConsentedUserDataErrorCode\n * @description `getConsentedUserData` 호출이 실패했을 때 반환될 수 있는 에러 코드예요.\n */\nexport type GetConsentedUserDataErrorCode = \"USER_DECLINED\" | \"UNAVAILABLE\" | \"TERMS_NOT_SET\" | \"INVALID_REQUEST\" | \"CANCELED\" | \"CONSENTED_USER_DATA_AGREEMENT_FAILED\" | \"CONSENTED_USER_DATA_INVALID_DATA\";\n/**\n * @public\n * @category 사용자 데이터\n * @name GetConsentedUserDataOptions\n * @description 사용자 동의 기반 데이터를 요청할 때 사용하는 옵션이에요.\n * @property {string} consentedUserDataKey - 서버가 사용자 데이터 제공 동의문과 데이터 묶음을 찾을 때 쓰는 key예요. 예: `cud_delivery`.\n * @property {boolean} [shouldRequestAgreementWhenUserDeclined=false] - `USER_DECLINED` 상태에서도 다시 약관 웹뷰를 띄울지 여부예요. 기본값은 `false`예요.\n */\nexport interface GetConsentedUserDataOptions {\n\tconsentedUserDataKey: string;\n\tshouldRequestAgreementWhenUserDeclined?: boolean;\n}\nexport type ConsentedUserDataKey = \"USER_NAME\" | \"USER_GENDER\" | \"USER_NATIONALITY\" | \"USER_BIRTHDAY\" | \"USER_PHONE\" | \"USER_ADDRESS\" | \"USER_EMAIL\" | \"USER_CONSUMPTION_HISTORY\";\n/**\n * @public\n * @category 사용자 데이터\n * @name ConsentedUserData\n * @description 사용자가 동의한 후 서버에서 제공하는 데이터예요. 요청한 항목에 해당하는 키만 포함될 수 있어요.\n */\nexport type ConsentedUserData = Partial<Record<ConsentedUserDataKey, string>>;\n/**\n * @public\n * @category 사용자 데이터\n * @name getConsentedUserData\n * @description\n * 사용자 동의 기반 데이터를 요청해요.\n * 동의가 필요한 경우 약관 웹뷰를 띄우고, 동의가 완료되면 서버에서 조회한 데이터를 반환해요.\n *\n * @param {GetConsentedUserDataOptions} options - 동의 데이터 요청 옵션이에요.\n * @returns {Promise<ConsentedUserData | undefined>} 서버에서 제공하는 사용자 데이터를 반환해요. 토스앱 버전이 `5.264.0` 미만이면 `undefined`를 반환해요.\n *\n * @throws\n * - {code: `USER_DECLINED`}: 사용자가 명시적으로 거부했고 재요청 옵션이 없거나, 약관 웹뷰에서 동의를 거부한 경우예요.\n * - {code: `UNAVAILABLE`}: 서버가 사용자 동의 여부를 판단할 수 없는 경우예요.\n * - {code: `TERMS_NOT_SET`}: 미니앱에 사용자 데이터 제공 동의문이 설정되지 않은 경우예요.\n * - {code: `INVALID_REQUEST`}: `consentedUserDataKey`가 비어 있거나, `termsUrl`이 없거나, HTTPS 회사 도메인이 아닌 경우예요.\n * - {code: `CANCELED`}: 약관 웹뷰가 결과를 보내기 전에 닫힌 경우예요.\n * - {code: `CONSENTED_USER_DATA_AGREEMENT_FAILED`}: 약관 웹뷰 처리 중 오류가 발생한 경우예요.\n * - {code: `CONSENTED_USER_DATA_INVALID_DATA`}: `PROVIDED`인데 `data`가 없거나, 동의 성공 후 재조회 결과가 `PROVIDED`가 아닌 경우예요.\n *\n * @example\n * ```tsx\n * import { getConsentedUserData } from '@apps-in-toss/framework';\n *\n * async function fetchDeliveryUserData() {\n * try {\n * const data = await getConsentedUserData({\n * consentedUserDataKey: 'cud_delivery',\n * });\n *\n * console.log('사용자 이름:', data?.USER_NAME);\n * console.log('전화번호:', data?.USER_PHONE);\n * } catch (error) {\n * console.error('동의 데이터 조회 실패:', error);\n * }\n * }\n * ```\n */\nexport declare function getConsentedUserData(options: GetConsentedUserDataOptions): Promise<Partial<Record<ConsentedUserDataKey, string>> | undefined>;\n\nexport {};\n"
|
|
149
|
+
},
|
|
146
150
|
{
|
|
147
151
|
"identifier": "requestReview",
|
|
148
152
|
"dts": "/**\n * @public\n * @category 리뷰\n * @name requestReview\n * @description\n * 유저에게 미니앱 리뷰를 요청해요.\n *\n * @property {() => boolean} isSupported 현재 앱 버전이 이 기능을 지원하는지 확인하는 함수예요.\n */\nexport declare function requestReview(): Promise<void>;\nexport declare namespace requestReview {\n\tvar isSupported: () => boolean;\n}\n\nexport {};\n"
|
package/dist/index.cjs
CHANGED
|
@@ -40,6 +40,7 @@ __export(index_exports, {
|
|
|
40
40
|
generateHapticFeedback: () => generateHapticFeedback,
|
|
41
41
|
getAnonymousKey: () => getAnonymousKey,
|
|
42
42
|
getClipboardText: () => getClipboardText,
|
|
43
|
+
getConsentedUserData: () => getConsentedUserData,
|
|
43
44
|
getCurrentLocation: () => getCurrentLocation,
|
|
44
45
|
getDeviceId: () => getDeviceId,
|
|
45
46
|
getGameCenterGameProfile: () => getGameCenterGameProfile,
|
|
@@ -1125,6 +1126,15 @@ async function getServerTime() {
|
|
|
1125
1126
|
}
|
|
1126
1127
|
getServerTime.isSupported = () => isMinVersionSupported(GET_SERVER_TIME_MIN_VERSION);
|
|
1127
1128
|
|
|
1129
|
+
// src/MiniAppModule/native-modules/getConsentedUserData.ts
|
|
1130
|
+
async function getConsentedUserData(options) {
|
|
1131
|
+
const isSupported = isMinVersionSupported({ ios: "5.264.0", android: "5.264.0" });
|
|
1132
|
+
if (!isSupported) {
|
|
1133
|
+
return void 0;
|
|
1134
|
+
}
|
|
1135
|
+
return safePostMessage("getConsentedUserData", options);
|
|
1136
|
+
}
|
|
1137
|
+
|
|
1128
1138
|
// src/MiniAppModule/native-modules/requestReview.ts
|
|
1129
1139
|
var MIN_VERSION2 = { android: "5.253.0", ios: "5.253.0" };
|
|
1130
1140
|
async function requestReview() {
|
|
@@ -1298,6 +1308,7 @@ var INTERNAL__module = {
|
|
|
1298
1308
|
generateHapticFeedback,
|
|
1299
1309
|
getAnonymousKey,
|
|
1300
1310
|
getClipboardText,
|
|
1311
|
+
getConsentedUserData,
|
|
1301
1312
|
getCurrentLocation,
|
|
1302
1313
|
getDeviceId,
|
|
1303
1314
|
getGameCenterGameProfile,
|
package/dist/index.d.cts
CHANGED
|
@@ -273,6 +273,73 @@ type GetAnonymousKeyResponse = GetAnonymousKeySuccessResponse;
|
|
|
273
273
|
*/
|
|
274
274
|
declare function getAnonymousKey(): Promise<GetAnonymousKeySuccessResponse | 'ERROR' | undefined>;
|
|
275
275
|
|
|
276
|
+
/**
|
|
277
|
+
* @public
|
|
278
|
+
* @category 사용자 데이터
|
|
279
|
+
* @name GetConsentedUserDataErrorCode
|
|
280
|
+
* @description `getConsentedUserData` 호출이 실패했을 때 반환될 수 있는 에러 코드예요.
|
|
281
|
+
*/
|
|
282
|
+
type GetConsentedUserDataErrorCode = 'USER_DECLINED' | 'UNAVAILABLE' | 'TERMS_NOT_SET' | 'INVALID_REQUEST' | 'CANCELED' | 'CONSENTED_USER_DATA_AGREEMENT_FAILED' | 'CONSENTED_USER_DATA_INVALID_DATA';
|
|
283
|
+
/**
|
|
284
|
+
* @public
|
|
285
|
+
* @category 사용자 데이터
|
|
286
|
+
* @name GetConsentedUserDataOptions
|
|
287
|
+
* @description 사용자 동의 기반 데이터를 요청할 때 사용하는 옵션이에요.
|
|
288
|
+
* @property {string} consentedUserDataKey - 서버가 사용자 데이터 제공 동의문과 데이터 묶음을 찾을 때 쓰는 key예요. 예: `cud_delivery`.
|
|
289
|
+
* @property {boolean} [shouldRequestAgreementWhenUserDeclined=false] - `USER_DECLINED` 상태에서도 다시 약관 웹뷰를 띄울지 여부예요. 기본값은 `false`예요.
|
|
290
|
+
*/
|
|
291
|
+
interface GetConsentedUserDataOptions {
|
|
292
|
+
consentedUserDataKey: string;
|
|
293
|
+
shouldRequestAgreementWhenUserDeclined?: boolean;
|
|
294
|
+
}
|
|
295
|
+
type ConsentedUserDataKey = 'USER_NAME' | 'USER_GENDER' | 'USER_NATIONALITY' | 'USER_BIRTHDAY' | 'USER_PHONE' | 'USER_ADDRESS' | 'USER_EMAIL' | 'USER_CONSUMPTION_HISTORY';
|
|
296
|
+
/**
|
|
297
|
+
* @public
|
|
298
|
+
* @category 사용자 데이터
|
|
299
|
+
* @name ConsentedUserData
|
|
300
|
+
* @description 사용자가 동의한 후 서버에서 제공하는 데이터예요. 요청한 항목에 해당하는 키만 포함될 수 있어요.
|
|
301
|
+
*/
|
|
302
|
+
type ConsentedUserData = Partial<Record<ConsentedUserDataKey, string>>;
|
|
303
|
+
/**
|
|
304
|
+
* @public
|
|
305
|
+
* @category 사용자 데이터
|
|
306
|
+
* @name getConsentedUserData
|
|
307
|
+
* @description
|
|
308
|
+
* 사용자 동의 기반 데이터를 요청해요.
|
|
309
|
+
* 동의가 필요한 경우 약관 웹뷰를 띄우고, 동의가 완료되면 서버에서 조회한 데이터를 반환해요.
|
|
310
|
+
*
|
|
311
|
+
* @param {GetConsentedUserDataOptions} options - 동의 데이터 요청 옵션이에요.
|
|
312
|
+
* @returns {Promise<ConsentedUserData | undefined>} 서버에서 제공하는 사용자 데이터를 반환해요. 토스앱 버전이 `5.264.0` 미만이면 `undefined`를 반환해요.
|
|
313
|
+
*
|
|
314
|
+
* @throws
|
|
315
|
+
* - {code: `USER_DECLINED`}: 사용자가 명시적으로 거부했고 재요청 옵션이 없거나, 약관 웹뷰에서 동의를 거부한 경우예요.
|
|
316
|
+
* - {code: `UNAVAILABLE`}: 서버가 사용자 동의 여부를 판단할 수 없는 경우예요.
|
|
317
|
+
* - {code: `TERMS_NOT_SET`}: 미니앱에 사용자 데이터 제공 동의문이 설정되지 않은 경우예요.
|
|
318
|
+
* - {code: `INVALID_REQUEST`}: `consentedUserDataKey`가 비어 있거나, `termsUrl`이 없거나, HTTPS 회사 도메인이 아닌 경우예요.
|
|
319
|
+
* - {code: `CANCELED`}: 약관 웹뷰가 결과를 보내기 전에 닫힌 경우예요.
|
|
320
|
+
* - {code: `CONSENTED_USER_DATA_AGREEMENT_FAILED`}: 약관 웹뷰 처리 중 오류가 발생한 경우예요.
|
|
321
|
+
* - {code: `CONSENTED_USER_DATA_INVALID_DATA`}: `PROVIDED`인데 `data`가 없거나, 동의 성공 후 재조회 결과가 `PROVIDED`가 아닌 경우예요.
|
|
322
|
+
*
|
|
323
|
+
* @example
|
|
324
|
+
* ```tsx
|
|
325
|
+
* import { getConsentedUserData } from '@apps-in-toss/framework';
|
|
326
|
+
*
|
|
327
|
+
* async function fetchDeliveryUserData() {
|
|
328
|
+
* try {
|
|
329
|
+
* const data = await getConsentedUserData({
|
|
330
|
+
* consentedUserDataKey: 'cud_delivery',
|
|
331
|
+
* });
|
|
332
|
+
*
|
|
333
|
+
* console.log('사용자 이름:', data?.USER_NAME);
|
|
334
|
+
* console.log('전화번호:', data?.USER_PHONE);
|
|
335
|
+
* } catch (error) {
|
|
336
|
+
* console.error('동의 데이터 조회 실패:', error);
|
|
337
|
+
* }
|
|
338
|
+
* }
|
|
339
|
+
* ```
|
|
340
|
+
*/
|
|
341
|
+
declare function getConsentedUserData(options: GetConsentedUserDataOptions): Promise<Partial<Record<ConsentedUserDataKey, string>> | undefined>;
|
|
342
|
+
|
|
276
343
|
/**
|
|
277
344
|
* @category 게임센터
|
|
278
345
|
* @name GameCenterGameProfileResponse
|
|
@@ -1433,6 +1500,7 @@ interface AsyncMethodsMap {
|
|
|
1433
1500
|
getServerTime: (params: CompatiblePlaceholderArgument) => Promise<{
|
|
1434
1501
|
serverTime: number;
|
|
1435
1502
|
}>;
|
|
1503
|
+
getConsentedUserData: (params: GetConsentedUserDataOptions) => Promise<ConsentedUserData>;
|
|
1436
1504
|
shareWithScheme: (params: {
|
|
1437
1505
|
schemeURL: string;
|
|
1438
1506
|
}) => Promise<void>;
|
|
@@ -3604,4 +3672,4 @@ declare const INTERNAL__module: {
|
|
|
3604
3672
|
tossCoreEventLog: typeof tossCoreEventLog;
|
|
3605
3673
|
};
|
|
3606
3674
|
|
|
3607
|
-
export { type AlbumItemResponse, type AlbumItemType, type AppsInTossSignTossCertParams, type CheckoutPaymentOptions, type CheckoutPaymentResult, type CompletedOrRefundedOrdersResult, type ConsumableProductListItem, type ContactsViralParams, type CreateSubscriptionPurchaseOrderOptions, type EventLogParams, type FetchAlbumItemsOptions, 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 NotificationAgreementResult, type OpenPDFViewerParams, type OpenPDFViewerResult, type Primitive, type RequestNotificationAgreementOptions, type RequestTossPayPaysBillingOptions, type RequestTossPayPaysBillingResult, type SaveBase64DataParams, Storage, type SubmitGameCenterLeaderBoardScoreResponse, type SubscriptionProductListItem, TossPay, type UpdateLocationEventEmitter, appLogin, appsInTossEvent, appsInTossSignTossCert, checkoutPayment, closeView, contactsViral, eventLog, fetchAlbumItems, 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, openPDFViewer, openURL, processProductGrant, requestNotificationAgreement, requestOneTimePurchase, requestReview, requestSubscriptionPurchase, requestTossPayPaysBilling, safePostMessage, safeSyncPostMessage, saveBase64Data, setClipboardText, setDeviceOrientation, setIosSwipeGestureEnabled, setScreenAwakeMode, setSecureScreen, share, shareWithScheme, startUpdateLocation, submitGameCenterLeaderBoardScore };
|
|
3675
|
+
export { type AlbumItemResponse, type AlbumItemType, type AppsInTossSignTossCertParams, type CheckoutPaymentOptions, type CheckoutPaymentResult, type CompletedOrRefundedOrdersResult, type ConsentedUserData, type ConsumableProductListItem, type ContactsViralParams, type CreateSubscriptionPurchaseOrderOptions, type EventLogParams, type FetchAlbumItemsOptions, type GameCenterGameProfileResponse, type GetAnonymousKeyResponse, type GetAnonymousKeySuccessResponse, type GetConsentedUserDataErrorCode, type GetConsentedUserDataOptions, 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 NotificationAgreementResult, type OpenPDFViewerParams, type OpenPDFViewerResult, type Primitive, type RequestNotificationAgreementOptions, type RequestTossPayPaysBillingOptions, type RequestTossPayPaysBillingResult, type SaveBase64DataParams, Storage, type SubmitGameCenterLeaderBoardScoreResponse, type SubscriptionProductListItem, TossPay, type UpdateLocationEventEmitter, appLogin, appsInTossEvent, appsInTossSignTossCert, checkoutPayment, closeView, contactsViral, eventLog, fetchAlbumItems, fetchAlbumPhotos, fetchContacts, generateHapticFeedback, getAnonymousKey, getClipboardText, getConsentedUserData, getCurrentLocation, getDeviceId, getGameCenterGameProfile, getGroupId, getIsTossLoginIntegratedService, getLocale, getNetworkStatus, getOperationalEnvironment, getPlatformOS, getSchemeUri, getServerTime, getTossAppVersion, getTossShareLink, getUserKeyForGame, grantPromotionReward, grantPromotionRewardForGame, iapCreateOneTimePurchaseOrder, isMinVersionSupported, onVisibilityChangedByTransparentServiceWeb, openCamera, openGameCenterLeaderboard, openPDFViewer, openURL, processProductGrant, requestNotificationAgreement, requestOneTimePurchase, requestReview, requestSubscriptionPurchase, requestTossPayPaysBilling, safePostMessage, safeSyncPostMessage, saveBase64Data, setClipboardText, setDeviceOrientation, setIosSwipeGestureEnabled, setScreenAwakeMode, setSecureScreen, share, shareWithScheme, startUpdateLocation, submitGameCenterLeaderBoardScore };
|
package/dist/index.d.ts
CHANGED
|
@@ -273,6 +273,73 @@ type GetAnonymousKeyResponse = GetAnonymousKeySuccessResponse;
|
|
|
273
273
|
*/
|
|
274
274
|
declare function getAnonymousKey(): Promise<GetAnonymousKeySuccessResponse | 'ERROR' | undefined>;
|
|
275
275
|
|
|
276
|
+
/**
|
|
277
|
+
* @public
|
|
278
|
+
* @category 사용자 데이터
|
|
279
|
+
* @name GetConsentedUserDataErrorCode
|
|
280
|
+
* @description `getConsentedUserData` 호출이 실패했을 때 반환될 수 있는 에러 코드예요.
|
|
281
|
+
*/
|
|
282
|
+
type GetConsentedUserDataErrorCode = 'USER_DECLINED' | 'UNAVAILABLE' | 'TERMS_NOT_SET' | 'INVALID_REQUEST' | 'CANCELED' | 'CONSENTED_USER_DATA_AGREEMENT_FAILED' | 'CONSENTED_USER_DATA_INVALID_DATA';
|
|
283
|
+
/**
|
|
284
|
+
* @public
|
|
285
|
+
* @category 사용자 데이터
|
|
286
|
+
* @name GetConsentedUserDataOptions
|
|
287
|
+
* @description 사용자 동의 기반 데이터를 요청할 때 사용하는 옵션이에요.
|
|
288
|
+
* @property {string} consentedUserDataKey - 서버가 사용자 데이터 제공 동의문과 데이터 묶음을 찾을 때 쓰는 key예요. 예: `cud_delivery`.
|
|
289
|
+
* @property {boolean} [shouldRequestAgreementWhenUserDeclined=false] - `USER_DECLINED` 상태에서도 다시 약관 웹뷰를 띄울지 여부예요. 기본값은 `false`예요.
|
|
290
|
+
*/
|
|
291
|
+
interface GetConsentedUserDataOptions {
|
|
292
|
+
consentedUserDataKey: string;
|
|
293
|
+
shouldRequestAgreementWhenUserDeclined?: boolean;
|
|
294
|
+
}
|
|
295
|
+
type ConsentedUserDataKey = 'USER_NAME' | 'USER_GENDER' | 'USER_NATIONALITY' | 'USER_BIRTHDAY' | 'USER_PHONE' | 'USER_ADDRESS' | 'USER_EMAIL' | 'USER_CONSUMPTION_HISTORY';
|
|
296
|
+
/**
|
|
297
|
+
* @public
|
|
298
|
+
* @category 사용자 데이터
|
|
299
|
+
* @name ConsentedUserData
|
|
300
|
+
* @description 사용자가 동의한 후 서버에서 제공하는 데이터예요. 요청한 항목에 해당하는 키만 포함될 수 있어요.
|
|
301
|
+
*/
|
|
302
|
+
type ConsentedUserData = Partial<Record<ConsentedUserDataKey, string>>;
|
|
303
|
+
/**
|
|
304
|
+
* @public
|
|
305
|
+
* @category 사용자 데이터
|
|
306
|
+
* @name getConsentedUserData
|
|
307
|
+
* @description
|
|
308
|
+
* 사용자 동의 기반 데이터를 요청해요.
|
|
309
|
+
* 동의가 필요한 경우 약관 웹뷰를 띄우고, 동의가 완료되면 서버에서 조회한 데이터를 반환해요.
|
|
310
|
+
*
|
|
311
|
+
* @param {GetConsentedUserDataOptions} options - 동의 데이터 요청 옵션이에요.
|
|
312
|
+
* @returns {Promise<ConsentedUserData | undefined>} 서버에서 제공하는 사용자 데이터를 반환해요. 토스앱 버전이 `5.264.0` 미만이면 `undefined`를 반환해요.
|
|
313
|
+
*
|
|
314
|
+
* @throws
|
|
315
|
+
* - {code: `USER_DECLINED`}: 사용자가 명시적으로 거부했고 재요청 옵션이 없거나, 약관 웹뷰에서 동의를 거부한 경우예요.
|
|
316
|
+
* - {code: `UNAVAILABLE`}: 서버가 사용자 동의 여부를 판단할 수 없는 경우예요.
|
|
317
|
+
* - {code: `TERMS_NOT_SET`}: 미니앱에 사용자 데이터 제공 동의문이 설정되지 않은 경우예요.
|
|
318
|
+
* - {code: `INVALID_REQUEST`}: `consentedUserDataKey`가 비어 있거나, `termsUrl`이 없거나, HTTPS 회사 도메인이 아닌 경우예요.
|
|
319
|
+
* - {code: `CANCELED`}: 약관 웹뷰가 결과를 보내기 전에 닫힌 경우예요.
|
|
320
|
+
* - {code: `CONSENTED_USER_DATA_AGREEMENT_FAILED`}: 약관 웹뷰 처리 중 오류가 발생한 경우예요.
|
|
321
|
+
* - {code: `CONSENTED_USER_DATA_INVALID_DATA`}: `PROVIDED`인데 `data`가 없거나, 동의 성공 후 재조회 결과가 `PROVIDED`가 아닌 경우예요.
|
|
322
|
+
*
|
|
323
|
+
* @example
|
|
324
|
+
* ```tsx
|
|
325
|
+
* import { getConsentedUserData } from '@apps-in-toss/framework';
|
|
326
|
+
*
|
|
327
|
+
* async function fetchDeliveryUserData() {
|
|
328
|
+
* try {
|
|
329
|
+
* const data = await getConsentedUserData({
|
|
330
|
+
* consentedUserDataKey: 'cud_delivery',
|
|
331
|
+
* });
|
|
332
|
+
*
|
|
333
|
+
* console.log('사용자 이름:', data?.USER_NAME);
|
|
334
|
+
* console.log('전화번호:', data?.USER_PHONE);
|
|
335
|
+
* } catch (error) {
|
|
336
|
+
* console.error('동의 데이터 조회 실패:', error);
|
|
337
|
+
* }
|
|
338
|
+
* }
|
|
339
|
+
* ```
|
|
340
|
+
*/
|
|
341
|
+
declare function getConsentedUserData(options: GetConsentedUserDataOptions): Promise<Partial<Record<ConsentedUserDataKey, string>> | undefined>;
|
|
342
|
+
|
|
276
343
|
/**
|
|
277
344
|
* @category 게임센터
|
|
278
345
|
* @name GameCenterGameProfileResponse
|
|
@@ -1433,6 +1500,7 @@ interface AsyncMethodsMap {
|
|
|
1433
1500
|
getServerTime: (params: CompatiblePlaceholderArgument) => Promise<{
|
|
1434
1501
|
serverTime: number;
|
|
1435
1502
|
}>;
|
|
1503
|
+
getConsentedUserData: (params: GetConsentedUserDataOptions) => Promise<ConsentedUserData>;
|
|
1436
1504
|
shareWithScheme: (params: {
|
|
1437
1505
|
schemeURL: string;
|
|
1438
1506
|
}) => Promise<void>;
|
|
@@ -3604,4 +3672,4 @@ declare const INTERNAL__module: {
|
|
|
3604
3672
|
tossCoreEventLog: typeof tossCoreEventLog;
|
|
3605
3673
|
};
|
|
3606
3674
|
|
|
3607
|
-
export { type AlbumItemResponse, type AlbumItemType, type AppsInTossSignTossCertParams, type CheckoutPaymentOptions, type CheckoutPaymentResult, type CompletedOrRefundedOrdersResult, type ConsumableProductListItem, type ContactsViralParams, type CreateSubscriptionPurchaseOrderOptions, type EventLogParams, type FetchAlbumItemsOptions, 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 NotificationAgreementResult, type OpenPDFViewerParams, type OpenPDFViewerResult, type Primitive, type RequestNotificationAgreementOptions, type RequestTossPayPaysBillingOptions, type RequestTossPayPaysBillingResult, type SaveBase64DataParams, Storage, type SubmitGameCenterLeaderBoardScoreResponse, type SubscriptionProductListItem, TossPay, type UpdateLocationEventEmitter, appLogin, appsInTossEvent, appsInTossSignTossCert, checkoutPayment, closeView, contactsViral, eventLog, fetchAlbumItems, 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, openPDFViewer, openURL, processProductGrant, requestNotificationAgreement, requestOneTimePurchase, requestReview, requestSubscriptionPurchase, requestTossPayPaysBilling, safePostMessage, safeSyncPostMessage, saveBase64Data, setClipboardText, setDeviceOrientation, setIosSwipeGestureEnabled, setScreenAwakeMode, setSecureScreen, share, shareWithScheme, startUpdateLocation, submitGameCenterLeaderBoardScore };
|
|
3675
|
+
export { type AlbumItemResponse, type AlbumItemType, type AppsInTossSignTossCertParams, type CheckoutPaymentOptions, type CheckoutPaymentResult, type CompletedOrRefundedOrdersResult, type ConsentedUserData, type ConsumableProductListItem, type ContactsViralParams, type CreateSubscriptionPurchaseOrderOptions, type EventLogParams, type FetchAlbumItemsOptions, type GameCenterGameProfileResponse, type GetAnonymousKeyResponse, type GetAnonymousKeySuccessResponse, type GetConsentedUserDataErrorCode, type GetConsentedUserDataOptions, 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 NotificationAgreementResult, type OpenPDFViewerParams, type OpenPDFViewerResult, type Primitive, type RequestNotificationAgreementOptions, type RequestTossPayPaysBillingOptions, type RequestTossPayPaysBillingResult, type SaveBase64DataParams, Storage, type SubmitGameCenterLeaderBoardScoreResponse, type SubscriptionProductListItem, TossPay, type UpdateLocationEventEmitter, appLogin, appsInTossEvent, appsInTossSignTossCert, checkoutPayment, closeView, contactsViral, eventLog, fetchAlbumItems, fetchAlbumPhotos, fetchContacts, generateHapticFeedback, getAnonymousKey, getClipboardText, getConsentedUserData, getCurrentLocation, getDeviceId, getGameCenterGameProfile, getGroupId, getIsTossLoginIntegratedService, getLocale, getNetworkStatus, getOperationalEnvironment, getPlatformOS, getSchemeUri, getServerTime, getTossAppVersion, getTossShareLink, getUserKeyForGame, grantPromotionReward, grantPromotionRewardForGame, iapCreateOneTimePurchaseOrder, isMinVersionSupported, onVisibilityChangedByTransparentServiceWeb, openCamera, openGameCenterLeaderboard, openPDFViewer, openURL, processProductGrant, requestNotificationAgreement, requestOneTimePurchase, requestReview, requestSubscriptionPurchase, requestTossPayPaysBilling, safePostMessage, safeSyncPostMessage, saveBase64Data, setClipboardText, setDeviceOrientation, setIosSwipeGestureEnabled, setScreenAwakeMode, setSecureScreen, share, shareWithScheme, startUpdateLocation, submitGameCenterLeaderBoardScore };
|
package/dist/index.js
CHANGED
|
@@ -1039,6 +1039,15 @@ async function getServerTime() {
|
|
|
1039
1039
|
}
|
|
1040
1040
|
getServerTime.isSupported = () => isMinVersionSupported(GET_SERVER_TIME_MIN_VERSION);
|
|
1041
1041
|
|
|
1042
|
+
// src/MiniAppModule/native-modules/getConsentedUserData.ts
|
|
1043
|
+
async function getConsentedUserData(options) {
|
|
1044
|
+
const isSupported = isMinVersionSupported({ ios: "5.264.0", android: "5.264.0" });
|
|
1045
|
+
if (!isSupported) {
|
|
1046
|
+
return void 0;
|
|
1047
|
+
}
|
|
1048
|
+
return safePostMessage("getConsentedUserData", options);
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1042
1051
|
// src/MiniAppModule/native-modules/requestReview.ts
|
|
1043
1052
|
var MIN_VERSION2 = { android: "5.253.0", ios: "5.253.0" };
|
|
1044
1053
|
async function requestReview() {
|
|
@@ -1211,6 +1220,7 @@ export {
|
|
|
1211
1220
|
generateHapticFeedback,
|
|
1212
1221
|
getAnonymousKey,
|
|
1213
1222
|
getClipboardText,
|
|
1223
|
+
getConsentedUserData,
|
|
1214
1224
|
getCurrentLocation,
|
|
1215
1225
|
getDeviceId,
|
|
1216
1226
|
getGameCenterGameProfile,
|
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
|
+
"version": "2.7.1",
|
|
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.
|
|
45
|
+
"@apps-in-toss/types": "2.7.1",
|
|
46
46
|
"brick-module": "0.5.2",
|
|
47
47
|
"es-toolkit": "^1.39.3"
|
|
48
48
|
},
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { isMinVersionSupported } from './isMinVersionSupported';
|
|
2
|
+
import { safePostMessage } from '../../natives';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @public
|
|
6
|
+
* @category 사용자 데이터
|
|
7
|
+
* @name GetConsentedUserDataErrorCode
|
|
8
|
+
* @description `getConsentedUserData` 호출이 실패했을 때 반환될 수 있는 에러 코드예요.
|
|
9
|
+
*/
|
|
10
|
+
export type GetConsentedUserDataErrorCode =
|
|
11
|
+
| 'USER_DECLINED'
|
|
12
|
+
| 'UNAVAILABLE'
|
|
13
|
+
| 'TERMS_NOT_SET'
|
|
14
|
+
| 'INVALID_REQUEST'
|
|
15
|
+
| 'CANCELED'
|
|
16
|
+
| 'CONSENTED_USER_DATA_AGREEMENT_FAILED'
|
|
17
|
+
| 'CONSENTED_USER_DATA_INVALID_DATA';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @public
|
|
21
|
+
* @category 사용자 데이터
|
|
22
|
+
* @name GetConsentedUserDataOptions
|
|
23
|
+
* @description 사용자 동의 기반 데이터를 요청할 때 사용하는 옵션이에요.
|
|
24
|
+
* @property {string} consentedUserDataKey - 서버가 사용자 데이터 제공 동의문과 데이터 묶음을 찾을 때 쓰는 key예요. 예: `cud_delivery`.
|
|
25
|
+
* @property {boolean} [shouldRequestAgreementWhenUserDeclined=false] - `USER_DECLINED` 상태에서도 다시 약관 웹뷰를 띄울지 여부예요. 기본값은 `false`예요.
|
|
26
|
+
*/
|
|
27
|
+
export interface GetConsentedUserDataOptions {
|
|
28
|
+
consentedUserDataKey: string;
|
|
29
|
+
shouldRequestAgreementWhenUserDeclined?: boolean;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
type ConsentedUserDataKey =
|
|
33
|
+
| 'USER_NAME'
|
|
34
|
+
| 'USER_GENDER'
|
|
35
|
+
| 'USER_NATIONALITY'
|
|
36
|
+
| 'USER_BIRTHDAY'
|
|
37
|
+
| 'USER_PHONE'
|
|
38
|
+
| 'USER_ADDRESS'
|
|
39
|
+
| 'USER_EMAIL'
|
|
40
|
+
| 'USER_CONSUMPTION_HISTORY';
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @public
|
|
44
|
+
* @category 사용자 데이터
|
|
45
|
+
* @name ConsentedUserData
|
|
46
|
+
* @description 사용자가 동의한 후 서버에서 제공하는 데이터예요. 요청한 항목에 해당하는 키만 포함될 수 있어요.
|
|
47
|
+
*/
|
|
48
|
+
export type ConsentedUserData = Partial<Record<ConsentedUserDataKey, string>>;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* @public
|
|
52
|
+
* @category 사용자 데이터
|
|
53
|
+
* @name getConsentedUserData
|
|
54
|
+
* @description
|
|
55
|
+
* 사용자 동의 기반 데이터를 요청해요.
|
|
56
|
+
* 동의가 필요한 경우 약관 웹뷰를 띄우고, 동의가 완료되면 서버에서 조회한 데이터를 반환해요.
|
|
57
|
+
*
|
|
58
|
+
* @param {GetConsentedUserDataOptions} options - 동의 데이터 요청 옵션이에요.
|
|
59
|
+
* @returns {Promise<ConsentedUserData | undefined>} 서버에서 제공하는 사용자 데이터를 반환해요. 토스앱 버전이 `5.264.0` 미만이면 `undefined`를 반환해요.
|
|
60
|
+
*
|
|
61
|
+
* @throws
|
|
62
|
+
* - {code: `USER_DECLINED`}: 사용자가 명시적으로 거부했고 재요청 옵션이 없거나, 약관 웹뷰에서 동의를 거부한 경우예요.
|
|
63
|
+
* - {code: `UNAVAILABLE`}: 서버가 사용자 동의 여부를 판단할 수 없는 경우예요.
|
|
64
|
+
* - {code: `TERMS_NOT_SET`}: 미니앱에 사용자 데이터 제공 동의문이 설정되지 않은 경우예요.
|
|
65
|
+
* - {code: `INVALID_REQUEST`}: `consentedUserDataKey`가 비어 있거나, `termsUrl`이 없거나, HTTPS 회사 도메인이 아닌 경우예요.
|
|
66
|
+
* - {code: `CANCELED`}: 약관 웹뷰가 결과를 보내기 전에 닫힌 경우예요.
|
|
67
|
+
* - {code: `CONSENTED_USER_DATA_AGREEMENT_FAILED`}: 약관 웹뷰 처리 중 오류가 발생한 경우예요.
|
|
68
|
+
* - {code: `CONSENTED_USER_DATA_INVALID_DATA`}: `PROVIDED`인데 `data`가 없거나, 동의 성공 후 재조회 결과가 `PROVIDED`가 아닌 경우예요.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```tsx
|
|
72
|
+
* import { getConsentedUserData } from '@apps-in-toss/framework';
|
|
73
|
+
*
|
|
74
|
+
* async function fetchDeliveryUserData() {
|
|
75
|
+
* try {
|
|
76
|
+
* const data = await getConsentedUserData({
|
|
77
|
+
* consentedUserDataKey: 'cud_delivery',
|
|
78
|
+
* });
|
|
79
|
+
*
|
|
80
|
+
* console.log('사용자 이름:', data?.USER_NAME);
|
|
81
|
+
* console.log('전화번호:', data?.USER_PHONE);
|
|
82
|
+
* } catch (error) {
|
|
83
|
+
* console.error('동의 데이터 조회 실패:', error);
|
|
84
|
+
* }
|
|
85
|
+
* }
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
export async function getConsentedUserData(options: GetConsentedUserDataOptions) {
|
|
89
|
+
const isSupported = isMinVersionSupported({ ios: '5.264.0', android: '5.264.0' });
|
|
90
|
+
|
|
91
|
+
if (!isSupported) {
|
|
92
|
+
return undefined;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return safePostMessage('getConsentedUserData', options);
|
|
96
|
+
}
|
|
@@ -54,6 +54,7 @@ export * from './appsInTossSignTossCert';
|
|
|
54
54
|
export * from './getGroupId';
|
|
55
55
|
export * from './shareWithScheme';
|
|
56
56
|
export * from './getServerTime';
|
|
57
|
+
export * from './getConsentedUserData';
|
|
57
58
|
export * from './requestReview';
|
|
58
59
|
export * from './requestNotificationAgreement';
|
|
59
60
|
|
|
@@ -11,6 +11,7 @@ import type { AppsInTossSignTossCertParams } from './native-modules/appsInTossSi
|
|
|
11
11
|
import type { CheckoutPaymentOptions, CheckoutPaymentResult } from './native-modules/checkoutPayment';
|
|
12
12
|
import type { AlbumItemResponse, FetchAlbumItemsOptions } from './native-modules/fetchAlbumItems';
|
|
13
13
|
import type { GetAnonymousKeyResponse } from './native-modules/getAnonymousKey';
|
|
14
|
+
import type { ConsentedUserData, GetConsentedUserDataOptions } from './native-modules/getConsentedUserData';
|
|
14
15
|
import type { GameCenterGameProfileResponse } from './native-modules/getGameCenterGameProfile';
|
|
15
16
|
import type { GetUserKeyForGameResponse } from './native-modules/getUserKeyForGame';
|
|
16
17
|
import type { GrantPromotionRewardForGameResponse } from './native-modules/grantPromotionRewardForGame';
|
|
@@ -105,6 +106,7 @@ export interface AsyncMethodsMap {
|
|
|
105
106
|
getIsTossLoginIntegratedService: (params: object) => Promise<boolean | undefined>;
|
|
106
107
|
|
|
107
108
|
getServerTime: (params: CompatiblePlaceholderArgument) => Promise<{ serverTime: number }>;
|
|
109
|
+
getConsentedUserData: (params: GetConsentedUserDataOptions) => Promise<ConsentedUserData>;
|
|
108
110
|
shareWithScheme: (params: { schemeURL: string }) => Promise<void>;
|
|
109
111
|
requestMiniAppReview: (params: { title: string }) => Promise<void>;
|
|
110
112
|
requestNotificationAgreement: (params: RequestNotificationAgreementOptions) => Promise<void>;
|
package/src/async-bridges.ts
CHANGED
|
@@ -37,4 +37,5 @@ export * from './MiniAppModule/native-modules/grantPromotionReward';
|
|
|
37
37
|
export * from './MiniAppModule/native-modules/grantPromotionRewardForGame';
|
|
38
38
|
export * from './MiniAppModule/native-modules/getIsTossLoginIntegratedService';
|
|
39
39
|
export * from './MiniAppModule/native-modules/getServerTime';
|
|
40
|
+
export * from './MiniAppModule/native-modules/getConsentedUserData';
|
|
40
41
|
export * from './MiniAppModule/native-modules/requestReview';
|