@leonxin/meetgames 0.1.18 → 0.1.19

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.
Files changed (88) hide show
  1. package/README.md +5 -4
  2. package/dist/cache.d.ts +16 -0
  3. package/dist/cache.d.ts.map +1 -1
  4. package/dist/cache.js +21 -0
  5. package/dist/cache.js.map +1 -1
  6. package/dist/cli.d.ts.map +1 -1
  7. package/dist/cli.js +20 -16
  8. package/dist/cli.js.map +1 -1
  9. package/dist/config/meetSdkDefaultConfig.d.ts +7 -11
  10. package/dist/config/meetSdkDefaultConfig.d.ts.map +1 -1
  11. package/dist/config/meetSdkDefaultConfig.js +216 -53
  12. package/dist/config/meetSdkDefaultConfig.js.map +1 -1
  13. package/dist/config/meetSdkIosConfig.d.ts +4 -5
  14. package/dist/config/meetSdkIosConfig.d.ts.map +1 -1
  15. package/dist/config/meetSdkIosConfig.js +19 -19
  16. package/dist/config/meetSdkIosConfig.js.map +1 -1
  17. package/dist/contracts/types.d.ts +4 -0
  18. package/dist/contracts/types.d.ts.map +1 -1
  19. package/dist/core/doctor.d.ts.map +1 -1
  20. package/dist/core/doctor.js +2 -0
  21. package/dist/core/doctor.js.map +1 -1
  22. package/dist/core/previewPatches.d.ts +2 -2
  23. package/dist/core/previewPatches.d.ts.map +1 -1
  24. package/dist/core/previewPatches.js +3 -3
  25. package/dist/core/previewPatches.js.map +1 -1
  26. package/dist/core/workspace.d.ts.map +1 -1
  27. package/dist/core/workspace.js +1 -0
  28. package/dist/core/workspace.js.map +1 -1
  29. package/dist/index.d.ts +4 -4
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/index.js +4 -4
  32. package/dist/index.js.map +1 -1
  33. package/dist/mcp/service.d.ts +2 -0
  34. package/dist/mcp/service.d.ts.map +1 -1
  35. package/dist/mcp/service.js +8 -7
  36. package/dist/mcp/service.js.map +1 -1
  37. package/dist/ops/handlers.d.ts.map +1 -1
  38. package/dist/ops/handlers.js +4 -0
  39. package/dist/ops/handlers.js.map +1 -1
  40. package/dist/remote/sdkHomeDownload.d.ts +4 -5
  41. package/dist/remote/sdkHomeDownload.d.ts.map +1 -1
  42. package/dist/remote/sdkHomeDownload.js +38 -12
  43. package/dist/remote/sdkHomeDownload.js.map +1 -1
  44. package/docs/API.md +13 -13
  45. package/docs/CLI.md +27 -13
  46. package/docs/INTEGRATION.md +7 -6
  47. package/package.json +1 -1
  48. package/src/cache.ts +37 -0
  49. package/src/cli.ts +21 -14
  50. package/src/config/meetSdkDefaultConfig.ts +243 -59
  51. package/src/config/meetSdkIosConfig.ts +17 -21
  52. package/src/contracts/types.ts +4 -0
  53. package/src/core/doctor.ts +2 -0
  54. package/src/core/previewPatches.ts +3 -3
  55. package/src/core/workspace.ts +1 -0
  56. package/src/index.ts +5 -3
  57. package/src/mcp/service.ts +11 -7
  58. package/src/ops/handlers.ts +4 -0
  59. package/src/remote/sdkHomeDownload.ts +48 -16
  60. package/config/meetsdk-android.json +0 -171
  61. package/config/meetsdk-ios.json +0 -15
  62. package/tests/assemble.test.ts +0 -12
  63. package/tests/doctor.test.ts +0 -131
  64. package/tests/downloadGoogleServicesJson.test.ts +0 -47
  65. package/tests/fetch-remote.test.ts +0 -23
  66. package/tests/fetchConfigOverrides.test.ts +0 -28
  67. package/tests/fetchConfigWrite.test.ts +0 -54
  68. package/tests/fixtures-hosts.test.ts +0 -78
  69. package/tests/gradle.test.ts +0 -33
  70. package/tests/integration-json.test.ts +0 -29
  71. package/tests/ios.codeUtils.test.ts +0 -23
  72. package/tests/ios.sdkBundle.test.ts +0 -21
  73. package/tests/loadManifest.test.ts +0 -15
  74. package/tests/manifest-xml.test.ts +0 -30
  75. package/tests/mcp.e2e.ts +0 -214
  76. package/tests/mcp.service.test.ts +0 -53
  77. package/tests/meetSdkRemoteConfig.test.ts +0 -482
  78. package/tests/meetSdkRemoteGradle.test.ts +0 -414
  79. package/tests/pipeline.android.test.ts +0 -149
  80. package/tests/pipeline.integration-json.test.ts +0 -58
  81. package/tests/pipeline.ios.test.ts +0 -609
  82. package/tests/pipeline.preview.patch.test.ts +0 -85
  83. package/tests/platformSelection.test.ts +0 -77
  84. package/tests/sdkHomeDownload.test.ts +0 -275
  85. package/tests/sdkVersionConfig.test.ts +0 -131
  86. package/tests/topsdk.test.ts +0 -53
  87. package/tests/topsdkDownloadSdkConfig.test.ts +0 -81
  88. package/tests/topsdkFeatureModules.test.ts +0 -116
