@ait-kit/sdk 0.2.0 → 0.4.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/README.md +178 -9
- package/dist/index.d.ts +9 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/platform-loader.d.ts +16 -0
- package/dist/platform-loader.d.ts.map +1 -0
- package/dist/platform-loader.js +35 -0
- package/dist/promotion/adapter.d.ts +3 -0
- package/dist/promotion/adapter.d.ts.map +1 -0
- package/dist/promotion/adapter.js +128 -0
- package/dist/promotion/platform-contract.d.ts +37 -0
- package/dist/promotion/platform-contract.d.ts.map +1 -0
- package/dist/promotion/platform-contract.js +1 -0
- package/dist/review/adapter.d.ts +3 -0
- package/dist/review/adapter.d.ts.map +1 -0
- package/dist/review/adapter.js +33 -0
- package/dist/review/platform-contract.d.ts +21 -0
- package/dist/review/platform-contract.d.ts.map +1 -0
- package/dist/review/platform-contract.js +1 -0
- package/dist/rn/ads.d.ts.map +1 -1
- package/dist/rn/ads.js +120 -119
- package/dist/rn/framework-loader.d.ts.map +1 -1
- package/dist/rn/framework-loader.js +6 -17
- package/dist/rn/iap.d.ts.map +1 -1
- package/dist/rn/iap.js +9 -28
- package/dist/rn/identity.d.ts.map +1 -1
- package/dist/rn/identity.js +11 -22
- package/dist/rn/index.d.ts +2 -0
- package/dist/rn/index.d.ts.map +1 -1
- package/dist/rn/index.js +2 -0
- package/dist/rn/notify-share.d.ts +3 -3
- package/dist/rn/notify-share.d.ts.map +1 -1
- package/dist/rn/notify-share.js +16 -33
- package/dist/rn/official-module.d.ts +83 -0
- package/dist/rn/official-module.d.ts.map +1 -0
- package/dist/rn/official-module.js +106 -0
- package/dist/rn/platform-loader.d.ts +4 -0
- package/dist/rn/platform-loader.d.ts.map +1 -0
- package/dist/rn/platform-loader.js +5 -0
- package/dist/rn/promotion.d.ts +9 -0
- package/dist/rn/promotion.d.ts.map +1 -0
- package/dist/rn/promotion.js +11 -0
- package/dist/rn/review.d.ts +7 -0
- package/dist/rn/review.d.ts.map +1 -0
- package/dist/rn/review.js +10 -0
- package/dist/rn/storage.d.ts.map +1 -1
- package/dist/rn/storage.js +4 -22
- package/dist/share/platform-contract.d.ts +4 -4
- package/dist/share/platform-contract.js +5 -5
- package/dist/web/framework-loader.d.ts.map +1 -1
- package/dist/web/framework-loader.js +7 -23
- package/dist/web/identity.d.ts.map +1 -1
- package/dist/web/identity.js +12 -33
- package/dist/web/index.d.ts +2 -0
- package/dist/web/index.d.ts.map +1 -1
- package/dist/web/index.js +4 -5
- package/dist/web/notify-share.d.ts +3 -2
- package/dist/web/notify-share.d.ts.map +1 -1
- package/dist/web/notify-share.js +11 -33
- package/dist/web/platform-loader.d.ts +4 -0
- package/dist/web/platform-loader.d.ts.map +1 -0
- package/dist/web/platform-loader.js +5 -0
- package/dist/web/promotion.d.ts +9 -0
- package/dist/web/promotion.d.ts.map +1 -0
- package/dist/web/promotion.js +10 -0
- package/dist/web/review.d.ts +7 -0
- package/dist/web/review.d.ts.map +1 -0
- package/dist/web/review.js +9 -0
- package/package.json +3 -3
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { SdkError } from "../index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Wraps an official function for the internal contract while preserving the
|
|
4
|
+
* original receiver (the official module object, in case the implementation
|
|
5
|
+
* relies on `this`) and an optional `isSupported` flag, so version-gate
|
|
6
|
+
* checks keep working whenever the official SDK exposes them.
|
|
7
|
+
*/
|
|
8
|
+
function preserveSupport(original, wrapper) {
|
|
9
|
+
if (typeof original.isSupported === "function") {
|
|
10
|
+
return Object.assign(wrapper, { isSupported: () => original.isSupported() });
|
|
11
|
+
}
|
|
12
|
+
return wrapper;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Converts the official identity exports (`appLogin`, `getAnonymousKey`) to
|
|
16
|
+
* the shared identity contract. Missing functions stay missing so the
|
|
17
|
+
* shared engine reports UNSUPPORTED per operation.
|
|
18
|
+
*/
|
|
19
|
+
export function adaptOfficialRnIdentity(module) {
|
|
20
|
+
const identity = {};
|
|
21
|
+
if (typeof module.appLogin === "function") {
|
|
22
|
+
const appLogin = module.appLogin;
|
|
23
|
+
identity.TossAuth = {
|
|
24
|
+
login: preserveSupport(appLogin, () => appLogin.call(module))
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
if (typeof module.getAnonymousKey === "function") {
|
|
28
|
+
const getAnonymousKey = module.getAnonymousKey;
|
|
29
|
+
identity.User = {
|
|
30
|
+
getAnonymousKey: preserveSupport(getAnonymousKey, async () => {
|
|
31
|
+
const result = await getAnonymousKey.call(module);
|
|
32
|
+
// The official SDK resolves undefined when the installed app is
|
|
33
|
+
// below the feature's minimum version: that is an unsupported
|
|
34
|
+
// environment, not a malformed result.
|
|
35
|
+
if (result === undefined) {
|
|
36
|
+
throw new SdkError("UNSUPPORTED", "the installed app version does not support getAnonymousKey");
|
|
37
|
+
}
|
|
38
|
+
// The "ERROR" sentinel and malformed shapes are rejected by the
|
|
39
|
+
// shared validator (runSdkGetAnonymousKey) like on any platform.
|
|
40
|
+
return result;
|
|
41
|
+
})
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
return identity;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Converts the official `requestNotificationAgreement` to the shared
|
|
48
|
+
* notification contract. The official params shape matches the internal
|
|
49
|
+
* one exactly, and the returned cleanup function passes through so the
|
|
50
|
+
* event flow owns and invokes it.
|
|
51
|
+
*/
|
|
52
|
+
export function adaptOfficialRnNotification(module) {
|
|
53
|
+
const notification = {};
|
|
54
|
+
if (typeof module.requestNotificationAgreement === "function") {
|
|
55
|
+
const requestNotificationAgreement = module.requestNotificationAgreement;
|
|
56
|
+
notification.Notification = {
|
|
57
|
+
requestAgreement: preserveSupport(requestNotificationAgreement, (params) => requestNotificationAgreement.call(module, params))
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
return notification;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Converts the official share exports to the shared share contract:
|
|
64
|
+
* `getTossShareLink(path, ogImageUrl?)` takes positional arguments (the
|
|
65
|
+
* internal contract's object form is unpacked here) and `share` receives
|
|
66
|
+
* the `{ message }` object as-is.
|
|
67
|
+
*/
|
|
68
|
+
export function adaptOfficialRnShare(module) {
|
|
69
|
+
const share = {};
|
|
70
|
+
if (typeof module.getTossShareLink === "function") {
|
|
71
|
+
const getTossShareLink = module.getTossShareLink;
|
|
72
|
+
share.Share = {
|
|
73
|
+
createLink: preserveSupport(getTossShareLink, ({ path, ogImageUrl }) => ogImageUrl !== undefined
|
|
74
|
+
? getTossShareLink.call(module, path, ogImageUrl)
|
|
75
|
+
: getTossShareLink.call(module, path))
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
if (typeof module.share === "function") {
|
|
79
|
+
const officialShare = module.share;
|
|
80
|
+
share.Share = {
|
|
81
|
+
...share.Share,
|
|
82
|
+
sendMessage: preserveSupport(officialShare, (message) => officialShare.call(module, message))
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
return share;
|
|
86
|
+
}
|
|
87
|
+
/** Translate the official flat review function, preserving both receivers. */
|
|
88
|
+
export function adaptOfficialRnReview(module) {
|
|
89
|
+
const request = module.requestReview;
|
|
90
|
+
return typeof request === "function"
|
|
91
|
+
? { Review: { request: preserveSupport(request, () => request.call(module)) } }
|
|
92
|
+
: {};
|
|
93
|
+
}
|
|
94
|
+
/** Flat RN API uses a params wrapper and undefined for unsupported app versions. */
|
|
95
|
+
export function adaptOfficialRnPromotion(module) {
|
|
96
|
+
const grant = module.grantPromotionReward;
|
|
97
|
+
if (typeof grant !== "function")
|
|
98
|
+
return {};
|
|
99
|
+
return { Promotion: { grantReward: preserveSupport(grant, async (input) => {
|
|
100
|
+
const result = await grant.call(module, { params: input });
|
|
101
|
+
if (result === undefined) {
|
|
102
|
+
throw new SdkError("UNSUPPORTED", "the installed app version does not support direct promotion rewards");
|
|
103
|
+
}
|
|
104
|
+
return result;
|
|
105
|
+
}) } };
|
|
106
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type PlatformLoader, type PlatformLoadResult } from "../platform-loader.js";
|
|
2
|
+
/** Lazy platform-local import followed by capability-specific selection. */
|
|
3
|
+
export declare function createRnPlatformLoader<T>(select: (module: typeof import("@apps-in-toss/framework")) => PlatformLoadResult<T>, includeErrorDetails?: boolean): PlatformLoader<T>;
|
|
4
|
+
//# sourceMappingURL=platform-loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform-loader.d.ts","sourceRoot":"","sources":["../../src/rn/platform-loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoD,KAAK,cAAc,EAAE,KAAK,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AACvI,4EAA4E;AAC5E,wBAAgB,sBAAsB,CAAC,CAAC,EACtC,MAAM,EAAE,CAAC,MAAM,EAAE,cAAc,yBAAyB,CAAC,KAAK,kBAAkB,CAAC,CAAC,CAAC,EACnF,mBAAmB,UAAO,GACzB,cAAc,CAAC,CAAC,CAAC,CAKnB"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { createCachedPlatformLoader, frameworkImportError } from "../platform-loader.js";
|
|
2
|
+
/** Lazy platform-local import followed by capability-specific selection. */
|
|
3
|
+
export function createRnPlatformLoader(select, includeErrorDetails = true) {
|
|
4
|
+
return createCachedPlatformLoader(async () => select(await import("@apps-in-toss/framework")), error => frameworkImportError("@apps-in-toss/framework", error, includeErrorDetails));
|
|
5
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { PromotionAdapter, PromotionPlatformLoader, PromotionPlatformSdk } from "../promotion/platform-contract.js";
|
|
2
|
+
export interface ReactNativePromotionOptions {
|
|
3
|
+
/** Shared Promotion contract or async loader; defaults to the official SDK. */
|
|
4
|
+
framework?: PromotionPlatformSdk | PromotionPlatformLoader;
|
|
5
|
+
/** Overall wait deadline; 0 (default) disables it. Timeout does not cancel payment. */
|
|
6
|
+
timeoutMs?: number;
|
|
7
|
+
}
|
|
8
|
+
export declare function createReactNativePromotion(options?: ReactNativePromotionOptions): PromotionAdapter;
|
|
9
|
+
//# sourceMappingURL=promotion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"promotion.d.ts","sourceRoot":"","sources":["../../src/rn/promotion.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAGzH,MAAM,WAAW,2BAA2B;IAC1C,+EAA+E;IAC/E,SAAS,CAAC,EAAE,oBAAoB,GAAG,uBAAuB,CAAC;IAC3D,uFAAuF;IACvF,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,0BAA0B,CAAC,OAAO,GAAE,2BAAgC,GAAG,gBAAgB,CAEtG"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { resolvePlatformLoader } from "../platform-loader.js";
|
|
2
|
+
import { createRnPlatformLoader } from "./platform-loader.js";
|
|
3
|
+
import { createPromotionAdapter } from "../promotion/adapter.js";
|
|
4
|
+
import { adaptOfficialRnPromotion } from "./official-module.js";
|
|
5
|
+
export function createReactNativePromotion(options = {}) {
|
|
6
|
+
return createPromotionAdapter(resolvePlatformLoader(options.framework, createDefaultPromotionLoader), options.timeoutMs);
|
|
7
|
+
}
|
|
8
|
+
/** Keep import diagnostics redacted for direct-promotion operations. */
|
|
9
|
+
function createDefaultPromotionLoader() {
|
|
10
|
+
return createRnPlatformLoader(module => ({ available: true, module: adaptOfficialRnPromotion(module) }), false);
|
|
11
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ReviewAdapter, ReviewPlatformLoader, ReviewPlatformSdk } from "../review/platform-contract.js";
|
|
2
|
+
export interface ReactNativeReviewOptions {
|
|
3
|
+
/** Shared contract injection, or a loader; defaults to the lazy official SDK. */
|
|
4
|
+
framework?: ReviewPlatformSdk | ReviewPlatformLoader;
|
|
5
|
+
}
|
|
6
|
+
export declare function createReactNativeReview(options?: ReactNativeReviewOptions): ReviewAdapter;
|
|
7
|
+
//# sourceMappingURL=review.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"review.d.ts","sourceRoot":"","sources":["../../src/rn/review.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAG7G,MAAM,WAAW,wBAAwB;IACvC,iFAAiF;IACjF,SAAS,CAAC,EAAE,iBAAiB,GAAG,oBAAoB,CAAC;CACtD;AAED,wBAAgB,uBAAuB,CAAC,OAAO,GAAE,wBAA6B,GAAG,aAAa,CAE7F"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { resolvePlatformLoader } from "../platform-loader.js";
|
|
2
|
+
import { createRnPlatformLoader } from "./platform-loader.js";
|
|
3
|
+
import { createReviewAdapter } from "../review/adapter.js";
|
|
4
|
+
import { adaptOfficialRnReview } from "./official-module.js";
|
|
5
|
+
export function createReactNativeReview(options = {}) {
|
|
6
|
+
return createReviewAdapter(resolvePlatformLoader(options.framework, createDefaultReviewLoader));
|
|
7
|
+
}
|
|
8
|
+
function createDefaultReviewLoader() {
|
|
9
|
+
return createRnPlatformLoader(module => ({ available: true, module: adaptOfficialRnReview(module) }), false);
|
|
10
|
+
}
|
package/dist/rn/storage.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/rn/storage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/rn/storage.ts"],"names":[],"mappings":"AAEA,OAAO,EAAY,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAEL,KAAK,qBAAqB,EAC1B,KAAK,kBAAkB,EACxB,MAAM,iCAAiC,CAAC;AAEzC,MAAM,WAAW,yBAAyB;IACxC;;;;OAIG;IACH,SAAS,CAAC,EAAE,kBAAkB,GAAG,qBAAqB,CAAC;CACxD;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,GAAE,yBAA8B,GACtC,UAAU,CA8BZ;AAED,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,yBAAyB,CAAC,WAAW,CAAC,GAChD,qBAAqB,CAEvB"}
|
package/dist/rn/storage.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { resolvePlatformLoader } from "../platform-loader.js";
|
|
2
|
+
import { createRnPlatformLoader } from "./platform-loader.js";
|
|
1
3
|
import { SdkError } from "../index.js";
|
|
2
4
|
import { createSdkStorageFromPlatform } from "../storage/platform-contract.js";
|
|
3
5
|
/**
|
|
@@ -37,28 +39,8 @@ export function createReactNativeStorage(options = {}) {
|
|
|
37
39
|
};
|
|
38
40
|
}
|
|
39
41
|
export function normalizeStorageLoader(framework) {
|
|
40
|
-
|
|
41
|
-
return createDefaultRnStorageLoader();
|
|
42
|
-
}
|
|
43
|
-
if (typeof framework === "function") {
|
|
44
|
-
return framework;
|
|
45
|
-
}
|
|
46
|
-
return async () => ({ available: true, module: framework });
|
|
42
|
+
return resolvePlatformLoader(framework, createDefaultRnStorageLoader);
|
|
47
43
|
}
|
|
48
44
|
function createDefaultRnStorageLoader() {
|
|
49
|
-
|
|
50
|
-
return async () => {
|
|
51
|
-
if (cached) {
|
|
52
|
-
return { available: true, module: cached };
|
|
53
|
-
}
|
|
54
|
-
try {
|
|
55
|
-
const framework = (await import("@apps-in-toss/framework"));
|
|
56
|
-
cached = framework;
|
|
57
|
-
return { available: true, module: cached };
|
|
58
|
-
}
|
|
59
|
-
catch (error) {
|
|
60
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
61
|
-
return { available: false, reason: `failed to import @apps-in-toss/framework: ${message}` };
|
|
62
|
-
}
|
|
63
|
-
};
|
|
45
|
+
return createRnPlatformLoader(module => ({ available: true, module: module }));
|
|
64
46
|
}
|
|
@@ -31,10 +31,10 @@ export type SharePlatformLoader = () => Promise<{
|
|
|
31
31
|
*/
|
|
32
32
|
export declare function validateSharePath(path: string): string;
|
|
33
33
|
/**
|
|
34
|
-
* Wraps the share-UI call: a resolution means the
|
|
35
|
-
*
|
|
36
|
-
* never grants reward eligibility. Rejections
|
|
37
|
-
* platform's error code/message preserved.
|
|
34
|
+
* Wraps the share-UI call: a resolution means ONLY that the SDK share call
|
|
35
|
+
* completed ("completed") — it never proves the share sheet opened or that
|
|
36
|
+
* the user actually shared, and never grants reward eligibility. Rejections
|
|
37
|
+
* surface as failed with the platform's error code/message preserved.
|
|
38
38
|
*/
|
|
39
39
|
export declare function runShareUi(platform: SharePlatformSdk, message: string): Promise<SdkShareUiResult>;
|
|
40
40
|
export {};
|
|
@@ -13,15 +13,15 @@ export function validateSharePath(path) {
|
|
|
13
13
|
return path;
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
|
-
* Wraps the share-UI call: a resolution means the
|
|
17
|
-
*
|
|
18
|
-
* never grants reward eligibility. Rejections
|
|
19
|
-
* platform's error code/message preserved.
|
|
16
|
+
* Wraps the share-UI call: a resolution means ONLY that the SDK share call
|
|
17
|
+
* completed ("completed") — it never proves the share sheet opened or that
|
|
18
|
+
* the user actually shared, and never grants reward eligibility. Rejections
|
|
19
|
+
* surface as failed with the platform's error code/message preserved.
|
|
20
20
|
*/
|
|
21
21
|
export async function runShareUi(platform, message) {
|
|
22
22
|
try {
|
|
23
23
|
await platform.Share.sendMessage({ message });
|
|
24
|
-
return { status: "
|
|
24
|
+
return { status: "completed" };
|
|
25
25
|
}
|
|
26
26
|
catch (error) {
|
|
27
27
|
const code = readErrorCode(error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"framework-loader.d.ts","sourceRoot":"","sources":["../../src/web/framework-loader.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"framework-loader.d.ts","sourceRoot":"","sources":["../../src/web/framework-loader.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAErE;;;;;GAKG;AACH,wBAAgB,+BAA+B,IAAI,iBAAiB,CAQnE"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createWebPlatformLoader } from "./platform-loader.js";
|
|
1
2
|
/**
|
|
2
3
|
* Default lazy loader for the official web SDK: imports
|
|
3
4
|
* `@apps-in-toss/web-framework` (an optional peer) only when an IAP
|
|
@@ -5,28 +6,11 @@
|
|
|
5
6
|
* retries; successful loads are cached.
|
|
6
7
|
*/
|
|
7
8
|
export function createDefaultWebFrameworkLoader() {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
if (
|
|
11
|
-
return { available:
|
|
9
|
+
return createWebPlatformLoader((framework) => {
|
|
10
|
+
const iap = framework.IAP;
|
|
11
|
+
if (typeof iap !== "object" || iap === null) {
|
|
12
|
+
return { available: false, reason: "@apps-in-toss/web-framework does not expose an IAP domain" };
|
|
12
13
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const iap = framework.IAP;
|
|
16
|
-
if (typeof iap !== "object" || iap === null) {
|
|
17
|
-
return {
|
|
18
|
-
available: false,
|
|
19
|
-
reason: "@apps-in-toss/web-framework does not expose an IAP domain"
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
// Per-operation capability is validated at each call site: an
|
|
23
|
-
// installed version may expose some IAP functions but not others.
|
|
24
|
-
cached = iap;
|
|
25
|
-
return { available: true, module: cached };
|
|
26
|
-
}
|
|
27
|
-
catch (error) {
|
|
28
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
29
|
-
return { available: false, reason: `failed to import @apps-in-toss/web-framework: ${message}` };
|
|
30
|
-
}
|
|
31
|
-
};
|
|
14
|
+
return { available: true, module: iap };
|
|
15
|
+
});
|
|
32
16
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../src/web/identity.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../src/web/identity.ts"],"names":[],"mappings":"AAEA,OAAO,EAAY,KAAK,eAAe,EAAE,KAAK,cAAc,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AACnG,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,EAGzB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAEL,KAAK,qBAAqB,EAC1B,KAAK,kBAAkB,EACxB,MAAM,iCAAiC,CAAC;AAEzC,MAAM,WAAW,kBAAkB;IACjC;;;;;OAKG;IACH,SAAS,CAAC,EAAE,mBAAmB,GAAG,sBAAsB,CAAC;CAC1D;AAED,MAAM,WAAW,WAAW;IAC1B,oEAAoE;IACpE,KAAK,IAAI,OAAO,CAAC,cAAc,CAAC,CAAC;IACjC,mEAAmE;IACnE,eAAe,IAAI,OAAO,CAAC,eAAe,CAAC,CAAC;CAC7C;AAED,wBAAgB,iBAAiB,CAAC,OAAO,GAAE,kBAAuB,GAAG,WAAW,CAa/E;AAED,MAAM,WAAW,iBAAiB;IAChC;;;;OAIG;IACH,SAAS,CAAC,EAAE,kBAAkB,GAAG,qBAAqB,CAAC;CACxD;AAED,6EAA6E;AAC7E,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,iBAAsB,GAAG,UAAU,CA8B5E"}
|
package/dist/web/identity.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { resolvePlatformLoader } from "../platform-loader.js";
|
|
2
|
+
import { createWebPlatformLoader } from "./platform-loader.js";
|
|
1
3
|
import { SdkError } from "../index.js";
|
|
2
4
|
import { runSdkGetAnonymousKey, runSdkLogin } from "../identity/platform-contract.js";
|
|
3
5
|
import { createSdkStorageFromPlatform } from "../storage/platform-contract.js";
|
|
@@ -48,40 +50,17 @@ export function createWebStorage(options = {}) {
|
|
|
48
50
|
};
|
|
49
51
|
}
|
|
50
52
|
function normalizeWebIdentityLoader(framework) {
|
|
51
|
-
|
|
52
|
-
return createDefaultWebLoader();
|
|
53
|
-
}
|
|
54
|
-
if (typeof framework === "function") {
|
|
55
|
-
return framework;
|
|
56
|
-
}
|
|
57
|
-
return async () => ({ available: true, module: framework });
|
|
53
|
+
return resolvePlatformLoader(framework, createDefaultWebIdentityLoader);
|
|
58
54
|
}
|
|
59
55
|
function normalizeWebStorageLoader(framework) {
|
|
60
|
-
|
|
61
|
-
return createDefaultWebLoader();
|
|
62
|
-
}
|
|
63
|
-
if (typeof framework === "function") {
|
|
64
|
-
return framework;
|
|
65
|
-
}
|
|
66
|
-
return async () => ({ available: true, module: framework });
|
|
56
|
+
return resolvePlatformLoader(framework, createDefaultWebStorageLoader);
|
|
67
57
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
cached = framework;
|
|
77
|
-
return { available: true, module: cached };
|
|
78
|
-
}
|
|
79
|
-
catch (error) {
|
|
80
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
81
|
-
return {
|
|
82
|
-
available: false,
|
|
83
|
-
reason: `failed to import @apps-in-toss/web-framework: ${message}`
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
};
|
|
58
|
+
// The web SDK exposes the shared namespaced contract shapes directly, so
|
|
59
|
+
// the default loaders consume the official module without any conversion
|
|
60
|
+
// or type assertion; a failed import is never cached, successful loads are.
|
|
61
|
+
function createDefaultWebIdentityLoader() {
|
|
62
|
+
return createWebPlatformLoader(module => ({ available: true, module: module }));
|
|
63
|
+
}
|
|
64
|
+
function createDefaultWebStorageLoader() {
|
|
65
|
+
return createWebPlatformLoader(module => ({ available: true, module: module }));
|
|
87
66
|
}
|
package/dist/web/index.d.ts
CHANGED
|
@@ -44,4 +44,6 @@ export { createWebIdentity, type WebIdentity, type WebIdentityOptions } from "./
|
|
|
44
44
|
export { createWebStorage, type WebStorageOptions } from "./identity.js";
|
|
45
45
|
export { createWebNotification, createWebShare, type WebNotification, type WebNotificationOptions, type WebShare, type WebShareOptions } from "./notify-share.js";
|
|
46
46
|
export declare function createWebIap(options: WebIapOptions): import("../iap/adapter.js").IapAdapter;
|
|
47
|
+
export { createWebReview, type WebReviewOptions } from "./review.js";
|
|
48
|
+
export { createWebPromotion, type WebPromotionOptions } from "./promotion.js";
|
|
47
49
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/web/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/web/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/web/index.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,OAAO,EAAoB,KAAK,iBAAiB,EAAE,KAAK,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACrG,OAAO,KAAK,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAE5F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD,MAAM,WAAW,aAAc,SAAQ,IAAI,CAAC,iBAAiB,EAAE,QAAQ,CAAC;IACtE;;;;OAIG;IACH,SAAS,CAAC,EAAE,eAAe,CAAC,KAAK,CAAC,GAAG,qBAAqB,GAAG,iBAAiB,CAAC;CAChF;AAED,MAAM,MAAM,MAAM,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC;AACrD,YAAY,EAAE,iBAAiB,EAAE,CAAC;AAElC,OAAO,EACL,iBAAiB,EACjB,KAAK,WAAW,EAChB,KAAK,kBAAkB,EACxB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,gBAAgB,EAAE,KAAK,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAGzE,OAAO,EACL,qBAAqB,EACrB,cAAc,EACd,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,KAAK,QAAQ,EACb,KAAK,eAAe,EACrB,MAAM,mBAAmB,CAAC;AAE3B,wBAAgB,YAAY,CAAC,OAAO,EAAE,aAAa,0CAGlD;AAED,OAAO,EAAE,eAAe,EAAE,KAAK,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAErE,OAAO,EAAE,kBAAkB,EAAE,KAAK,mBAAmB,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/web/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { resolvePlatformLoader } from "../platform-loader.js";
|
|
1
2
|
/**
|
|
2
3
|
* Web adapters for `@ait-kit/sdk`.
|
|
3
4
|
*
|
|
@@ -34,10 +35,8 @@ export { createWebStorage } from "./identity.js";
|
|
|
34
35
|
// createWebStorage lives in identity.ts alongside the shared web loader helpers.
|
|
35
36
|
export { createWebNotification, createWebShare } from "./notify-share.js";
|
|
36
37
|
export function createWebIap(options) {
|
|
37
|
-
const loader =
|
|
38
|
-
? createDefaultWebFrameworkLoader()
|
|
39
|
-
: typeof options.framework === "function"
|
|
40
|
-
? options.framework
|
|
41
|
-
: async () => ({ available: true, module: options.framework });
|
|
38
|
+
const loader = resolvePlatformLoader(options.framework, createDefaultWebFrameworkLoader);
|
|
42
39
|
return createIapAdapter({ ...options, loader });
|
|
43
40
|
}
|
|
41
|
+
export { createWebReview } from "./review.js";
|
|
42
|
+
export { createWebPromotion } from "./promotion.js";
|
|
@@ -28,8 +28,9 @@ export interface WebShare {
|
|
|
28
28
|
/** Creates a share link for an `intoss://` deeplink path. */
|
|
29
29
|
createLink(path: string, ogImageUrl?: string): Promise<string>;
|
|
30
30
|
/**
|
|
31
|
-
* Opens the native share sheet; `
|
|
32
|
-
* never grants reward
|
|
31
|
+
* Opens the native share sheet; `completed` means only that the SDK share
|
|
32
|
+
* call finished — it never proves the user shared and never grants reward
|
|
33
|
+
* eligibility.
|
|
33
34
|
*/
|
|
34
35
|
sendMessage(message: string): Promise<SdkShareUiResult>;
|
|
35
36
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notify-share.d.ts","sourceRoot":"","sources":["../../src/web/notify-share.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"notify-share.d.ts","sourceRoot":"","sources":["../../src/web/notify-share.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,8BAA8B,EACnC,KAAK,gBAAgB,EACtB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,KAAK,0BAA0B,EAC/B,KAAK,uBAAuB,EAE7B,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EAGtB,MAAM,+BAA+B,CAAC;AAIvC,MAAM,WAAW,sBAAsB;IACrC;;;;OAIG;IACH,SAAS,CAAC,EAAE,uBAAuB,GAAG,0BAA0B,CAAC;IACjE,4EAA4E;IAC5E,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,eAAe;IAC9B,qEAAqE;IACrE,gBAAgB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,8BAA8B,CAAC,CAAC;CACjF;AAED,wBAAgB,qBAAqB,CAAC,OAAO,GAAE,sBAA2B,GAAG,eAAe,CAa3F;AAED,MAAM,WAAW,eAAe;IAC9B;;;;OAIG;IACH,SAAS,CAAC,EAAE,gBAAgB,GAAG,mBAAmB,CAAC;CACpD;AAED,MAAM,WAAW,QAAQ;IACvB,6DAA6D;IAC7D,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC/D;;;;OAIG;IACH,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;CACzD;AAED,wBAAgB,cAAc,CAAC,OAAO,GAAE,eAAoB,GAAG,QAAQ,CAwCtE"}
|
package/dist/web/notify-share.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { resolvePlatformLoader } from "../platform-loader.js";
|
|
2
|
+
import { createWebPlatformLoader } from "./platform-loader.js";
|
|
1
3
|
import { SdkError } from "../index.js";
|
|
2
4
|
import { runRequestAgreement } from "../notification/platform-contract.js";
|
|
3
5
|
import { runShareUi, validateSharePath } from "../share/platform-contract.js";
|
|
@@ -53,42 +55,18 @@ export function createWebShare(options = {}) {
|
|
|
53
55
|
};
|
|
54
56
|
}
|
|
55
57
|
function normalizeWebNotificationLoader(framework) {
|
|
56
|
-
|
|
57
|
-
return createDefaultWebModuleLoader();
|
|
58
|
-
}
|
|
59
|
-
if (typeof framework === "function") {
|
|
60
|
-
return framework;
|
|
61
|
-
}
|
|
62
|
-
return async () => ({ available: true, module: framework });
|
|
58
|
+
return resolvePlatformLoader(framework, createDefaultWebNotificationLoader);
|
|
63
59
|
}
|
|
64
60
|
function normalizeWebShareLoader(framework) {
|
|
65
|
-
|
|
66
|
-
return createDefaultWebModuleLoader();
|
|
67
|
-
}
|
|
68
|
-
if (typeof framework === "function") {
|
|
69
|
-
return framework;
|
|
70
|
-
}
|
|
71
|
-
return async () => ({ available: true, module: framework });
|
|
61
|
+
return resolvePlatformLoader(framework, createDefaultWebShareLoader);
|
|
72
62
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
const framework = (await import("@apps-in-toss/web-framework"));
|
|
81
|
-
cached = framework;
|
|
82
|
-
return { available: true, module: cached };
|
|
83
|
-
}
|
|
84
|
-
catch (error) {
|
|
85
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
86
|
-
return {
|
|
87
|
-
available: false,
|
|
88
|
-
reason: `failed to import @apps-in-toss/web-framework: ${message}`
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
};
|
|
63
|
+
// See createDefaultWebIdentityLoader in ./identity.ts: the web SDK already
|
|
64
|
+
// matches the shared contract shapes, so no conversion or assertion is used.
|
|
65
|
+
function createDefaultWebNotificationLoader() {
|
|
66
|
+
return createWebPlatformLoader(module => ({ available: true, module: module }));
|
|
67
|
+
}
|
|
68
|
+
function createDefaultWebShareLoader() {
|
|
69
|
+
return createWebPlatformLoader(module => ({ available: true, module: module }));
|
|
92
70
|
}
|
|
93
71
|
/**
|
|
94
72
|
* Same loader-covering deadline as the React Native adapter; see
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type PlatformLoader, type PlatformLoadResult } from "../platform-loader.js";
|
|
2
|
+
/** Lazy platform-local import followed by capability-specific selection. */
|
|
3
|
+
export declare function createWebPlatformLoader<T>(select: (module: typeof import("@apps-in-toss/web-framework")) => PlatformLoadResult<T>, includeErrorDetails?: boolean): PlatformLoader<T>;
|
|
4
|
+
//# sourceMappingURL=platform-loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform-loader.d.ts","sourceRoot":"","sources":["../../src/web/platform-loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoD,KAAK,cAAc,EAAE,KAAK,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AACvI,4EAA4E;AAC5E,wBAAgB,uBAAuB,CAAC,CAAC,EACvC,MAAM,EAAE,CAAC,MAAM,EAAE,cAAc,6BAA6B,CAAC,KAAK,kBAAkB,CAAC,CAAC,CAAC,EACvF,mBAAmB,UAAO,GACzB,cAAc,CAAC,CAAC,CAAC,CAKnB"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { createCachedPlatformLoader, frameworkImportError } from "../platform-loader.js";
|
|
2
|
+
/** Lazy platform-local import followed by capability-specific selection. */
|
|
3
|
+
export function createWebPlatformLoader(select, includeErrorDetails = true) {
|
|
4
|
+
return createCachedPlatformLoader(async () => select(await import("@apps-in-toss/web-framework")), error => frameworkImportError("@apps-in-toss/web-framework", error, includeErrorDetails));
|
|
5
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { PromotionAdapter, PromotionPlatformLoader, PromotionPlatformSdk } from "../promotion/platform-contract.js";
|
|
2
|
+
export interface WebPromotionOptions {
|
|
3
|
+
/** Shared Promotion contract or async loader; defaults to the official SDK. */
|
|
4
|
+
framework?: PromotionPlatformSdk | PromotionPlatformLoader;
|
|
5
|
+
/** Overall wait deadline; 0 (default) disables it. Timeout does not cancel payment. */
|
|
6
|
+
timeoutMs?: number;
|
|
7
|
+
}
|
|
8
|
+
export declare function createWebPromotion(options?: WebPromotionOptions): PromotionAdapter;
|
|
9
|
+
//# sourceMappingURL=promotion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"promotion.d.ts","sourceRoot":"","sources":["../../src/web/promotion.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAEzH,MAAM,WAAW,mBAAmB;IAClC,+EAA+E;IAC/E,SAAS,CAAC,EAAE,oBAAoB,GAAG,uBAAuB,CAAC;IAC3D,uFAAuF;IACvF,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,kBAAkB,CAAC,OAAO,GAAE,mBAAwB,GAAG,gBAAgB,CAEtF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { resolvePlatformLoader } from "../platform-loader.js";
|
|
2
|
+
import { createWebPlatformLoader } from "./platform-loader.js";
|
|
3
|
+
import { createPromotionAdapter } from "../promotion/adapter.js";
|
|
4
|
+
export function createWebPromotion(options = {}) {
|
|
5
|
+
return createPromotionAdapter(resolvePlatformLoader(options.framework, createDefaultPromotionLoader), options.timeoutMs);
|
|
6
|
+
}
|
|
7
|
+
/** Keep import diagnostics redacted for direct-promotion operations. */
|
|
8
|
+
function createDefaultPromotionLoader() {
|
|
9
|
+
return createWebPlatformLoader(module => ({ available: true, module: module }), false);
|
|
10
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ReviewAdapter, ReviewPlatformLoader, ReviewPlatformSdk } from "../review/platform-contract.js";
|
|
2
|
+
export interface WebReviewOptions {
|
|
3
|
+
/** Shared contract injection, or a loader; defaults to the lazy official SDK. */
|
|
4
|
+
framework?: ReviewPlatformSdk | ReviewPlatformLoader;
|
|
5
|
+
}
|
|
6
|
+
export declare function createWebReview(options?: WebReviewOptions): ReviewAdapter;
|
|
7
|
+
//# sourceMappingURL=review.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"review.d.ts","sourceRoot":"","sources":["../../src/web/review.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAE7G,MAAM,WAAW,gBAAgB;IAC/B,iFAAiF;IACjF,SAAS,CAAC,EAAE,iBAAiB,GAAG,oBAAoB,CAAC;CACtD;AAED,wBAAgB,eAAe,CAAC,OAAO,GAAE,gBAAqB,GAAG,aAAa,CAE7E"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { resolvePlatformLoader } from "../platform-loader.js";
|
|
2
|
+
import { createWebPlatformLoader } from "./platform-loader.js";
|
|
3
|
+
import { createReviewAdapter } from "../review/adapter.js";
|
|
4
|
+
export function createWebReview(options = {}) {
|
|
5
|
+
return createReviewAdapter(resolvePlatformLoader(options.framework, createDefaultReviewLoader));
|
|
6
|
+
}
|
|
7
|
+
function createDefaultReviewLoader() {
|
|
8
|
+
return createWebPlatformLoader(module => ({ available: true, module: module }), false);
|
|
9
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ait-kit/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Frontend SDK adapters for Apps in Toss mini apps: shared contracts plus per-runtime entry points.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
"prepack": "bun run build"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
|
-
"@apps-in-toss/framework": "
|
|
53
|
-
"@apps-in-toss/web-framework": "
|
|
52
|
+
"@apps-in-toss/framework": ">=2.10.10",
|
|
53
|
+
"@apps-in-toss/web-framework": ">=3.4.0"
|
|
54
54
|
},
|
|
55
55
|
"peerDependenciesMeta": {
|
|
56
56
|
"@apps-in-toss/framework": {
|