@mpgd/adapter-ait 0.13.3 → 0.14.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/host.d.ts +13 -1
- package/dist/host.js +1247 -216
- package/dist/iap-diagnostics.d.ts +59 -0
- package/dist/iap-diagnostics.js +58 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/origins.d.ts +10 -0
- package/dist/origins.js +31 -0
- package/package.json +8 -4
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stable diagnostic codes for Apps in Toss in-app purchases.
|
|
3
|
+
*
|
|
4
|
+
* The host bridge attaches one of these codes to a non-completed
|
|
5
|
+
* `PurchaseResult.diagnostic`, a partial `PurchaseRestoreResult.diagnostic`, or
|
|
6
|
+
* a rejected `commerce.getProducts`/`commerce.restore` bridge call. Native SDK
|
|
7
|
+
* error codes are passed through separately as `providerCode`. Codes never
|
|
8
|
+
* carry order ids, player ids, tokens or other personal data.
|
|
9
|
+
*
|
|
10
|
+
* This module is SDK-free so game UI code can compare codes without importing
|
|
11
|
+
* the Apps in Toss framework.
|
|
12
|
+
*/
|
|
13
|
+
export declare const aitIapDiagnosticCodes: {
|
|
14
|
+
/** IAP is not configured or the running Toss app lacks a required IAP method. */
|
|
15
|
+
readonly unavailable: 'AIT_IAP_UNAVAILABLE';
|
|
16
|
+
/** The requested logical product has no configured SKU mapping. */
|
|
17
|
+
readonly productNotConfigured: 'AIT_IAP_PRODUCT_NOT_CONFIGURED';
|
|
18
|
+
/** The native SDK returned no value, which it does on an unsupported Toss app version. */
|
|
19
|
+
readonly unsupportedAppVersion: 'AIT_IAP_UNSUPPORTED_APP_VERSION';
|
|
20
|
+
/** The native product catalog call failed or did not settle in time. */
|
|
21
|
+
readonly catalogUnavailable: 'AIT_IAP_CATALOG_UNAVAILABLE';
|
|
22
|
+
/** The native product catalog is empty. */
|
|
23
|
+
readonly catalogEmpty: 'AIT_IAP_CATALOG_EMPTY';
|
|
24
|
+
/** The native catalog has products, but none of the configured SKUs is usable. */
|
|
25
|
+
readonly configuredSkusNotVisible: 'AIT_IAP_CONFIGURED_SKUS_NOT_VISIBLE';
|
|
26
|
+
/** The configured SKU is not a one-time (consumable or non-consumable) product. */
|
|
27
|
+
readonly productTypeUnsupported: 'AIT_IAP_PRODUCT_TYPE_UNSUPPORTED';
|
|
28
|
+
/** The game-owned `prepareIap` hook rejected or did not settle in time. */
|
|
29
|
+
readonly preparationFailed: 'AIT_IAP_PREPARATION_FAILED';
|
|
30
|
+
/** Pending provider orders could not be read, so no new checkout was opened. */
|
|
31
|
+
readonly pendingOrderCheckFailed: 'AIT_IAP_PENDING_ORDER_CHECK_FAILED';
|
|
32
|
+
/** An earlier paid order for this product was just granted; no new checkout was opened. */
|
|
33
|
+
readonly pendingOrderRecovered: 'AIT_IAP_PENDING_ORDER_RECOVERED';
|
|
34
|
+
/** A paid order is still awaiting its server grant; no new checkout was opened. */
|
|
35
|
+
readonly pendingOrderUnresolved: 'AIT_IAP_PENDING_ORDER_UNRESOLVED';
|
|
36
|
+
/** The durable purchase-attempt marker could not be read or written. */
|
|
37
|
+
readonly attemptStorageUnavailable: 'AIT_IAP_ATTEMPT_STORAGE_UNAVAILABLE';
|
|
38
|
+
/** The same client purchase key already has an unfinished attempt. */
|
|
39
|
+
readonly attemptPending: 'AIT_IAP_ATTEMPT_PENDING';
|
|
40
|
+
/** Another purchase checkout or restore holds the IAP lock; nothing was charged. */
|
|
41
|
+
readonly checkoutInProgress: 'AIT_IAP_CHECKOUT_IN_PROGRESS';
|
|
42
|
+
/** The native checkout could not be opened. */
|
|
43
|
+
readonly checkoutStartFailed: 'AIT_IAP_CHECKOUT_START_FAILED';
|
|
44
|
+
/** The native checkout did not report a terminal result in time. */
|
|
45
|
+
readonly checkoutTimeout: 'AIT_IAP_CHECKOUT_TIMEOUT';
|
|
46
|
+
/** The native checkout reported an error before an order was observed. */
|
|
47
|
+
readonly nativePurchaseFailed: 'AIT_IAP_NATIVE_PURCHASE_FAILED';
|
|
48
|
+
/** A provider order exists but the game server has not confirmed its grant. */
|
|
49
|
+
readonly grantPending: 'AIT_IAP_GRANT_PENDING';
|
|
50
|
+
/** The server grant succeeded but the native acknowledgement failed or was not observed. */
|
|
51
|
+
readonly grantCompletionFailed: 'AIT_IAP_GRANT_COMPLETION_FAILED';
|
|
52
|
+
/** The game-owned entitlement reader failed or did not settle in time. */
|
|
53
|
+
readonly entitlementReadFailed: 'AIT_IAP_ENTITLEMENT_READ_FAILED';
|
|
54
|
+
/** Restore ran out of time before reconciling pending orders. */
|
|
55
|
+
readonly restoreTimeout: 'AIT_IAP_RESTORE_TIMEOUT';
|
|
56
|
+
};
|
|
57
|
+
export type AitIapDiagnosticCode = typeof aitIapDiagnosticCodes[keyof typeof aitIapDiagnosticCodes];
|
|
58
|
+
/** Native error code the SDK reports after a checkout whose grant callback returned false. */
|
|
59
|
+
export declare const aitIapProductNotGrantedByPartnerCode = "PRODUCT_NOT_GRANTED_BY_PARTNER";
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stable diagnostic codes for Apps in Toss in-app purchases.
|
|
3
|
+
*
|
|
4
|
+
* The host bridge attaches one of these codes to a non-completed
|
|
5
|
+
* `PurchaseResult.diagnostic`, a partial `PurchaseRestoreResult.diagnostic`, or
|
|
6
|
+
* a rejected `commerce.getProducts`/`commerce.restore` bridge call. Native SDK
|
|
7
|
+
* error codes are passed through separately as `providerCode`. Codes never
|
|
8
|
+
* carry order ids, player ids, tokens or other personal data.
|
|
9
|
+
*
|
|
10
|
+
* This module is SDK-free so game UI code can compare codes without importing
|
|
11
|
+
* the Apps in Toss framework.
|
|
12
|
+
*/
|
|
13
|
+
export const aitIapDiagnosticCodes = {
|
|
14
|
+
/** IAP is not configured or the running Toss app lacks a required IAP method. */
|
|
15
|
+
unavailable: 'AIT_IAP_UNAVAILABLE',
|
|
16
|
+
/** The requested logical product has no configured SKU mapping. */
|
|
17
|
+
productNotConfigured: 'AIT_IAP_PRODUCT_NOT_CONFIGURED',
|
|
18
|
+
/** The native SDK returned no value, which it does on an unsupported Toss app version. */
|
|
19
|
+
unsupportedAppVersion: 'AIT_IAP_UNSUPPORTED_APP_VERSION',
|
|
20
|
+
/** The native product catalog call failed or did not settle in time. */
|
|
21
|
+
catalogUnavailable: 'AIT_IAP_CATALOG_UNAVAILABLE',
|
|
22
|
+
/** The native product catalog is empty. */
|
|
23
|
+
catalogEmpty: 'AIT_IAP_CATALOG_EMPTY',
|
|
24
|
+
/** The native catalog has products, but none of the configured SKUs is usable. */
|
|
25
|
+
configuredSkusNotVisible: 'AIT_IAP_CONFIGURED_SKUS_NOT_VISIBLE',
|
|
26
|
+
/** The configured SKU is not a one-time (consumable or non-consumable) product. */
|
|
27
|
+
productTypeUnsupported: 'AIT_IAP_PRODUCT_TYPE_UNSUPPORTED',
|
|
28
|
+
/** The game-owned `prepareIap` hook rejected or did not settle in time. */
|
|
29
|
+
preparationFailed: 'AIT_IAP_PREPARATION_FAILED',
|
|
30
|
+
/** Pending provider orders could not be read, so no new checkout was opened. */
|
|
31
|
+
pendingOrderCheckFailed: 'AIT_IAP_PENDING_ORDER_CHECK_FAILED',
|
|
32
|
+
/** An earlier paid order for this product was just granted; no new checkout was opened. */
|
|
33
|
+
pendingOrderRecovered: 'AIT_IAP_PENDING_ORDER_RECOVERED',
|
|
34
|
+
/** A paid order is still awaiting its server grant; no new checkout was opened. */
|
|
35
|
+
pendingOrderUnresolved: 'AIT_IAP_PENDING_ORDER_UNRESOLVED',
|
|
36
|
+
/** The durable purchase-attempt marker could not be read or written. */
|
|
37
|
+
attemptStorageUnavailable: 'AIT_IAP_ATTEMPT_STORAGE_UNAVAILABLE',
|
|
38
|
+
/** The same client purchase key already has an unfinished attempt. */
|
|
39
|
+
attemptPending: 'AIT_IAP_ATTEMPT_PENDING',
|
|
40
|
+
/** Another purchase checkout or restore holds the IAP lock; nothing was charged. */
|
|
41
|
+
checkoutInProgress: 'AIT_IAP_CHECKOUT_IN_PROGRESS',
|
|
42
|
+
/** The native checkout could not be opened. */
|
|
43
|
+
checkoutStartFailed: 'AIT_IAP_CHECKOUT_START_FAILED',
|
|
44
|
+
/** The native checkout did not report a terminal result in time. */
|
|
45
|
+
checkoutTimeout: 'AIT_IAP_CHECKOUT_TIMEOUT',
|
|
46
|
+
/** The native checkout reported an error before an order was observed. */
|
|
47
|
+
nativePurchaseFailed: 'AIT_IAP_NATIVE_PURCHASE_FAILED',
|
|
48
|
+
/** A provider order exists but the game server has not confirmed its grant. */
|
|
49
|
+
grantPending: 'AIT_IAP_GRANT_PENDING',
|
|
50
|
+
/** The server grant succeeded but the native acknowledgement failed or was not observed. */
|
|
51
|
+
grantCompletionFailed: 'AIT_IAP_GRANT_COMPLETION_FAILED',
|
|
52
|
+
/** The game-owned entitlement reader failed or did not settle in time. */
|
|
53
|
+
entitlementReadFailed: 'AIT_IAP_ENTITLEMENT_READ_FAILED',
|
|
54
|
+
/** Restore ran out of time before reconciling pending orders. */
|
|
55
|
+
restoreTimeout: 'AIT_IAP_RESTORE_TIMEOUT',
|
|
56
|
+
};
|
|
57
|
+
/** Native error code the SDK reports after a checkout whose grant callback returned false. */
|
|
58
|
+
export const aitIapProductNotGrantedByPartnerCode = 'PRODUCT_NOT_GRANTED_BY_PARTNER';
|
package/dist/index.d.ts
CHANGED
|
@@ -23,5 +23,7 @@ export declare function createAitPlatformGateway(input: {
|
|
|
23
23
|
readonly bridge?: GamePlatformBridge;
|
|
24
24
|
readonly fallbackBridge?: GamePlatformBridge;
|
|
25
25
|
}): PlatformGateway;
|
|
26
|
+
export { aitIapDiagnosticCodes, aitIapProductNotGrantedByPartnerCode, type AitIapDiagnosticCode, } from './iap-diagnostics.js';
|
|
27
|
+
export { aitBrowserOrigins, isAitBrowserOrigin } from './origins.js';
|
|
26
28
|
export { aitLifecyclePauseEvent, aitLifecycleResumeEvent, createAitLifecycleAdapter, dispatchAitLifecycleEvent, } from './lifecycle.js';
|
|
27
29
|
export declare function createAitSandboxBridge(options?: CreateAitSandboxBridgeOptions): GamePlatformBridge;
|
package/dist/index.js
CHANGED
|
@@ -121,6 +121,8 @@ export function createAitPlatformGateway(input) {
|
|
|
121
121
|
},
|
|
122
122
|
};
|
|
123
123
|
}
|
|
124
|
+
export { aitIapDiagnosticCodes, aitIapProductNotGrantedByPartnerCode, } from './iap-diagnostics.js';
|
|
125
|
+
export { aitBrowserOrigins, isAitBrowserOrigin } from './origins.js';
|
|
124
126
|
export { aitLifecyclePauseEvent, aitLifecycleResumeEvent, createAitLifecycleAdapter, dispatchAitLifecycleEvent, } from './lifecycle.js';
|
|
125
127
|
function getBridge() {
|
|
126
128
|
return globalThis.__GAME_PLATFORM_BRIDGE__;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser origins an Apps in Toss mini-app can send requests from.
|
|
3
|
+
*
|
|
4
|
+
* Game backends use this list for an exact CORS allowlist. The `web` pair is
|
|
5
|
+
* used by released and QR-test WebView bundles, and SDK 3.x bundles can also
|
|
6
|
+
* send the `apps` pair. This module is SDK-free and safe to import on a server.
|
|
7
|
+
*/
|
|
8
|
+
export declare function aitBrowserOrigins(appName: string): readonly string[];
|
|
9
|
+
/** Exact-match check of a request `Origin` header against `aitBrowserOrigins(appName)`. */
|
|
10
|
+
export declare function isAitBrowserOrigin(appName: string, origin: string | null | undefined): boolean;
|
package/dist/origins.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser origins an Apps in Toss mini-app can send requests from.
|
|
3
|
+
*
|
|
4
|
+
* Game backends use this list for an exact CORS allowlist. The `web` pair is
|
|
5
|
+
* used by released and QR-test WebView bundles, and SDK 3.x bundles can also
|
|
6
|
+
* send the `apps` pair. This module is SDK-free and safe to import on a server.
|
|
7
|
+
*/
|
|
8
|
+
export function aitBrowserOrigins(appName) {
|
|
9
|
+
const host = normalizeAitOriginAppName(appName);
|
|
10
|
+
return Object.freeze([
|
|
11
|
+
`https://${host}.web.tossmini.com`,
|
|
12
|
+
`https://${host}.private-web.tossmini.com`,
|
|
13
|
+
`https://${host}.apps.tossmini.com`,
|
|
14
|
+
`https://${host}.private-apps.tossmini.com`,
|
|
15
|
+
]);
|
|
16
|
+
}
|
|
17
|
+
/** Exact-match check of a request `Origin` header against `aitBrowserOrigins(appName)`. */
|
|
18
|
+
export function isAitBrowserOrigin(appName, origin) {
|
|
19
|
+
return typeof origin === 'string' && aitBrowserOrigins(appName).includes(origin);
|
|
20
|
+
}
|
|
21
|
+
function normalizeAitOriginAppName(appName) {
|
|
22
|
+
if (typeof appName !== 'string') {
|
|
23
|
+
throw new TypeError('AIT appName must be a string.');
|
|
24
|
+
}
|
|
25
|
+
// Browsers send lower-case hosts in the Origin header.
|
|
26
|
+
const normalized = appName.trim().toLowerCase();
|
|
27
|
+
if (!/^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/u.test(normalized)) {
|
|
28
|
+
throw new TypeError('AIT appName must be a DNS label: 1 to 63 letters, numbers or inner hyphens.');
|
|
29
|
+
}
|
|
30
|
+
return normalized;
|
|
31
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpgd/adapter-ait",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "Apps in Toss WebView platform adapter for mpgd games.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -53,14 +53,18 @@
|
|
|
53
53
|
"types": "./dist/authority-fetch.d.ts",
|
|
54
54
|
"default": "./dist/authority-fetch.js"
|
|
55
55
|
},
|
|
56
|
+
"./origins": {
|
|
57
|
+
"types": "./dist/origins.d.ts",
|
|
58
|
+
"default": "./dist/origins.js"
|
|
59
|
+
},
|
|
56
60
|
"./package.json": "./package.json"
|
|
57
61
|
},
|
|
58
62
|
"files": [
|
|
59
63
|
"dist"
|
|
60
64
|
],
|
|
61
65
|
"dependencies": {
|
|
62
|
-
"@mpgd/
|
|
63
|
-
"@mpgd/
|
|
66
|
+
"@mpgd/bridge": "0.11.0",
|
|
67
|
+
"@mpgd/platform": "0.18.0"
|
|
64
68
|
},
|
|
65
69
|
"peerDependencies": {
|
|
66
70
|
"@apps-in-toss/web-framework": ">=3.0.0 <4"
|
|
@@ -76,7 +80,7 @@
|
|
|
76
80
|
"ttsc": "0.30.4",
|
|
77
81
|
"typescript": "7.0.2",
|
|
78
82
|
"vitest": "^4.0.0",
|
|
79
|
-
"@mpgd/game-runtime": "0.6.
|
|
83
|
+
"@mpgd/game-runtime": "0.6.1"
|
|
80
84
|
},
|
|
81
85
|
"main": "./dist/index.js",
|
|
82
86
|
"types": "./dist/index.d.ts",
|