@mikoto_zero/minigame-open-mcp 1.0.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.
@@ -0,0 +1,576 @@
1
+ /**
2
+ * TapTap Minigame Leaderboard API Documentation
3
+ * Based on: https://developer.taptap.cn/minigameapidoc/dev/api/open-api/leaderboard/
4
+ */
5
+ export const LEADERBOARD_DOCUMENTATION = {
6
+ title: "TapTap Minigame Leaderboard API",
7
+ description: "Complete leaderboard functionality for TapTap minigames, including score submission, ranking queries, and leaderboard display.",
8
+ apiReference: "https://developer.taptap.cn/minigameapidoc/dev/api/open-api/leaderboard/",
9
+ categories: {
10
+ initialization: {
11
+ title: "Initialization",
12
+ description: "Get the LeaderboardManager instance",
13
+ apis: [
14
+ {
15
+ name: "tap.getLeaderboardManager",
16
+ method: "tap.getLeaderboardManager()",
17
+ description: "Get the LeaderboardManager instance to access leaderboard functionality",
18
+ returnValue: "LeaderboardManager - The leaderboard manager instance",
19
+ example: `// Get LeaderboardManager instance
20
+ const leaderboardManager = tap.getLeaderboardManager();
21
+
22
+ // Now you can use leaderboardManager to call various methods
23
+ leaderboardManager.openLeaderboard();`
24
+ }
25
+ ]
26
+ },
27
+ display: {
28
+ title: "Display Leaderboard",
29
+ description: "Open and display the leaderboard UI page",
30
+ apis: [
31
+ {
32
+ name: "openLeaderboard",
33
+ method: "leaderboardManager.openLeaderboard(leaderboardId, collection, callback)",
34
+ description: "Opens TapTap's leaderboard page, displaying total and friend leaderboards for the specified leaderboard ID",
35
+ parameters: {
36
+ "leaderboardId": "string (required) - Unique identifier for the leaderboard",
37
+ "collection": "string (optional) - Leaderboard type: 'friends' for friend rankings or 'public' (default) for global rankings",
38
+ "callback.onSuccess": "function (optional) - Success callback function",
39
+ "callback.onFailure": "function (optional) - Failure callback with (code, message) parameters"
40
+ },
41
+ returnValue: "void - Opens native leaderboard UI",
42
+ example: `// Open leaderboard UI
43
+ const leaderboardManager = tap.getLeaderboardManager();
44
+
45
+ // Open global leaderboard
46
+ leaderboardManager.openLeaderboard({
47
+ leaderboardId: "weekly_high_score",
48
+ collection: "public",
49
+ callback: {
50
+ onSuccess: function(res) {
51
+ console.log("Leaderboard opened successfully:", res);
52
+ },
53
+ onFailure: function(code, message) {
54
+ console.error(\`Failed to open leaderboard: code=\${code}, message=\${message}\`);
55
+ // Error codes:
56
+ // 500001: Leaderboard ID not found
57
+ // 1025: Friend relationship permissions not declared
58
+ // 104/103: User privacy/authorization issues
59
+ }
60
+ }
61
+ });
62
+
63
+ // Open friend leaderboard
64
+ leaderboardManager.openLeaderboard({
65
+ leaderboardId: "friend_ranking",
66
+ collection: "friends",
67
+ callback: {
68
+ onSuccess: function(res) {
69
+ console.log("Friend leaderboard opened");
70
+ },
71
+ onFailure: function(code, message) {
72
+ console.error("Failed:", message);
73
+ }
74
+ }
75
+ });`
76
+ }
77
+ ]
78
+ },
79
+ score_submission: {
80
+ title: "Score Submission",
81
+ description: "Submit player scores to leaderboards",
82
+ apis: [
83
+ {
84
+ name: "submitScores",
85
+ method: "leaderboardManager.submitScores(scores, callback)",
86
+ description: "Batch submit user leaderboard scores. Maximum of 5 scores can be submitted at once.",
87
+ parameters: {
88
+ "scores": "Array<ScoreEntry> (required) - Array of score entries to submit, maximum 5 entries",
89
+ "scores[].leaderboardId": "string (required) - Unique identifier for the leaderboard",
90
+ "scores[].score": "number (required) - Integer score value to submit",
91
+ "callback.onSuccess": "function (optional) - Success callback function",
92
+ "callback.onFailure": "function (optional) - Failure callback with (code, message) parameters"
93
+ },
94
+ returnValue: "void - Submission result is returned via callback",
95
+ example: `// Submit scores to multiple leaderboards
96
+ const leaderboardManager = tap.getLeaderboardManager();
97
+
98
+ leaderboardManager.submitScores({
99
+ scores: [
100
+ {
101
+ leaderboardId: "leaderboard_1",
102
+ score: 1000
103
+ },
104
+ {
105
+ leaderboardId: "leaderboard_2",
106
+ score: 2000
107
+ }
108
+ ],
109
+ callback: {
110
+ onSuccess: function(res) {
111
+ console.log("submitScores success:", res);
112
+ },
113
+ onFailure: function(code, message) {
114
+ console.error(\`submitScores failed: \${code}, \${message}\`);
115
+ // Error codes:
116
+ // 500001: Leaderboard ID not found
117
+ // 500002: Leaderboard parameter error
118
+ // 500199: Invalid number of score entries (exceeds 5)
119
+ }
120
+ }
121
+ });
122
+
123
+ // Submit single score
124
+ leaderboardManager.submitScores({
125
+ scores: [
126
+ {
127
+ leaderboardId: "weekly_high_score",
128
+ score: 15000
129
+ }
130
+ ],
131
+ callback: {
132
+ onSuccess: function(res) {
133
+ console.log("Score submitted successfully");
134
+ },
135
+ onFailure: function(code, message) {
136
+ console.error("Failed to submit score:", message);
137
+ }
138
+ }
139
+ });`
140
+ }
141
+ ]
142
+ },
143
+ score_query: {
144
+ title: "Score Query",
145
+ description: "Query leaderboard scores and rankings",
146
+ apis: [
147
+ {
148
+ name: "loadLeaderboardScores",
149
+ method: "leaderboardManager.loadLeaderboardScores(leaderboardId, collection, maxSize, continuationToken, periodToken, callback)",
150
+ description: "Retrieve paginated leaderboard data with support for friend and public rankings",
151
+ parameters: {
152
+ "leaderboardId": "string (required) - Unique identifier for the leaderboard",
153
+ "collection": "string (optional) - Leaderboard type: 'friends' or 'public' (default)",
154
+ "maxSize": "number (optional) - Limit results between 1-200 entries, default 200",
155
+ "continuationToken": "string (optional) - Token for pagination to get next page",
156
+ "periodToken": "string (optional) - Time period identifier for the leaderboard",
157
+ "callback.onSuccess": "function (optional) - Success callback function",
158
+ "callback.onFailure": "function (optional) - Failure callback with (code, message) parameters"
159
+ },
160
+ returnValue: "void - Leaderboard data is returned via callback including scores list and pagination details",
161
+ example: `// Load top scores from a leaderboard
162
+ const leaderboardManager = tap.getLeaderboardManager();
163
+
164
+ leaderboardManager.loadLeaderboardScores({
165
+ leaderboardId: "your_leaderboardId",
166
+ collection: "friends",
167
+ maxSize: 10,
168
+ callback: {
169
+ onSuccess: function(res) {
170
+ console.log("Leaderboard scores:", res);
171
+ // res contains:
172
+ // - leaderboard info
173
+ // - scores list
174
+ // - next continuation token for pagination
175
+ // - isTruncated flag
176
+ },
177
+ onFailure: function(code, message) {
178
+ console.error("Load failed:", message);
179
+ }
180
+ }
181
+ });
182
+
183
+ // Load global leaderboard with pagination
184
+ let continuationToken = null;
185
+
186
+ function loadNextPage() {
187
+ leaderboardManager.loadLeaderboardScores({
188
+ leaderboardId: "weekly_high_score",
189
+ collection: "public",
190
+ maxSize: 50,
191
+ continuationToken: continuationToken,
192
+ callback: {
193
+ onSuccess: function(res) {
194
+ console.log("Page loaded:", res.scores.length, "entries");
195
+
196
+ // Check if there are more pages
197
+ if (res.isTruncated) {
198
+ continuationToken = res.continuationToken;
199
+ // Can load next page with the new token
200
+ }
201
+ },
202
+ onFailure: function(code, message) {
203
+ console.error("Failed to load page:", message);
204
+ }
205
+ }
206
+ });
207
+ }`
208
+ },
209
+ {
210
+ name: "loadCurrentPlayerLeaderboardScore",
211
+ method: "leaderboardManager.loadCurrentPlayerLeaderboardScore(leaderboardId, collection, periodToken, callback)",
212
+ description: "Get the current user's score and ranking position in the specified leaderboard. Requires user to have submitted a score to this leaderboard.",
213
+ parameters: {
214
+ "leaderboardId": "string (required) - Unique identifier for the leaderboard",
215
+ "collection": "string (optional) - Leaderboard type: 'friends' or 'public' (default)",
216
+ "periodToken": "string (optional) - Time period identifier for the leaderboard",
217
+ "callback.onSuccess": "function (optional) - Success callback function",
218
+ "callback.onFailure": "function (optional) - Failure callback with (code, message) parameters"
219
+ },
220
+ returnValue: "void - Current player's score data is returned via callback",
221
+ example: `// Get current player's ranking
222
+ const leaderboardManager = tap.getLeaderboardManager();
223
+
224
+ leaderboardManager.loadCurrentPlayerLeaderboardScore({
225
+ leaderboardId: "weekly_high_score",
226
+ collection: "public",
227
+ callback: {
228
+ onSuccess: function(res) {
229
+ console.log("Your score:", res.score);
230
+ console.log("Your rank:", res.rank);
231
+ console.log("Leaderboard:", res.leaderboard);
232
+ },
233
+ onFailure: function(code, message) {
234
+ console.error("Failed to load player score:", message);
235
+ }
236
+ }
237
+ });
238
+
239
+ // Get friend leaderboard ranking
240
+ leaderboardManager.loadCurrentPlayerLeaderboardScore({
241
+ leaderboardId: "friend_ranking",
242
+ collection: "friends",
243
+ callback: {
244
+ onSuccess: function(res) {
245
+ console.log("Your rank among friends:", res.rank);
246
+ },
247
+ onFailure: function(code, message) {
248
+ console.error("Failed:", message);
249
+ }
250
+ }
251
+ });`
252
+ },
253
+ {
254
+ name: "loadPlayerCenteredScores",
255
+ method: "leaderboardManager.loadPlayerCenteredScores(leaderboardId, collection, maxCount, periodToken, callback)",
256
+ description: "Retrieve scores for the current user and nearby players on a leaderboard, useful for showing surrounding competitors",
257
+ parameters: {
258
+ "leaderboardId": "string (required) - Unique identifier for the leaderboard",
259
+ "collection": "string (optional) - Leaderboard type: 'friends' or 'public' (default)",
260
+ "maxCount": "number (optional) - Limit results between 1-25 players",
261
+ "periodToken": "string (optional) - Time period identifier for the leaderboard",
262
+ "callback.onSuccess": "function (optional) - Success callback function",
263
+ "callback.onFailure": "function (optional) - Failure callback with (code, message) parameters"
264
+ },
265
+ returnValue: "void - Nearby players' scores are returned via callback",
266
+ example: `// Load nearby players' scores
267
+ const leaderboardManager = tap.getLeaderboardManager();
268
+
269
+ leaderboardManager.loadPlayerCenteredScores({
270
+ leaderboardId: "your_leaderboardId",
271
+ collection: "friends",
272
+ maxCount: 10,
273
+ callback: {
274
+ onSuccess: function(res) {
275
+ console.log("Players around you:", res);
276
+ // res contains current player and nearby players' scores
277
+ res.scores.forEach(score => {
278
+ const marker = score.isCurrentPlayer ? '👉' : ' ';
279
+ console.log(\`\${marker} Rank #\${score.rank}: \${score.playerName} - \${score.score}\`);
280
+ });
281
+ },
282
+ onFailure: function(code, message) {
283
+ console.error("Failed to load nearby scores:", message);
284
+ }
285
+ }
286
+ });
287
+
288
+ // Load surrounding players on global leaderboard
289
+ leaderboardManager.loadPlayerCenteredScores({
290
+ leaderboardId: "global_ranking",
291
+ collection: "public",
292
+ maxCount: 20,
293
+ callback: {
294
+ onSuccess: function(res) {
295
+ console.log("Loaded", res.scores.length, "players around you");
296
+ },
297
+ onFailure: function(code, message) {
298
+ console.error("Failed:", message);
299
+ }
300
+ }
301
+ });`
302
+ }
303
+ ]
304
+ },
305
+ common_scenarios: {
306
+ title: "Common Implementation Scenarios",
307
+ description: "Complete examples for typical use cases",
308
+ apis: [
309
+ {
310
+ name: "Complete Game Flow",
311
+ method: "N/A",
312
+ description: "Example of integrating leaderboard into a complete game flow",
313
+ example: `// Complete leaderboard integration example
314
+ const leaderboardManager = tap.getLeaderboardManager();
315
+
316
+ // 1. After game ends, submit score
317
+ async function submitGameScore(finalScore) {
318
+ try {
319
+ await leaderboardManager.submitScores([{
320
+ leaderboardName: 'daily_ranking',
321
+ score: finalScore,
322
+ extraInfo: JSON.stringify({
323
+ timestamp: Date.now(),
324
+ gameMode: 'classic'
325
+ })
326
+ }]);
327
+ console.log('Score submitted!');
328
+ return true;
329
+ } catch (error) {
330
+ console.error('Submit failed:', error);
331
+ return false;
332
+ }
333
+ }
334
+
335
+ // 2. Show player's ranking after submission
336
+ async function showPlayerRanking() {
337
+ try {
338
+ const playerScore = await leaderboardManager.loadCurrentPlayerLeaderboardScore('daily_ranking');
339
+
340
+ // Display ranking to player
341
+ showMessage(\`Your rank: #\${playerScore.rank}\`);
342
+ showMessage(\`Your score: \${playerScore.score}\`);
343
+
344
+ // Show if player improved
345
+ if (playerScore.previousRank && playerScore.rank < playerScore.previousRank) {
346
+ showMessage(\`🎉 You moved up \${playerScore.previousRank - playerScore.rank} positions!\`);
347
+ }
348
+ } catch (error) {
349
+ console.error('Failed to get ranking:', error);
350
+ }
351
+ }
352
+
353
+ // 3. Display nearby competitors
354
+ async function showNearbyPlayers() {
355
+ try {
356
+ const nearby = await leaderboardManager.loadPlayerCenteredScores('daily_ranking', {
357
+ before: 3,
358
+ after: 3
359
+ });
360
+
361
+ // Render leaderboard UI
362
+ renderLeaderboard(nearby.entries);
363
+ } catch (error) {
364
+ console.error('Failed to load nearby players:', error);
365
+ }
366
+ }
367
+
368
+ // 4. Open full leaderboard when player clicks "View All"
369
+ function openFullLeaderboard() {
370
+ leaderboardManager.openLeaderboard();
371
+ }
372
+
373
+ // Complete flow
374
+ async function handleGameEnd(finalScore) {
375
+ const submitted = await submitGameScore(finalScore);
376
+ if (submitted) {
377
+ await showPlayerRanking();
378
+ await showNearbyPlayers();
379
+ }
380
+ }
381
+ `
382
+ },
383
+ {
384
+ name: "Pagination Example",
385
+ method: "N/A",
386
+ description: "Example of implementing paginated leaderboard browsing",
387
+ example: `// Paginated leaderboard implementation
388
+ class LeaderboardView {
389
+ constructor() {
390
+ this.leaderboardManager = tap.getLeaderboardManager();
391
+ this.currentPage = 0;
392
+ this.pageSize = 20;
393
+ this.leaderboardName = 'global_ranking';
394
+ }
395
+
396
+ async loadPage(page) {
397
+ try {
398
+ const offset = page * this.pageSize;
399
+ const data = await this.leaderboardManager.loadLeaderboardScores(
400
+ this.leaderboardName,
401
+ {
402
+ offset: offset,
403
+ limit: this.pageSize
404
+ }
405
+ );
406
+
407
+ this.renderPage(data);
408
+ this.currentPage = page;
409
+
410
+ // Calculate total pages
411
+ const totalPages = Math.ceil(data.total / this.pageSize);
412
+ this.updatePagination(page, totalPages);
413
+
414
+ return data;
415
+ } catch (error) {
416
+ console.error('Failed to load page:', error);
417
+ throw error;
418
+ }
419
+ }
420
+
421
+ async nextPage() {
422
+ await this.loadPage(this.currentPage + 1);
423
+ }
424
+
425
+ async previousPage() {
426
+ if (this.currentPage > 0) {
427
+ await this.loadPage(this.currentPage - 1);
428
+ }
429
+ }
430
+
431
+ renderPage(data) {
432
+ // Render leaderboard entries
433
+ const listElement = document.getElementById('leaderboard-list');
434
+ listElement.innerHTML = data.entries.map(entry => \`
435
+ <div class="leaderboard-entry">
436
+ <span class="rank">#\${entry.rank}</span>
437
+ <span class="player">\${entry.playerName}</span>
438
+ <span class="score">\${entry.score}</span>
439
+ </div>
440
+ \`).join('');
441
+ }
442
+
443
+ updatePagination(current, total) {
444
+ document.getElementById('page-info').textContent = \`Page \${current + 1} of \${total}\`;
445
+ document.getElementById('prev-btn').disabled = current === 0;
446
+ document.getElementById('next-btn').disabled = current === total - 1;
447
+ }
448
+ }
449
+
450
+ // Usage
451
+ const leaderboardView = new LeaderboardView();
452
+ leaderboardView.loadPage(0);
453
+ `
454
+ }
455
+ ]
456
+ }
457
+ }
458
+ };
459
+ /**
460
+ * Search leaderboard documentation by keyword
461
+ */
462
+ export function searchLeaderboardDocs(query, category) {
463
+ const results = [];
464
+ const lowerQuery = query.toLowerCase();
465
+ const categoriesToSearch = category
466
+ ? [LEADERBOARD_DOCUMENTATION.categories[category]]
467
+ : Object.values(LEADERBOARD_DOCUMENTATION.categories);
468
+ for (const cat of categoriesToSearch) {
469
+ if (!cat)
470
+ continue;
471
+ for (const api of cat.apis) {
472
+ const searchText = `${api.name} ${api.description} ${api.example}`.toLowerCase();
473
+ if (searchText.includes(lowerQuery)) {
474
+ results.push(`
475
+ ### ${api.name}
476
+
477
+ **Method:** \`${api.method}\`
478
+
479
+ **Description:** ${api.description}
480
+
481
+ ${api.parameters ? `**Parameters:**
482
+ ${Object.entries(api.parameters).map(([key, value]) => `- \`${key}\`: ${value}`).join('\n')}
483
+ ` : ''}
484
+
485
+ ${api.returnValue ? `**Returns:** ${api.returnValue}\n` : ''}
486
+
487
+ **Example:**
488
+ \`\`\`javascript
489
+ ${api.example}
490
+ \`\`\`
491
+ `);
492
+ }
493
+ }
494
+ }
495
+ return results;
496
+ }
497
+ /**
498
+ * Get overview of leaderboard system
499
+ */
500
+ export function getLeaderboardOverview() {
501
+ return `# ${LEADERBOARD_DOCUMENTATION.title}
502
+
503
+ ${LEADERBOARD_DOCUMENTATION.description}
504
+
505
+ **Official API Reference:** ${LEADERBOARD_DOCUMENTATION.apiReference}
506
+
507
+ ## Available Categories
508
+
509
+ ${Object.entries(LEADERBOARD_DOCUMENTATION.categories).map(([key, cat]) => `
510
+ ### ${cat.title}
511
+ ${cat.description}
512
+
513
+ Available methods: ${cat.apis.map(api => `\`${api.name}\``).join(', ')}
514
+ `).join('\n')}
515
+
516
+ ## Quick Start
517
+
518
+ \`\`\`javascript
519
+ // 1. Get LeaderboardManager instance
520
+ const leaderboardManager = tap.getLeaderboardManager();
521
+
522
+ // 2. Submit a score
523
+ await leaderboardManager.submitScores([{
524
+ leaderboardName: 'my_leaderboard',
525
+ score: 1000
526
+ }]);
527
+
528
+ // 3. Query current player's rank
529
+ const playerScore = await leaderboardManager.loadCurrentPlayerLeaderboardScore('my_leaderboard');
530
+ console.log('Your rank:', playerScore.rank);
531
+
532
+ // 4. Open leaderboard UI
533
+ leaderboardManager.openLeaderboard();
534
+ \`\`\`
535
+ `;
536
+ }
537
+ /**
538
+ * Get detailed documentation for a specific category
539
+ */
540
+ export function getCategoryDocs(category) {
541
+ const cat = LEADERBOARD_DOCUMENTATION.categories[category];
542
+ if (!cat) {
543
+ return `Category "${category}" not found. Available categories: ${Object.keys(LEADERBOARD_DOCUMENTATION.categories).join(', ')}`;
544
+ }
545
+ return `# ${cat.title}
546
+
547
+ ${cat.description}
548
+
549
+ ${cat.apis.map(api => `
550
+ ## ${api.name}
551
+
552
+ **Method:** \`${api.method}\`
553
+
554
+ **Description:** ${api.description}
555
+
556
+ ${api.parameters ? `### Parameters
557
+
558
+ ${Object.entries(api.parameters).map(([key, value]) => `- **\`${key}\`**: ${value}`).join('\n')}
559
+ ` : ''}
560
+
561
+ ${api.returnValue ? `### Returns
562
+
563
+ ${api.returnValue}
564
+ ` : ''}
565
+
566
+ ### Example
567
+
568
+ \`\`\`javascript
569
+ ${api.example}
570
+ \`\`\`
571
+
572
+ ---
573
+ `).join('\n')}
574
+ `;
575
+ }
576
+ //# sourceMappingURL=leaderboardDocs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"leaderboardDocs.js","sourceRoot":"","sources":["../../src/data/leaderboardDocs.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAwBH,MAAM,CA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,MAAM,GAAG,GAAG,yBAAyB,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;IAC3D,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,OAAO,aAAa,QAAQ,sCAAsC,MAAM,CAAC,IAAI,CAAC,yBAAyB,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;IACnI,CAAC;IAED,OAAO,KAAK,GAAG,CAAC,KAAK;;EAErB,GAAG,CAAC,WAAW;;EAEf,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;KACjB,GAAG,CAAC,IAAI;;gBAEG,GAAG,CAAC,MAAM;;mBAEP,GAAG,CAAC,WAAW;;EAEhC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC;;EAEjB,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,SAAS,GAAG,SAAS,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;CAC9F,CAAC,CAAC,CAAC,EAAE;;EAEJ,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC;;EAElB,GAAG,CAAC,WAAW;CAChB,CAAC,CAAC,CAAC,EAAE;;;;;EAKJ,GAAG,CAAC,OAAO;;;;CAIZ,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;CACZ,CAAC;AACF,CAAC"}
@@ -0,0 +1,80 @@
1
+ /**
2
+ * HTTP Client for TapTap API Requests
3
+ * Handles authentication, request signing, headers, and error responses
4
+ */
5
+ /**
6
+ * Environment configuration
7
+ */
8
+ export declare class ApiConfig {
9
+ private static instance;
10
+ readonly userToken: string;
11
+ readonly clientId: string;
12
+ readonly clientSecret: string;
13
+ readonly apiBaseUrl: string;
14
+ readonly environment: 'rnd' | 'production';
15
+ private constructor();
16
+ private validateConfig;
17
+ static getInstance(): ApiConfig;
18
+ isConfigured(): boolean;
19
+ getConfigStatus(): Record<string, string>;
20
+ }
21
+ /**
22
+ * HTTP request options
23
+ */
24
+ export interface RequestOptions {
25
+ headers?: Record<string, string>;
26
+ body?: unknown;
27
+ params?: Record<string, string>;
28
+ timeout?: number;
29
+ }
30
+ /**
31
+ * HTTP response wrapper
32
+ */
33
+ export interface ApiResponse<T = unknown> {
34
+ success: boolean;
35
+ data?: T;
36
+ message?: string;
37
+ error?: string;
38
+ }
39
+ /**
40
+ * Generic HTTP Client for TapTap API
41
+ */
42
+ export declare class HttpClient {
43
+ private config;
44
+ constructor();
45
+ /**
46
+ * Make a GET request
47
+ */
48
+ get<T = unknown>(path: string, options?: RequestOptions): Promise<T>;
49
+ /**
50
+ * Make a POST request
51
+ */
52
+ post<T = unknown>(path: string, options?: RequestOptions): Promise<T>;
53
+ /**
54
+ * Generic request method with signature
55
+ */
56
+ private request;
57
+ /**
58
+ * Generate request signature
59
+ * Format: HMAC-SHA256(method + url + headers + body, CLIENT_SECRET)
60
+ */
61
+ private generateSignature;
62
+ /**
63
+ * Get headers part for signature
64
+ * Only includes X-Tap-* headers (excluding X-Tap-Sign)
65
+ */
66
+ private getHeadersPart;
67
+ /**
68
+ * Generate random string
69
+ */
70
+ private generateRandomString;
71
+ /**
72
+ * Get current environment
73
+ */
74
+ getEnvironment(): string;
75
+ /**
76
+ * Get API base URL
77
+ */
78
+ getBaseUrl(): string;
79
+ }
80
+ //# sourceMappingURL=httpClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"httpClient.d.ts","sourceRoot":"","sources":["../../src/network/httpClient.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH;;GAEG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAY;IAEnC,SAAgB,SAAS,EAAE,MAAM,CAAC;IAClC,SAAgB,QAAQ,EAAE,MAAM,CAAC;IACjC,SAAgB,YAAY,EAAE,MAAM,CAAC;IACrC,SAAgB,UAAU,EAAE,MAA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