@mpgd/adapter-ait 0.8.0 → 0.10.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.
@@ -1,5 +1,6 @@
1
+ export type AitAdPlacementType = 'rewarded' | 'interstitial' | 'banner';
1
2
  export interface AitAdBridgeConfig {
2
3
  readonly adGroupIds: Readonly<Record<string, string>>;
3
- readonly adPlacementTypes: Readonly<Record<string, 'rewarded' | 'interstitial'>>;
4
+ readonly adPlacementTypes: Readonly<Record<string, AitAdPlacementType>>;
4
5
  }
5
6
  export declare function extractAitAdBridgeConfig(input: unknown, sourceLabel?: string): AitAdBridgeConfig;
package/dist/ad-config.js CHANGED
@@ -9,7 +9,7 @@ export function extractAitAdBridgeConfig(input, sourceLabel = 'ad placements') {
9
9
  for (const [placementIndex, placement] of placements.entries()) {
10
10
  if (!isRecord(placement)
11
11
  || typeof placement.id !== 'string'
12
- || (placement.type !== 'rewarded' && placement.type !== 'interstitial')) {
12
+ || !isAitAdPlacementType(placement.type)) {
13
13
  throw new Error(`AIT ad placement entry at index ${placementIndex} is invalid: ${sourceLabel}`);
14
14
  }
15
15
  if (placementIds.has(placement.id)) {
@@ -28,6 +28,9 @@ export function extractAitAdBridgeConfig(input, sourceLabel = 'ad placements') {
28
28
  }
29
29
  return { adGroupIds, adPlacementTypes };
30
30
  }
31
+ function isAitAdPlacementType(value) {
32
+ return value === 'rewarded' || value === 'interstitial' || value === 'banner';
33
+ }
31
34
  function isRecord(value) {
32
35
  return typeof value === 'object' && value !== null && !Array.isArray(value);
33
36
  }
package/dist/host.d.ts CHANGED
@@ -1,20 +1,81 @@
1
- import { getTossShareLink, grantPromotionRewardForGame as grantPromotionReward, isMinVersionSupported, loadFullScreenAd, openGameCenterLeaderboard, requestNotificationAgreement, share, showFullScreenAd, Storage, submitGameCenterLeaderBoardScore } from '@apps-in-toss/web-framework';
2
- import type { NotificationTopic, ShareResult } from '@mpgd/platform';
1
+ import { getTossShareLink, grantPromotionRewardForGame as grantPromotionReward, IAP, isMinVersionSupported, loadFullScreenAd, openGameCenterLeaderboard, requestNotificationAgreement, share, showFullScreenAd, Storage, submitGameCenterLeaderBoardScore, TossAds } from '@apps-in-toss/web-framework';
2
+ import type { Entitlement, LogicalProductId, NotificationTopic, ShareResult } from '@mpgd/platform';
3
+ import type { AitAdPlacementType } from './ad-config.js';
3
4
  import type { GamePlatformBridge } from './index.js';
4
5
  export type AitIdentityProvider = () => Promise<unknown>;
6
+ /**
7
+ * The AIT SDK adds support-version metadata to native functions over time.
8
+ * The host only depends on the callable surface and an optional support probe
9
+ * so adapter tests remain compatible with older wrappers and newer SDKs.
10
+ */
11
+ type AitOptionalCapabilityMethod<T extends (...args: never[]) => unknown> = (...args: Parameters<T>) => ReturnType<T>;
12
+ interface AitCapabilityProbe {
13
+ readonly isSupported?: () => boolean;
14
+ }
15
+ type AitNativeMethod<T extends (...args: never[]) => unknown> = AitOptionalCapabilityMethod<T> & AitCapabilityProbe;
16
+ interface AitIapDependencies {
17
+ readonly createOneTimePurchaseOrder: AitNativeMethod<typeof IAP.createOneTimePurchaseOrder>;
18
+ readonly getProductItemList: AitNativeMethod<typeof IAP.getProductItemList>;
19
+ readonly getPendingOrders: AitNativeMethod<typeof IAP.getPendingOrders>;
20
+ readonly completeProductGrant: AitNativeMethod<typeof IAP.completeProductGrant>;
21
+ }
22
+ interface AitBannerDependencies {
23
+ readonly initialize: typeof TossAds.initialize;
24
+ readonly attachBanner: typeof TossAds.attachBanner;
25
+ }
5
26
  export interface AitHostDependencies {
6
27
  readonly identityProvider: AitIdentityProvider;
7
28
  readonly storage: Pick<typeof Storage, 'getItem' | 'removeItem' | 'setItem'>;
8
29
  readonly getTossShareLink: typeof getTossShareLink;
9
30
  readonly share: typeof share;
10
- readonly grantPromotionReward: typeof grantPromotionReward;
11
- readonly requestNotificationAgreement: typeof requestNotificationAgreement;
31
+ readonly grantPromotionReward: AitNativeMethod<typeof grantPromotionReward>;
32
+ readonly requestNotificationAgreement: AitNativeMethod<typeof requestNotificationAgreement>;
12
33
  readonly isMinVersionSupported: typeof isMinVersionSupported;
13
- readonly loadFullScreenAd: typeof loadFullScreenAd;
14
- readonly showFullScreenAd: typeof showFullScreenAd;
15
- readonly openGameCenterLeaderboard: typeof openGameCenterLeaderboard;
16
- readonly submitGameCenterLeaderBoardScore: typeof submitGameCenterLeaderBoardScore;
34
+ readonly loadFullScreenAd: AitNativeMethod<typeof loadFullScreenAd>;
35
+ readonly showFullScreenAd: AitNativeMethod<typeof showFullScreenAd>;
36
+ readonly tossAds: AitBannerDependencies;
37
+ readonly openGameCenterLeaderboard: AitNativeMethod<typeof openGameCenterLeaderboard>;
38
+ readonly submitGameCenterLeaderBoardScore: AitNativeMethod<typeof submitGameCenterLeaderBoardScore>;
39
+ readonly iap: AitIapDependencies;
40
+ }
41
+ /** Game-owned logical product mapped to a console-issued Apps in Toss SKU. */
42
+ export interface AitIapProductConfig {
43
+ readonly productId: LogicalProductId;
44
+ readonly sku: string;
45
+ /** Apps in Toss currently displays KRW prices; override only for a supported future catalog. */
46
+ readonly currencyCode?: string;
47
+ }
48
+ export interface AitIapPreparationInput {
49
+ readonly intent: 'purchase' | 'restore';
50
+ readonly productId?: LogicalProductId;
51
+ readonly platformSku?: string;
52
+ }
53
+ /**
54
+ * Game-owned server gate that ensures the anonymous game key is linked to a
55
+ * Toss login user before a purchase or pending-order recovery can proceed.
56
+ */
57
+ export type AitIapPreparer = (input: AitIapPreparationInput) => Promise<boolean>;
58
+ export interface AitIapProductGrantVerificationInput {
59
+ readonly orderId: string;
60
+ readonly productId: LogicalProductId;
61
+ readonly platformSku: string;
62
+ readonly idempotencyKey: string;
63
+ readonly source: 'process-product-grant' | 'pending-order-restore';
64
+ /** Client callback time only; the game authority must use the order status time. */
65
+ readonly purchasedAt: string;
66
+ readonly signal: AbortSignal;
67
+ readonly timeoutMs: number;
17
68
  }
69
+ /**
70
+ * A server-backed verifier. Returning false keeps the provider-side grant
71
+ * pending; the bridge never manufactures a client-side entitlement.
72
+ */
73
+ export type AitIapProductGrantVerifier = (input: AitIapProductGrantVerificationInput) => Promise<boolean>;
74
+ /**
75
+ * Reads durable purchase entitlements from the game authority. Native product
76
+ * callbacks are intentionally not treated as a source of ownership state.
77
+ */
78
+ export type AitIapEntitlementReader = () => Promise<readonly Entitlement[]>;
18
79
  export interface AitPromotionRewardConfig {
19
80
  readonly promotionCode: string;
20
81
  readonly amount: number;
@@ -53,14 +114,27 @@ export type AitPromotionGrantAuthorization = {
53
114
  * single-use game claim.
54
115
  */
55
116
  export type AitPromotionGrantAuthorizer = (input: AitPromotionGrantAuthorizationInput) => Promise<AitPromotionGrantAuthorization>;
117
+ export interface AitBannerAppearance {
118
+ readonly theme?: 'auto' | 'light' | 'dark';
119
+ readonly tone?: 'blackAndWhite' | 'grey';
120
+ readonly variant?: 'card' | 'expanded';
121
+ }
56
122
  export interface InstallAitHostBridgeOptions {
57
123
  readonly appName?: string;
58
124
  readonly adGroupIds?: Readonly<Record<string, string>>;
59
- readonly adPlacementTypes?: Readonly<Record<string, 'rewarded' | 'interstitial'>>;
125
+ readonly adPlacementTypes?: Readonly<Record<string, AitAdPlacementType>>;
60
126
  /** Logical campaign ids mapped to console-issued Apps in Toss promotion configuration. */
61
127
  readonly promotionRewards?: Readonly<Record<string, AitPromotionRewardConfig>>;
62
128
  readonly authorizePromotionGrant?: AitPromotionGrantAuthorizer;
63
129
  readonly resolvePendingPromotionGrant?: AitPendingPromotionGrantResolver;
130
+ /** Enable IAP only with logical-to-native SKU mappings and both server hooks. */
131
+ readonly iapProducts?: readonly AitIapProductConfig[];
132
+ readonly prepareIap?: AitIapPreparer;
133
+ readonly verifyIapProductGrant?: AitIapProductGrantVerifier;
134
+ /** Required to expose native IAP so ownership survives a wrapper restart. */
135
+ readonly readIapEntitlements?: AitIapEntitlementReader;
136
+ /** May be shortened, but never extended beyond the native callback-safe default. */
137
+ readonly iapProductGrantTimeoutMs?: number;
64
138
  /** Logical notification topics mapped to approved Apps in Toss template codes. */
65
139
  readonly notificationTemplateCodes?: Partial<Readonly<Record<NotificationTopic, string>>>;
66
140
  /** Maximum total wait for the native show request before display is observed. */
@@ -71,6 +145,10 @@ export interface InstallAitHostBridgeOptions {
71
145
  readonly adDisplayStartTimeoutMs?: number;
72
146
  /** Last-resort cleanup when the native SDK omits its terminal display callback. */
73
147
  readonly adMaximumDisplayMs?: number;
148
+ /** Maximum wait for an inline banner to render or report no-fill/failure. */
149
+ readonly bannerRenderTimeoutMs?: number;
150
+ /** Provider-neutral host preference mapped to the Apps in Toss banner appearance. */
151
+ readonly bannerAppearance?: AitBannerAppearance;
74
152
  readonly dependencies?: Partial<AitHostDependencies>;
75
153
  }
76
154
  export declare function installAitHostBridge(options?: InstallAitHostBridgeOptions): GamePlatformBridge;