@apps-in-toss/native-modules 2.6.1 → 2.7.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/dist/bridges-meta.json +4 -0
- package/dist/index.cjs +33 -0
- package/dist/index.d.cts +87 -3
- package/dist/index.d.ts +87 -3
- package/dist/index.js +31 -0
- package/package.json +2 -2
- package/src/MiniAppModule/native-modules/getConsentedUserData.ts +96 -0
- package/src/MiniAppModule/native-modules/iap.ts +39 -2
- 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,
|
|
@@ -67,6 +68,7 @@ __export(index_exports, {
|
|
|
67
68
|
requestNotificationAgreement: () => requestNotificationAgreement,
|
|
68
69
|
requestOneTimePurchase: () => requestOneTimePurchase,
|
|
69
70
|
requestReview: () => requestReview,
|
|
71
|
+
requestSubscriptionPurchase: () => requestSubscriptionPurchase,
|
|
70
72
|
requestTossPayPaysBilling: () => requestTossPayPaysBilling,
|
|
71
73
|
safePostMessage: () => safePostMessage,
|
|
72
74
|
safeSyncPostMessage: () => safeSyncPostMessage,
|
|
@@ -716,6 +718,26 @@ function requestOneTimePurchase(params) {
|
|
|
716
718
|
);
|
|
717
719
|
return unregisterCallbacks;
|
|
718
720
|
}
|
|
721
|
+
function requestSubscriptionPurchase(params) {
|
|
722
|
+
const { options, onEvent, onError } = params;
|
|
723
|
+
const { sku, offerId } = options;
|
|
724
|
+
const unregisterCallbacks = INTERNAL__appBridgeHandler.invokeAppBridgeMethod(
|
|
725
|
+
"requestSubscriptionPurchase",
|
|
726
|
+
{ sku, offerId: offerId ?? null },
|
|
727
|
+
{
|
|
728
|
+
onPurchased: (params2) => {
|
|
729
|
+
onEvent({ type: "purchased", data: params2 });
|
|
730
|
+
},
|
|
731
|
+
onSuccess: (result) => {
|
|
732
|
+
onEvent({ type: "success", data: result });
|
|
733
|
+
},
|
|
734
|
+
onError: (error) => {
|
|
735
|
+
onError(error);
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
);
|
|
739
|
+
return unregisterCallbacks;
|
|
740
|
+
}
|
|
719
741
|
function createOneTimePurchaseOrder(params) {
|
|
720
742
|
const isIAPSupported = isMinVersionSupported({
|
|
721
743
|
android: "5.219.0",
|
|
@@ -1104,6 +1126,15 @@ async function getServerTime() {
|
|
|
1104
1126
|
}
|
|
1105
1127
|
getServerTime.isSupported = () => isMinVersionSupported(GET_SERVER_TIME_MIN_VERSION);
|
|
1106
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
|
+
|
|
1107
1138
|
// src/MiniAppModule/native-modules/requestReview.ts
|
|
1108
1139
|
var MIN_VERSION2 = { android: "5.253.0", ios: "5.253.0" };
|
|
1109
1140
|
async function requestReview() {
|
|
@@ -1277,6 +1308,7 @@ var INTERNAL__module = {
|
|
|
1277
1308
|
generateHapticFeedback,
|
|
1278
1309
|
getAnonymousKey,
|
|
1279
1310
|
getClipboardText,
|
|
1311
|
+
getConsentedUserData,
|
|
1280
1312
|
getCurrentLocation,
|
|
1281
1313
|
getDeviceId,
|
|
1282
1314
|
getGameCenterGameProfile,
|
|
@@ -1304,6 +1336,7 @@ var INTERNAL__module = {
|
|
|
1304
1336
|
requestNotificationAgreement,
|
|
1305
1337
|
requestOneTimePurchase,
|
|
1306
1338
|
requestReview,
|
|
1339
|
+
requestSubscriptionPurchase,
|
|
1307
1340
|
requestTossPayPaysBilling,
|
|
1308
1341
|
safePostMessage,
|
|
1309
1342
|
safeSyncPostMessage,
|
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
|
|
@@ -470,7 +537,7 @@ interface OneTimePurchaseSuccessEvent {
|
|
|
470
537
|
type: 'success';
|
|
471
538
|
data: IapCreateOneTimePurchaseOrderResult;
|
|
472
539
|
}
|
|
473
|
-
interface
|
|
540
|
+
interface OneTimePurchasedEvent {
|
|
474
541
|
type: 'purchased';
|
|
475
542
|
data: {
|
|
476
543
|
orderId: string;
|
|
@@ -497,7 +564,7 @@ interface IapCreateOneTimePurchaseOrderOptions {
|
|
|
497
564
|
}
|
|
498
565
|
interface IapRequestOneTimePurchaseOptions {
|
|
499
566
|
options: Sku;
|
|
500
|
-
onEvent: (event:
|
|
567
|
+
onEvent: (event: OneTimePurchasedEvent | OneTimePurchaseSuccessEvent) => void | Promise<void>;
|
|
501
568
|
onError: (error: unknown) => void | Promise<void>;
|
|
502
569
|
}
|
|
503
570
|
declare function iapCreateOneTimePurchaseOrder(params: Sku): Promise<IapCreateOneTimePurchaseOrderResult>;
|
|
@@ -506,6 +573,22 @@ declare function processProductGrant(params: {
|
|
|
506
573
|
isProductGranted: boolean;
|
|
507
574
|
}): Promise<void>;
|
|
508
575
|
declare function requestOneTimePurchase(params: IapRequestOneTimePurchaseOptions): () => void;
|
|
576
|
+
interface SubscriptionPurchasedEvent {
|
|
577
|
+
type: 'purchased';
|
|
578
|
+
data: {
|
|
579
|
+
orderId: string;
|
|
580
|
+
subscriptionId?: string;
|
|
581
|
+
};
|
|
582
|
+
}
|
|
583
|
+
interface IapRequestSubscriptionPurchaseOrderOptions {
|
|
584
|
+
options: {
|
|
585
|
+
sku: string;
|
|
586
|
+
offerId?: string | null;
|
|
587
|
+
};
|
|
588
|
+
onEvent: (event: SubscriptionPurchasedEvent | SubscriptionSuccessEvent) => void | Promise<void>;
|
|
589
|
+
onError: (error: unknown) => void | Promise<void>;
|
|
590
|
+
}
|
|
591
|
+
declare function requestSubscriptionPurchase(params: IapRequestSubscriptionPurchaseOrderOptions): () => void;
|
|
509
592
|
/**
|
|
510
593
|
* @public
|
|
511
594
|
* @category 인앱결제
|
|
@@ -1417,6 +1500,7 @@ interface AsyncMethodsMap {
|
|
|
1417
1500
|
getServerTime: (params: CompatiblePlaceholderArgument) => Promise<{
|
|
1418
1501
|
serverTime: number;
|
|
1419
1502
|
}>;
|
|
1503
|
+
getConsentedUserData: (params: GetConsentedUserDataOptions) => Promise<ConsentedUserData>;
|
|
1420
1504
|
shareWithScheme: (params: {
|
|
1421
1505
|
schemeURL: string;
|
|
1422
1506
|
}) => Promise<void>;
|
|
@@ -3588,4 +3672,4 @@ declare const INTERNAL__module: {
|
|
|
3588
3672
|
tossCoreEventLog: typeof tossCoreEventLog;
|
|
3589
3673
|
};
|
|
3590
3674
|
|
|
3591
|
-
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, 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
|
|
@@ -470,7 +537,7 @@ interface OneTimePurchaseSuccessEvent {
|
|
|
470
537
|
type: 'success';
|
|
471
538
|
data: IapCreateOneTimePurchaseOrderResult;
|
|
472
539
|
}
|
|
473
|
-
interface
|
|
540
|
+
interface OneTimePurchasedEvent {
|
|
474
541
|
type: 'purchased';
|
|
475
542
|
data: {
|
|
476
543
|
orderId: string;
|
|
@@ -497,7 +564,7 @@ interface IapCreateOneTimePurchaseOrderOptions {
|
|
|
497
564
|
}
|
|
498
565
|
interface IapRequestOneTimePurchaseOptions {
|
|
499
566
|
options: Sku;
|
|
500
|
-
onEvent: (event:
|
|
567
|
+
onEvent: (event: OneTimePurchasedEvent | OneTimePurchaseSuccessEvent) => void | Promise<void>;
|
|
501
568
|
onError: (error: unknown) => void | Promise<void>;
|
|
502
569
|
}
|
|
503
570
|
declare function iapCreateOneTimePurchaseOrder(params: Sku): Promise<IapCreateOneTimePurchaseOrderResult>;
|
|
@@ -506,6 +573,22 @@ declare function processProductGrant(params: {
|
|
|
506
573
|
isProductGranted: boolean;
|
|
507
574
|
}): Promise<void>;
|
|
508
575
|
declare function requestOneTimePurchase(params: IapRequestOneTimePurchaseOptions): () => void;
|
|
576
|
+
interface SubscriptionPurchasedEvent {
|
|
577
|
+
type: 'purchased';
|
|
578
|
+
data: {
|
|
579
|
+
orderId: string;
|
|
580
|
+
subscriptionId?: string;
|
|
581
|
+
};
|
|
582
|
+
}
|
|
583
|
+
interface IapRequestSubscriptionPurchaseOrderOptions {
|
|
584
|
+
options: {
|
|
585
|
+
sku: string;
|
|
586
|
+
offerId?: string | null;
|
|
587
|
+
};
|
|
588
|
+
onEvent: (event: SubscriptionPurchasedEvent | SubscriptionSuccessEvent) => void | Promise<void>;
|
|
589
|
+
onError: (error: unknown) => void | Promise<void>;
|
|
590
|
+
}
|
|
591
|
+
declare function requestSubscriptionPurchase(params: IapRequestSubscriptionPurchaseOrderOptions): () => void;
|
|
509
592
|
/**
|
|
510
593
|
* @public
|
|
511
594
|
* @category 인앱결제
|
|
@@ -1417,6 +1500,7 @@ interface AsyncMethodsMap {
|
|
|
1417
1500
|
getServerTime: (params: CompatiblePlaceholderArgument) => Promise<{
|
|
1418
1501
|
serverTime: number;
|
|
1419
1502
|
}>;
|
|
1503
|
+
getConsentedUserData: (params: GetConsentedUserDataOptions) => Promise<ConsentedUserData>;
|
|
1420
1504
|
shareWithScheme: (params: {
|
|
1421
1505
|
schemeURL: string;
|
|
1422
1506
|
}) => Promise<void>;
|
|
@@ -3588,4 +3672,4 @@ declare const INTERNAL__module: {
|
|
|
3588
3672
|
tossCoreEventLog: typeof tossCoreEventLog;
|
|
3589
3673
|
};
|
|
3590
3674
|
|
|
3591
|
-
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, 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
|
@@ -631,6 +631,26 @@ function requestOneTimePurchase(params) {
|
|
|
631
631
|
);
|
|
632
632
|
return unregisterCallbacks;
|
|
633
633
|
}
|
|
634
|
+
function requestSubscriptionPurchase(params) {
|
|
635
|
+
const { options, onEvent, onError } = params;
|
|
636
|
+
const { sku, offerId } = options;
|
|
637
|
+
const unregisterCallbacks = INTERNAL__appBridgeHandler.invokeAppBridgeMethod(
|
|
638
|
+
"requestSubscriptionPurchase",
|
|
639
|
+
{ sku, offerId: offerId ?? null },
|
|
640
|
+
{
|
|
641
|
+
onPurchased: (params2) => {
|
|
642
|
+
onEvent({ type: "purchased", data: params2 });
|
|
643
|
+
},
|
|
644
|
+
onSuccess: (result) => {
|
|
645
|
+
onEvent({ type: "success", data: result });
|
|
646
|
+
},
|
|
647
|
+
onError: (error) => {
|
|
648
|
+
onError(error);
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
);
|
|
652
|
+
return unregisterCallbacks;
|
|
653
|
+
}
|
|
634
654
|
function createOneTimePurchaseOrder(params) {
|
|
635
655
|
const isIAPSupported = isMinVersionSupported({
|
|
636
656
|
android: "5.219.0",
|
|
@@ -1019,6 +1039,15 @@ async function getServerTime() {
|
|
|
1019
1039
|
}
|
|
1020
1040
|
getServerTime.isSupported = () => isMinVersionSupported(GET_SERVER_TIME_MIN_VERSION);
|
|
1021
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
|
+
|
|
1022
1051
|
// src/MiniAppModule/native-modules/requestReview.ts
|
|
1023
1052
|
var MIN_VERSION2 = { android: "5.253.0", ios: "5.253.0" };
|
|
1024
1053
|
async function requestReview() {
|
|
@@ -1191,6 +1220,7 @@ export {
|
|
|
1191
1220
|
generateHapticFeedback,
|
|
1192
1221
|
getAnonymousKey,
|
|
1193
1222
|
getClipboardText,
|
|
1223
|
+
getConsentedUserData,
|
|
1194
1224
|
getCurrentLocation,
|
|
1195
1225
|
getDeviceId,
|
|
1196
1226
|
getGameCenterGameProfile,
|
|
@@ -1218,6 +1248,7 @@ export {
|
|
|
1218
1248
|
requestNotificationAgreement,
|
|
1219
1249
|
requestOneTimePurchase,
|
|
1220
1250
|
requestReview,
|
|
1251
|
+
requestSubscriptionPurchase,
|
|
1221
1252
|
requestTossPayPaysBilling,
|
|
1222
1253
|
safePostMessage,
|
|
1223
1254
|
safeSyncPostMessage,
|
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.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": "2.
|
|
45
|
+
"@apps-in-toss/types": "2.7.0",
|
|
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
|
+
}
|
|
@@ -43,7 +43,7 @@ interface OneTimePurchaseSuccessEvent {
|
|
|
43
43
|
data: IapCreateOneTimePurchaseOrderResult;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
interface
|
|
46
|
+
interface OneTimePurchasedEvent {
|
|
47
47
|
type: 'purchased';
|
|
48
48
|
data: { orderId: string };
|
|
49
49
|
}
|
|
@@ -66,7 +66,7 @@ export interface IapCreateOneTimePurchaseOrderOptions {
|
|
|
66
66
|
|
|
67
67
|
interface IapRequestOneTimePurchaseOptions {
|
|
68
68
|
options: Sku;
|
|
69
|
-
onEvent: (event:
|
|
69
|
+
onEvent: (event: OneTimePurchasedEvent | OneTimePurchaseSuccessEvent) => void | Promise<void>;
|
|
70
70
|
onError: (error: unknown) => void | Promise<void>;
|
|
71
71
|
}
|
|
72
72
|
|
|
@@ -102,6 +102,43 @@ export function requestOneTimePurchase(params: IapRequestOneTimePurchaseOptions)
|
|
|
102
102
|
return unregisterCallbacks;
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
+
interface SubscriptionPurchasedEvent {
|
|
106
|
+
type: 'purchased';
|
|
107
|
+
data: { orderId: string; subscriptionId?: string };
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
interface IapRequestSubscriptionPurchaseOrderOptions {
|
|
111
|
+
options: {
|
|
112
|
+
sku: string;
|
|
113
|
+
offerId?: string | null;
|
|
114
|
+
};
|
|
115
|
+
onEvent: (event: SubscriptionPurchasedEvent | SubscriptionSuccessEvent) => void | Promise<void>;
|
|
116
|
+
onError: (error: unknown) => void | Promise<void>;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export function requestSubscriptionPurchase(params: IapRequestSubscriptionPurchaseOrderOptions) {
|
|
120
|
+
const { options, onEvent, onError } = params;
|
|
121
|
+
const { sku, offerId } = options;
|
|
122
|
+
|
|
123
|
+
const unregisterCallbacks = INTERNAL__appBridgeHandler.invokeAppBridgeMethod(
|
|
124
|
+
'requestSubscriptionPurchase',
|
|
125
|
+
{ sku, offerId: offerId ?? null },
|
|
126
|
+
{
|
|
127
|
+
onPurchased: (params: { orderId: string; subscriptionId?: string }) => {
|
|
128
|
+
onEvent({ type: 'purchased', data: params });
|
|
129
|
+
},
|
|
130
|
+
onSuccess: (result: IapCreateSubscriptionPurchaseOrderResult) => {
|
|
131
|
+
onEvent({ type: 'success', data: result });
|
|
132
|
+
},
|
|
133
|
+
onError: (error: any) => {
|
|
134
|
+
onError(error);
|
|
135
|
+
},
|
|
136
|
+
}
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
return unregisterCallbacks;
|
|
140
|
+
}
|
|
141
|
+
|
|
105
142
|
/**
|
|
106
143
|
* @public
|
|
107
144
|
* @category 인앱결제
|
|
@@ -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';
|