@@ -1,85 +0,0 @@
1
- import fs from "node:fs";
2
- import path from "node:path";
3
- import { fileURLToPath } from "node:url";
4
- import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
5
- import { loadAndroidIntegrationFile } from "../src/config/loadAndroidIntegration.js";
6
- import { loadManifestFile } from "../src/config/loadManifest.js";
7
- import type { AndroidIntegrationDocument, Manifest } from "../src/contracts/types.js";
8
- import { clearPreviewPatchFilesIfTargetInside } from "../src/core/previewPatches.js";
9
- import { buildWorkspaceContext } from "../src/core/workspace.js";
10
- import { runPipeline } from "../src/core/pipeline.js";
11
-
12
- const here = path.dirname(fileURLToPath(import.meta.url));
13
- const pkgRoot = path.resolve(here, "..");
14
- const fixtureRoot = path.join(pkgRoot, "fixtures", "android-test-project", "android-latest-project");
15
- const recipeFixtureRoot = path.join(pkgRoot, "fixtures", "recipes");
16
- const previewPatchPath = path.join(pkgRoot, "preview-patches", "pipeline.patch");
17
-
18
- function stubSdkHomeVersion(): void {
19
- vi.stubGlobal(
20
- "fetch",
21
- vi.fn(async () => ({
22
- ok: true,
23
- status: 200,
24
- text: async () =>
25
- JSON.stringify({
26
- code: 200,
27
- data: {
28
- result: {
29
- android: { ver: "1.6.1.3", date: "2026-05-25" },
30
- ios: { ver: "1.6.0.5", date: "2026-06-09" },
31
- },
32
- },
33
- }),
34
- })) as unknown as typeof fetch
35
- );
36
- }
37
-
38
- function toManifest(doc: AndroidIntegrationDocument): Manifest {
39
- const { meta: _m, remote: _r, ...rest } = doc;
40
- void _m;
41
- void _r;
42
- return rest;
43
- }
44
-
45
- /**
46
- * Single on-disk preview for humans / CI artifacts: both fixture manifests (dry-run only).
47
- */
48
- describe("pipeline preview patch", () => {
49
- beforeEach(() => {
50
- stubSdkHomeVersion();
51
- });
52
-
53
- afterEach(() => {
54
- vi.unstubAllGlobals();
55
- });
56
-
57
- it("writes preview-patches/pipeline.patch (yaml + integration-json)", async () => {
58
- const ctx = buildWorkspaceContext(fixtureRoot, pkgRoot);
59
- expect(ctx.android?.ok).toBe(true);
60
-
61
- const yamlManifest = loadManifestFile(path.join(recipeFixtureRoot, "android-default.fixture.yaml"));
62
- const rYaml = await runPipeline(ctx, yamlManifest, { dryRun: true });
63
- expect(rYaml.report.errors).toEqual([]);
64
-
65
- const doc = loadAndroidIntegrationFile(path.join(recipeFixtureRoot, "android-integration.fixture.json"));
66
- const rJson = await runPipeline(ctx, toManifest(doc), { dryRun: true });
67
- expect(rJson.report.errors).toEqual([]);
68
-
69
- const body = [
70
- "# dry-run — fixtures/recipes/android-default.fixture.yaml",
71
- rYaml.patch.trimEnd(),
72
- "",
73
- "# dry-run — android-integration.fixture.json",
74
- rJson.patch.trimEnd(),
75
- "",
76
- ].join("\n");
77
-
78
- clearPreviewPatchFilesIfTargetInside(pkgRoot, previewPatchPath);
79
- fs.mkdirSync(path.dirname(previewPatchPath), { recursive: true });
80
- fs.writeFileSync(previewPatchPath, body, "utf8");
81
-
82
- expect(rYaml.patch).toContain("TOPSDK REPO AUTO");
83
- expect(rJson.patch).toContain("TOPSDK AUTO");
84
- });
85
- });
@@ -1,77 +0,0 @@
1
- import fs from "node:fs";
2
- import path from "node:path";
3
- import { describe, expect, it } from "vitest";
4
- import {
5
- manifestForPlatform,
6
- detectSinglePlatform,
7
- platformContext,
8
- } from "../src/core/platform.js";
9
- import { buildWorkspaceContext } from "../src/core/workspace.js";
10
- import type { Manifest } from "../src/contracts/types.js";
11
-
12
- const pkgRoot = path.resolve(__dirname, "..");
13
- const androidLatestRoot = path.join(pkgRoot, "fixtures", "android-test-project", "android-latest-project");
14
- const iosProjectRoot = path.join(pkgRoot, "fixtures", "ios-test-project", "native-sample");
15
- const hasIosProjectFixture = fs.existsSync(iosProjectRoot);
16
-
17
- describe("platform selection", () => {
18
- it("detects Android project roots as Android only", () => {
19
- const ctx = buildWorkspaceContext(androidLatestRoot, pkgRoot);
20
- const detected = detectSinglePlatform(ctx);
21
-
22
- expect(detected).toEqual({ ok: true, platform: "android" });
23
- expect(platformContext(ctx, "android").android?.ok).toBe(true);
24
- expect(platformContext(ctx, "android").ios).toBeUndefined();
25
- });
26
-
27
- it.skipIf(!hasIosProjectFixture)("detects iOS project roots as iOS only", () => {
28
- const ctx = buildWorkspaceContext(iosProjectRoot, pkgRoot);
29
- const detected = detectSinglePlatform(ctx);
30
-
31
- expect(detected).toEqual({ ok: true, platform: "ios" });
32
- expect(platformContext(ctx, "ios").ios?.ok).toBe(true);
33
- expect(platformContext(ctx, "ios").android).toBeUndefined();
34
- });
35
-
36
- it("filters mixed manifests to the selected platform before running", () => {
37
- const manifest: Manifest = {
38
- version: 1,
39
- steps: [
40
- { op: "android.one", platform: "android" },
41
- { op: "ios.one", platform: "ios" },
42
- { op: "shared.one", platform: "all" },
43
- { op: "shared.two" },
44
- ],
45
- };
46
-
47
- expect(manifestForPlatform(manifest, "android").steps.map((s) => s.op)).toEqual([
48
- "android.one",
49
- "shared.one",
50
- "shared.two",
51
- ]);
52
- expect(manifestForPlatform(manifest, "ios").steps.map((s) => s.op)).toEqual([
53
- "ios.one",
54
- "shared.one",
55
- "shared.two",
56
- ]);
57
- });
58
-
59
- it.skipIf(!hasIosProjectFixture)("overrides detected iOS target name when explicitly provided", () => {
60
- const ctx = buildWorkspaceContext(iosProjectRoot, pkgRoot, {
61
- appTarget: "native-sample",
62
- });
63
-
64
- expect(ctx.ios?.ok && ctx.ios.targetName).toBe("native-sample");
65
- expect(ctx.ios?.ok && ctx.ios.targetNames).toContain("native-sample");
66
- });
67
-
68
- it.skipIf(!hasIosProjectFixture)("rejects missing iOS app target names during detection", () => {
69
- const ctx = buildWorkspaceContext(iosProjectRoot, pkgRoot, {
70
- appTarget: "GameRelease",
71
- });
72
-
73
- expect(ctx.ios?.ok).toBe(false);
74
- expect(ctx.ios?.ok ? "" : ctx.ios?.error).toContain("IOS_APP_TARGET_NOT_FOUND: GameRelease");
75
- });
76
-
77
- });
@@ -1,275 +0,0 @@
1
- import { afterEach, describe, expect, it, vi } from "vitest";
2
- import fs from "node:fs";
3
- import os from "node:os";
4
- import path from "node:path";
5
- import { fileURLToPath } from "node:url";
6
- import {
7
- DEFAULT_IOS_SDK_PLUGINS,
8
- buildSdkHomeDownloadUrl,
9
- buildSdkHomeVersionUrl,
10
- downloadIosSdkToBundled,
11
- fetchSdkHomeIosDownloadUrl,
12
- fetchSdkHomeIosVersion,
13
- fetchSdkHomeVersions,
14
- resolveIosSdkDownloadPluginsFromRemoteConfig,
15
- resolveIosSdkRootFromDirectory,
16
- resolveIosSdkZipFileName,
17
- } from "../src/remote/sdkHomeDownload.js";
18
- import { resolveIosSdkCacheLayout } from "../src/cache.js";
19
-
20
- describe("sdk-home iOS SDK download client", () => {
21
- afterEach(() => {
22
- vi.unstubAllGlobals();
23
- });
24
-
25
- it("builds version and getDownLoadUrl URLs", () => {
26
- expect(buildSdkHomeVersionUrl("https://business-api.meetgames.com")).toBe(
27
- "https://business-api.meetgames.com/sdk/home/version"
28
- );
29
- const url = buildSdkHomeDownloadUrl({
30
- baseUrl: "https://business-api.meetgames.com/",
31
- version: "1.6.0.5",
32
- plugins: DEFAULT_IOS_SDK_PLUGINS,
33
- packageType: "native",
34
- });
35
- const u = new URL(url);
36
- expect(u.pathname).toBe("/sdk/home/sdk-download/getDownLoadUrl");
37
- expect(u.searchParams.get("version")).toBe("1.6.0.5");
38
- expect(u.searchParams.get("platform")).toBe("ios");
39
- expect(u.searchParams.get("plugins")).toBe(DEFAULT_IOS_SDK_PLUGINS.join(","));
40
- expect(u.searchParams.get("packageType")).toBe("native");
41
- });
42
-
43
- it("parses the iOS version envelope", async () => {
44
- vi.stubGlobal(
45
- "fetch",
46
- vi.fn(async () => ({
47
- ok: true,
48
- status: 200,
49
- text: async () =>
50
- JSON.stringify({
51
- code: 200,
52
- data: {
53
- result: {
54
- android: { ver: "1.6.1.3", date: "2026-05-25" },
55
- ios: { ver: "1.6.0.5", date: "2026-06-09" },
56
- },
57
- },
58
- }),
59
- })) as unknown as typeof fetch
60
- );
61
-
62
- const { ios } = await fetchSdkHomeIosVersion({ baseUrl: "https://example.com" });
63
- expect(ios).toEqual({ ver: "1.6.0.5", date: "2026-06-09" });
64
- });
65
-
66
- it("parses Android and iOS versions from the version envelope", async () => {
67
- vi.stubGlobal(
68
- "fetch",
69
- vi.fn(async () => ({
70
- ok: true,
71
- status: 200,
72
- text: async () =>
73
- JSON.stringify({
74
- code: 200,
75
- data: {
76
- result: {
77
- android: { ver: "1.6.1.3", date: "2026-05-25" },
78
- ios: { ver: "1.6.0.5", date: "2026-06-09" },
79
- },
80
- },
81
- }),
82
- })) as unknown as typeof fetch
83
- );
84
-
85
- const { versions } = await fetchSdkHomeVersions({ baseUrl: "https://example.com" });
86
- expect(versions.android).toEqual({ ver: "1.6.1.3", date: "2026-05-25" });
87
- expect(versions.ios).toEqual({ ver: "1.6.0.5", date: "2026-06-09" });
88
- });
89
-
90
- it("parses the download URL envelope", async () => {
91
- vi.stubGlobal(
92
- "fetch",
93
- vi.fn(async () => ({
94
- ok: true,
95
- status: 200,
96
- text: async () => JSON.stringify({ code: 200, data: "https://cdn.example.com/topSDK-ios.zip" }),
97
- })) as unknown as typeof fetch
98
- );
99
-
100
- const { sdkZipUrl } = await fetchSdkHomeIosDownloadUrl({
101
- baseUrl: "https://example.com",
102
- version: "1.6.0.5",
103
- });
104
- expect(sdkZipUrl).toBe("https://cdn.example.com/topSDK-ios.zip");
105
- });
106
-
107
- it("uses the sdk-home generated iOS archive name", () => {
108
- expect(resolveIosSdkZipFileName("1.6.0.5")).toBe("topSDK-ios--V1.6.0.5.zip");
109
- });
110
-
111
- it("resolves SDK download plugins from the iOS remote config", () => {
112
- expect(
113
- resolveIosSdkDownloadPluginsFromRemoteConfig({
114
- packageName: "com.example.app",
115
- channel: "APPLE",
116
- devicePlatform: "ios",
117
- topsdk: { appId: "app", appSecret: "secret" },
118
- sdkModules: {
119
- login: {
120
- guest: {},
121
- email: {},
122
- facebook: { clientId: "fb", scheme: "fb", secret: "token" },
123
- google: { clientId: "google", scheme: "google" },
124
- snapchat: { clientId: "snap", redirect: "snap://callback" },
125
- line: { clientId: "line", scheme: "line" },
126
- naver: { clientId: "naver", secret: "secret", scheme: "naver" },
127
- kakao: { clientId: "kakao", scheme: "kakao" },
128
- tiktok: { clientId: "tiktok", secret: "secret", redirect: "tiktok://callback" },
129
- discord: { clientId: "discord", secret: "secret", redirect: "https://example.invalid/discord" },
130
- apple: {},
131
- },
132
- payment: { appleIap: {} },
133
- analytics: {
134
- appsflyer: { devKey: "af", appleAppId: "123" },
135
- firebase: { firebase_file_url: "https://cdn.example.invalid/GoogleService-Info.plist" },
136
- adjust: { appCode: "adjust" },
137
- facebookdata: { clientId: "fb", scheme: "fb", secret: "token" },
138
- },
139
- },
140
- })
141
- ).toEqual([
142
- "guest",
143
- "email",
144
- "facebook",
145
- "google",
146
- "snapchat",
147
- "line",
148
- "naver",
149
- "kakao",
150
- "tiktok",
151
- "discord",
152
- "apple",
153
- "apple_pay",
154
- "dataAppsFlyer",
155
- "dataFirebase",
156
- "dataAdjust",
157
- "dataFacebook",
158
- ]);
159
- });
160
-
161
- it("resolves top-level and nested extracted SDK layouts", () => {
162
- const root = fs.mkdtempSync(path.join(os.tmpdir(), "meet-sdk-tool-ios-"));
163
- try {
164
- fs.mkdirSync(path.join(root, "sdk"), { recursive: true });
165
- fs.mkdirSync(path.join(root, "plugins"), { recursive: true });
166
- expect(resolveIosSdkRootFromDirectory(root)).toBe(root);
167
-
168
- const nestedRoot = path.join(root, "nested");
169
- fs.rmSync(path.join(root, "sdk"), { recursive: true, force: true });
170
- fs.rmSync(path.join(root, "plugins"), { recursive: true, force: true });
171
- fs.mkdirSync(path.join(nestedRoot, "sdk"), { recursive: true });
172
- fs.mkdirSync(path.join(nestedRoot, "plugins"), { recursive: true });
173
- expect(resolveIosSdkRootFromDirectory(root)).toBe(nestedRoot);
174
- } finally {
175
- fs.rmSync(root, { recursive: true, force: true });
176
- }
177
- });
178
-
179
- it("reuses an existing iOS SDK cache for the latest server version", async () => {
180
- const version = "99.88.77-cache-test";
181
- const cacheRoot = fs.mkdtempSync(path.join(os.tmpdir(), "meet-sdk-tool-cache-"));
182
- const cacheLayout = resolveIosSdkCacheLayout({
183
- version,
184
- packageType: "native",
185
- plugins: [...DEFAULT_IOS_SDK_PLUGINS],
186
- cacheRoot,
187
- });
188
- fs.mkdirSync(path.join(cacheLayout.extractDir, "sdk"), { recursive: true });
189
- fs.mkdirSync(path.join(cacheLayout.extractDir, "plugins"), { recursive: true });
190
- const fetchMock = vi.fn(async (input: string | URL) => {
191
- const url = String(input);
192
- if (url.includes("/sdk/home/sdk-download/getDownLoadUrl")) {
193
- throw new Error("download URL should not be requested when cache is current");
194
- }
195
- return {
196
- ok: true,
197
- status: 200,
198
- text: async () =>
199
- JSON.stringify({
200
- code: 200,
201
- data: {
202
- result: {
203
- android: { ver: "1.0.0", date: "2026-01-01" },
204
- ios: { ver: version, date: "2026-06-26" },
205
- },
206
- },
207
- }),
208
- };
209
- });
210
- vi.stubGlobal("fetch", fetchMock as unknown as typeof fetch);
211
-
212
- try {
213
- const result = await downloadIosSdkToBundled(path.resolve(path.dirname(fileURLToPath(import.meta.url)), ".."), {
214
- baseUrl: "https://example.com",
215
- cacheRoot,
216
- });
217
-
218
- expect(result.version).toBe(version);
219
- expect(result.downloaded).toBe(false);
220
- expect(result.resolvedSdkRoot).toBe(cacheLayout.extractDir);
221
- expect(fetchMock).toHaveBeenCalledTimes(1);
222
- } finally {
223
- fs.rmSync(cacheRoot, { recursive: true, force: true });
224
- }
225
- });
226
-
227
- it("reuses a higher local iOS SDK cache instead of downloading an older server version", async () => {
228
- const serverVersion = "99.88.77-cache-test";
229
- const cachedVersion = "99.88.78-cache-test";
230
- const cacheRoot = fs.mkdtempSync(path.join(os.tmpdir(), "meet-sdk-tool-cache-"));
231
- const cacheLayout = resolveIosSdkCacheLayout({
232
- version: cachedVersion,
233
- packageType: "native",
234
- plugins: [...DEFAULT_IOS_SDK_PLUGINS],
235
- cacheRoot,
236
- });
237
- fs.mkdirSync(path.join(cacheLayout.extractDir, "sdk"), { recursive: true });
238
- fs.mkdirSync(path.join(cacheLayout.extractDir, "plugins"), { recursive: true });
239
- const fetchMock = vi.fn(async (input: string | URL) => {
240
- const url = String(input);
241
- if (url.includes("/sdk/home/sdk-download/getDownLoadUrl")) {
242
- throw new Error("download URL should not be requested when a higher cache is available");
243
- }
244
- return {
245
- ok: true,
246
- status: 200,
247
- text: async () =>
248
- JSON.stringify({
249
- code: 200,
250
- data: {
251
- result: {
252
- android: { ver: "1.0.0", date: "2026-01-01" },
253
- ios: { ver: serverVersion, date: "2026-06-26" },
254
- },
255
- },
256
- }),
257
- };
258
- });
259
- vi.stubGlobal("fetch", fetchMock as unknown as typeof fetch);
260
-
261
- try {
262
- const result = await downloadIosSdkToBundled(path.resolve(path.dirname(fileURLToPath(import.meta.url)), ".."), {
263
- baseUrl: "https://example.com",
264
- cacheRoot,
265
- });
266
-
267
- expect(result.version).toBe(cachedVersion);
268
- expect(result.downloaded).toBe(false);
269
- expect(result.resolvedSdkRoot).toBe(cacheLayout.extractDir);
270
- expect(fetchMock).toHaveBeenCalledTimes(1);
271
- } finally {
272
- fs.rmSync(cacheRoot, { recursive: true, force: true });
273
- }
274
- });
275
- });
@@ -1,131 +0,0 @@
1
- import fs from "node:fs";
2
- import os from "node:os";
3
- import path from "node:path";
4
- import { afterEach, describe, expect, it, vi } from "vitest";
5
- import { loadMeetSdkDefaultConfigWithLatestAndroidVersion } from "../src/config/meetSdkDefaultConfig.js";
6
- import {
7
- loadMeetSdkIosConfig,
8
- resolveMeetSdkIosConfigPath,
9
- syncMeetSdkIosVersionToConfig,
10
- } from "../src/config/meetSdkIosConfig.js";
11
-
12
- function makeTempPackageRoot(): string {
13
- return fs.mkdtempSync(path.join(os.tmpdir(), "meet-sdk-config-"));
14
- }
15
-
16
- function writeAndroidDefaults(packageRoot: string): void {
17
- fs.mkdirSync(path.join(packageRoot, "config"), { recursive: true });
18
- fs.writeFileSync(
19
- path.join(packageRoot, "config", "meetsdk-android.json"),
20
- JSON.stringify(
21
- {
22
- topsdk: {
23
- version: "",
24
- groupId: "com.sino.topsdk",
25
- repositories: [],
26
- },
27
- sdkModules: {
28
- login: {},
29
- payment: {},
30
- analytics: {},
31
- },
32
- },
33
- null,
34
- 2
35
- ),
36
- "utf8"
37
- );
38
- }
39
-
40
- describe("SDK version package configs", () => {
41
- afterEach(() => {
42
- vi.unstubAllGlobals();
43
- });
44
-
45
- it("stores fetched Android SDK version in meetsdk-android.json", async () => {
46
- const packageRoot = makeTempPackageRoot();
47
- try {
48
- writeAndroidDefaults(packageRoot);
49
- vi.stubGlobal(
50
- "fetch",
51
- vi.fn(async () => ({
52
- ok: true,
53
- status: 200,
54
- text: async () =>
55
- JSON.stringify({
56
- code: 200,
57
- data: {
58
- result: {
59
- android: { ver: "9.8.7", date: "2026-06-20" },
60
- ios: { ver: "1.2.3", date: "2026-06-21" },
61
- },
62
- },
63
- }),
64
- })) as unknown as typeof fetch
65
- );
66
-
67
- const defaults = await loadMeetSdkDefaultConfigWithLatestAndroidVersion({
68
- sdkHomeApiBaseUrl: "https://android-version-sync.example.com",
69
- packageRoot,
70
- });
71
-
72
- const stored = JSON.parse(fs.readFileSync(path.join(packageRoot, "config", "meetsdk-android.json"), "utf8")) as {
73
- topsdk: { version: string; date: string };
74
- };
75
- expect(defaults.topsdk.version).toBe("9.8.7");
76
- expect(defaults.topsdk.date).toBe("2026-06-20");
77
- expect(stored.topsdk.version).toBe("9.8.7");
78
- expect(stored.topsdk.date).toBe("2026-06-20");
79
- } finally {
80
- fs.rmSync(packageRoot, { recursive: true, force: true });
81
- }
82
- });
83
-
84
- it("stores resolved iOS SDK version in meetsdk-ios.json", () => {
85
- const packageRoot = makeTempPackageRoot();
86
- try {
87
- const configPath = syncMeetSdkIosVersionToConfig({
88
- packageRoot,
89
- version: "1.6.0.5",
90
- date: "2026-06-09",
91
- packageType: "native",
92
- plugins: ["guest", "facebook"],
93
- });
94
-
95
- expect(configPath).toBe(resolveMeetSdkIosConfigPath(packageRoot));
96
- expect(loadMeetSdkIosConfig(packageRoot)).toEqual({
97
- topsdk: {
98
- version: "1.6.0.5",
99
- date: "2026-06-09",
100
- packageType: "native",
101
- plugins: ["guest", "facebook"],
102
- },
103
- });
104
- } finally {
105
- fs.rmSync(packageRoot, { recursive: true, force: true });
106
- }
107
- });
108
-
109
- it("clears stale iOS SDK date when only an explicit version is stored", () => {
110
- const packageRoot = makeTempPackageRoot();
111
- try {
112
- syncMeetSdkIosVersionToConfig({
113
- packageRoot,
114
- version: "1.6.0.5",
115
- date: "2026-06-09",
116
- });
117
- syncMeetSdkIosVersionToConfig({
118
- packageRoot,
119
- version: "1.6.0.6",
120
- date: "",
121
- });
122
-
123
- expect(loadMeetSdkIosConfig(packageRoot).topsdk).toMatchObject({
124
- version: "1.6.0.6",
125
- });
126
- expect(loadMeetSdkIosConfig(packageRoot).topsdk.date).toBeUndefined();
127
- } finally {
128
- fs.rmSync(packageRoot, { recursive: true, force: true });
129
- }
130
- });
131
- });
@@ -1,53 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { topsdkMd5Base64Sign } from "../src/remote/topsdkSign.js";
3
- import {
4
- buildTopSdkGetSdkConfigUrl,
5
- defaultTopSdkBaseUrl,
6
- filterTopSdkAuthTypesForRequest,
7
- resolveAuthTypesForGetSdkConfigRequest,
8
- } from "../src/remote/topsdkGetSdkConfig.js";
9
-
10
- describe("TOPSDK getSDKConfig client", () => {
11
- it("matches topsdk-tool-ios md5_base64_byte signing", () => {
12
- const sign = topsdkMd5Base64Sign("testApp", "secret", 1700000000000);
13
- expect(sign).toBe("Fww7ophf9iCbLC+Rj9rQ5w==");
14
- });
15
-
16
- it("filters auth types like ChannelConfigManager", () => {
17
- expect(filterTopSdkAuthTypesForRequest(["GUEST", "GOOGLE", "UI", "FACEBOOK", "IAPPAY"])).toEqual([
18
- "GOOGLE",
19
- "FACEBOOK",
20
- ]);
21
- });
22
-
23
- it("resolveAuthTypesForGetSdkConfigRequest uses discovery when explicit list is empty", () => {
24
- const r = resolveAuthTypesForGetSdkConfigRequest([]);
25
- expect(r).toContain("FACEBOOK");
26
- expect(r).toContain("GOOGLE");
27
- expect(r).not.toContain("GUEST");
28
- });
29
-
30
- it("builds GET URL with repeated authType query keys", () => {
31
- const { url } = buildTopSdkGetSdkConfigUrl({
32
- baseUrl: "https://pre-api-sdk-gameplus.meetsocial.com/",
33
- appId: "a",
34
- appSecret: "b",
35
- authTypes: ["GOOGLE", "FACEBOOK"],
36
- channelType: "google",
37
- timestampMillis: 99,
38
- });
39
- const u = new URL(url);
40
- expect(u.pathname).toContain("getSDKConfig");
41
- expect(u.searchParams.getAll("authType")).toEqual(["GOOGLE", "FACEBOOK"]);
42
- expect(u.searchParams.get("channelType")).toBe("google");
43
- expect(u.searchParams.get("appId")).toBe("a");
44
- expect(u.searchParams.get("timestamp")).toBe("99");
45
- expect(u.searchParams.get("sign")).toBeTruthy();
46
- });
47
-
48
- it("defaultTopSdkBaseUrl: prod / pre / test hosts", () => {
49
- expect(defaultTopSdkBaseUrl("prod")).toBe("https://api-sdk-gameplus.meetsocial.com/");
50
- expect(defaultTopSdkBaseUrl("pre")).toBe("https://pre-api-sdk-gameplus.meetsocial.com/");
51
- expect(defaultTopSdkBaseUrl("test")).toBe("https://test-api-sdk-gameplus.meetsocial.com/");
52
- });
53
- });