postproxy-mcp 0.1.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/LICENSE +21 -0
- package/README.md +635 -0
- package/dist/api/client.d.ts +71 -0
- package/dist/api/client.d.ts.map +1 -0
- package/dist/api/client.js +432 -0
- package/dist/api/client.js.map +1 -0
- package/dist/auth/credentials.d.ts +19 -0
- package/dist/auth/credentials.d.ts.map +1 -0
- package/dist/auth/credentials.js +40 -0
- package/dist/auth/credentials.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +44 -0
- package/dist/index.js.map +1 -0
- package/dist/server.d.ts +162 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +220 -0
- package/dist/server.js.map +1 -0
- package/dist/setup-cli.d.ts +6 -0
- package/dist/setup-cli.d.ts.map +1 -0
- package/dist/setup-cli.js +10 -0
- package/dist/setup-cli.js.map +1 -0
- package/dist/setup.d.ts +8 -0
- package/dist/setup.d.ts.map +1 -0
- package/dist/setup.js +143 -0
- package/dist/setup.js.map +1 -0
- package/dist/tools/accounts.d.ts +11 -0
- package/dist/tools/accounts.d.ts.map +1 -0
- package/dist/tools/accounts.js +53 -0
- package/dist/tools/accounts.js.map +1 -0
- package/dist/tools/auth.d.ts +11 -0
- package/dist/tools/auth.d.ts.map +1 -0
- package/dist/tools/auth.js +35 -0
- package/dist/tools/auth.js.map +1 -0
- package/dist/tools/history.d.ts +13 -0
- package/dist/tools/history.d.ts.map +1 -0
- package/dist/tools/history.js +79 -0
- package/dist/tools/history.js.map +1 -0
- package/dist/tools/post.d.ts +44 -0
- package/dist/tools/post.d.ts.map +1 -0
- package/dist/tools/post.js +251 -0
- package/dist/tools/post.js.map +1 -0
- package/dist/tools/profiles.d.ts +11 -0
- package/dist/tools/profiles.d.ts.map +1 -0
- package/dist/tools/profiles.js +52 -0
- package/dist/tools/profiles.js.map +1 -0
- package/dist/types/index.d.ts +147 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +5 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/errors.d.ts +21 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +33 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/idempotency.d.ts +8 -0
- package/dist/utils/idempotency.d.ts.map +1 -0
- package/dist/utils/idempotency.js +23 -0
- package/dist/utils/idempotency.js.map +1 -0
- package/dist/utils/logger.d.ts +20 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +68 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/validation.d.ts +555 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/validation.js +145 -0
- package/dist/utils/validation.js.map +1 -0
- package/package.json +39 -0
- package/src/api/client.ts +497 -0
- package/src/auth/credentials.ts +43 -0
- package/src/index.ts +57 -0
- package/src/server.ts +235 -0
- package/src/setup-cli.ts +11 -0
- package/src/setup.ts +187 -0
- package/src/tools/auth.ts +45 -0
- package/src/tools/history.ts +89 -0
- package/src/tools/post.ts +338 -0
- package/src/tools/profiles.ts +69 -0
- package/src/types/index.ts +161 -0
- package/src/utils/errors.ts +38 -0
- package/src/utils/idempotency.ts +31 -0
- package/src/utils/logger.ts +75 -0
- package/src/utils/validation.ts +171 -0
- package/tsconfig.json +19 -0
- package/worker/index.ts +901 -0
- package/wrangler.toml +11 -0
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript types for PostProxy API responses and requests
|
|
3
|
+
*/
|
|
4
|
+
export interface ProfileGroup {
|
|
5
|
+
id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
profiles_count: number;
|
|
8
|
+
created_at?: string;
|
|
9
|
+
updated_at?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface Profile {
|
|
12
|
+
id: string;
|
|
13
|
+
name: string;
|
|
14
|
+
platform: string;
|
|
15
|
+
profile_group_id: string;
|
|
16
|
+
expires_at: string | null;
|
|
17
|
+
post_count: number;
|
|
18
|
+
username?: string;
|
|
19
|
+
avatar_url?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface CreatePostParams {
|
|
22
|
+
content: string;
|
|
23
|
+
profile_group_id?: number;
|
|
24
|
+
profiles: string[];
|
|
25
|
+
schedule?: string;
|
|
26
|
+
media?: string[];
|
|
27
|
+
idempotency_key?: string;
|
|
28
|
+
draft?: boolean;
|
|
29
|
+
platforms?: PlatformParams;
|
|
30
|
+
}
|
|
31
|
+
export interface CreatePostResponse {
|
|
32
|
+
id: string;
|
|
33
|
+
body?: string;
|
|
34
|
+
content?: string;
|
|
35
|
+
status: "draft" | "pending" | "processing" | "processed" | "scheduled";
|
|
36
|
+
draft: boolean;
|
|
37
|
+
scheduled_at: string | null;
|
|
38
|
+
created_at: string;
|
|
39
|
+
platforms: PlatformOutcome[];
|
|
40
|
+
}
|
|
41
|
+
export interface PlatformOutcome {
|
|
42
|
+
platform: string;
|
|
43
|
+
status: "pending" | "processing" | "published" | "failed" | "deleted";
|
|
44
|
+
params: Record<string, any>;
|
|
45
|
+
attempted_at: string | null;
|
|
46
|
+
insights?: {
|
|
47
|
+
impressions?: number;
|
|
48
|
+
on?: string;
|
|
49
|
+
[key: string]: any;
|
|
50
|
+
};
|
|
51
|
+
url?: string;
|
|
52
|
+
post_id?: string;
|
|
53
|
+
error?: string | null;
|
|
54
|
+
}
|
|
55
|
+
export interface PostDetails {
|
|
56
|
+
id: string;
|
|
57
|
+
body?: string;
|
|
58
|
+
content?: string;
|
|
59
|
+
status: "draft" | "pending" | "processing" | "processed" | "scheduled";
|
|
60
|
+
draft: boolean;
|
|
61
|
+
scheduled_at: string | null;
|
|
62
|
+
created_at: string;
|
|
63
|
+
updated_at?: string;
|
|
64
|
+
platforms: PlatformOutcome[];
|
|
65
|
+
}
|
|
66
|
+
export interface Post {
|
|
67
|
+
id: string;
|
|
68
|
+
body?: string;
|
|
69
|
+
content?: string;
|
|
70
|
+
status: "draft" | "pending" | "processing" | "processed" | "scheduled";
|
|
71
|
+
draft: boolean;
|
|
72
|
+
scheduled_at: string | null;
|
|
73
|
+
created_at: string;
|
|
74
|
+
updated_at?: string;
|
|
75
|
+
platforms: PlatformOutcome[];
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Platform-specific parameters for Instagram
|
|
79
|
+
*/
|
|
80
|
+
export interface InstagramParams {
|
|
81
|
+
format?: "post" | "reel" | "story";
|
|
82
|
+
collaborators?: string[];
|
|
83
|
+
first_comment?: string;
|
|
84
|
+
cover_url?: string;
|
|
85
|
+
audio_name?: string;
|
|
86
|
+
trial_strategy?: "MANUAL" | "SS_PERFORMANCE";
|
|
87
|
+
thumb_offset?: string;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Platform-specific parameters for YouTube
|
|
91
|
+
*/
|
|
92
|
+
export interface YouTubeParams {
|
|
93
|
+
title?: string;
|
|
94
|
+
privacy_status?: "public" | "unlisted" | "private";
|
|
95
|
+
cover_url?: string;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Platform-specific parameters for TikTok
|
|
99
|
+
*/
|
|
100
|
+
export interface TikTokParams {
|
|
101
|
+
privacy_status?: "PUBLIC_TO_EVERYONE" | "MUTUAL_FOLLOW_FRIENDS" | "FOLLOWER_OF_CREATOR" | "SELF_ONLY";
|
|
102
|
+
photo_cover_index?: number;
|
|
103
|
+
auto_add_music?: boolean;
|
|
104
|
+
made_with_ai?: boolean;
|
|
105
|
+
disable_comment?: boolean;
|
|
106
|
+
disable_duet?: boolean;
|
|
107
|
+
disable_stitch?: boolean;
|
|
108
|
+
brand_content_toggle?: boolean;
|
|
109
|
+
brand_organic_toggle?: boolean;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Platform-specific parameters for Facebook
|
|
113
|
+
*/
|
|
114
|
+
export interface FacebookParams {
|
|
115
|
+
format?: "post" | "story";
|
|
116
|
+
first_comment?: string;
|
|
117
|
+
page_id?: string;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Platform-specific parameters for LinkedIn
|
|
121
|
+
*/
|
|
122
|
+
export interface LinkedInParams {
|
|
123
|
+
organization_id?: string;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Platform-specific parameters for Twitter/X
|
|
127
|
+
* Note: Twitter/X does not have platform-specific parameters
|
|
128
|
+
*/
|
|
129
|
+
export type TwitterParams = Record<string, never>;
|
|
130
|
+
/**
|
|
131
|
+
* Platform-specific parameters for Threads
|
|
132
|
+
* Note: Threads does not have platform-specific parameters
|
|
133
|
+
*/
|
|
134
|
+
export type ThreadsParams = Record<string, never>;
|
|
135
|
+
/**
|
|
136
|
+
* Union type for all platform-specific parameters
|
|
137
|
+
*/
|
|
138
|
+
export interface PlatformParams {
|
|
139
|
+
instagram?: InstagramParams;
|
|
140
|
+
youtube?: YouTubeParams;
|
|
141
|
+
tiktok?: TikTokParams;
|
|
142
|
+
facebook?: FacebookParams;
|
|
143
|
+
linkedin?: LinkedInParams;
|
|
144
|
+
twitter?: TwitterParams;
|
|
145
|
+
threads?: ThreadsParams;
|
|
146
|
+
}
|
|
147
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,E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AAE,aAAa,CAAC;IACxB,OAAO,CAAC,EAAE,aAAa,CAAC;CACzB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error handling utilities for MCP server
|
|
3
|
+
*/
|
|
4
|
+
export declare class MCPError extends Error {
|
|
5
|
+
code: string;
|
|
6
|
+
details?: any | undefined;
|
|
7
|
+
constructor(code: string, message: string, details?: any | undefined);
|
|
8
|
+
}
|
|
9
|
+
export declare const ErrorCodes: {
|
|
10
|
+
readonly AUTH_MISSING: "AUTH_MISSING";
|
|
11
|
+
readonly AUTH_INVALID: "AUTH_INVALID";
|
|
12
|
+
readonly VALIDATION_ERROR: "VALIDATION_ERROR";
|
|
13
|
+
readonly TARGET_NOT_FOUND: "TARGET_NOT_FOUND";
|
|
14
|
+
readonly PUBLISH_FAILED: "PUBLISH_FAILED";
|
|
15
|
+
readonly PLATFORM_ERROR: "PLATFORM_ERROR";
|
|
16
|
+
readonly API_ERROR: "API_ERROR";
|
|
17
|
+
};
|
|
18
|
+
export type ErrorCode = typeof ErrorCodes[keyof typeof ErrorCodes];
|
|
19
|
+
export declare function formatError(error: Error, code: ErrorCode, details?: any): MCPError;
|
|
20
|
+
export declare function createError(code: ErrorCode, message: string, details?: any): MCPError;
|
|
21
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,qBAAa,QAAS,SAAQ,KAAK;IAExB,IAAI,EAAE,MAAM;IAEZ,OAAO,CAAC,EAAE,GAAG;gBAFb,IAAI,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,EACR,OAAO,CAAC,EAAE,GAAG,YAAA;CAMvB;AAED,eAAO,MAAM,UAAU;;;;;;;;CAQb,CAAC;AAEX,MAAM,MAAM,SAAS,GAAG,OAAO,UAAU,CAAC,MAAM,OAAO,UAAU,CAAC,CAAC;AAEnE,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,GAAG,GAAG,QAAQ,CAKlF;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,GAAG,QAAQ,CAErF"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error handling utilities for MCP server
|
|
3
|
+
*/
|
|
4
|
+
export class MCPError extends Error {
|
|
5
|
+
code;
|
|
6
|
+
details;
|
|
7
|
+
constructor(code, message, details) {
|
|
8
|
+
super(message);
|
|
9
|
+
this.code = code;
|
|
10
|
+
this.details = details;
|
|
11
|
+
this.name = "MCPError";
|
|
12
|
+
Object.setPrototypeOf(this, MCPError.prototype);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export const ErrorCodes = {
|
|
16
|
+
AUTH_MISSING: "AUTH_MISSING",
|
|
17
|
+
AUTH_INVALID: "AUTH_INVALID",
|
|
18
|
+
VALIDATION_ERROR: "VALIDATION_ERROR",
|
|
19
|
+
TARGET_NOT_FOUND: "TARGET_NOT_FOUND",
|
|
20
|
+
PUBLISH_FAILED: "PUBLISH_FAILED",
|
|
21
|
+
PLATFORM_ERROR: "PLATFORM_ERROR",
|
|
22
|
+
API_ERROR: "API_ERROR",
|
|
23
|
+
};
|
|
24
|
+
export function formatError(error, code, details) {
|
|
25
|
+
if (error instanceof MCPError) {
|
|
26
|
+
return error;
|
|
27
|
+
}
|
|
28
|
+
return new MCPError(code, error.message || "An error occurred", details);
|
|
29
|
+
}
|
|
30
|
+
export function createError(code, message, details) {
|
|
31
|
+
return new MCPError(code, message, details);
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,OAAO,QAAS,SAAQ,KAAK;IAExB;IAEA;IAHT,YACS,IAAY,EACnB,OAAe,EACR,OAAa;QAEpB,KAAK,CAAC,OAAO,CAAC,CAAC;QAJR,SAAI,GAAJ,IAAI,CAAQ;QAEZ,YAAO,GAAP,OAAO,CAAM;QAGpB,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;QACvB,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAC;IAClD,CAAC;CACF;AAED,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,YAAY,EAAE,cAAc;IAC5B,YAAY,EAAE,cAAc;IAC5B,gBAAgB,EAAE,kBAAkB;IACpC,gBAAgB,EAAE,kBAAkB;IACpC,cAAc,EAAE,gBAAgB;IAChC,cAAc,EAAE,gBAAgB;IAChC,SAAS,EAAE,WAAW;CACd,CAAC;AAIX,MAAM,UAAU,WAAW,CAAC,KAAY,EAAE,IAAe,EAAE,OAAa;IACtE,IAAI,KAAK,YAAY,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,IAAI,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,OAAO,IAAI,mBAAmB,EAAE,OAAO,CAAC,CAAC;AAC3E,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,IAAe,EAAE,OAAe,EAAE,OAAa;IACzE,OAAO,IAAI,QAAQ,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;AAC9C,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Idempotency key generation utilities
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Generate an idempotency key from normalized post data
|
|
6
|
+
*/
|
|
7
|
+
export declare function generateIdempotencyKey(content: string, targets: string[], schedule?: string): string;
|
|
8
|
+
//# sourceMappingURL=idempotency.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"idempotency.d.ts","sourceRoot":"","sources":["../../src/utils/idempotency.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EAAE,EACjB,QAAQ,CAAC,EAAE,MAAM,GAChB,MAAM,CAiBR"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Idempotency key generation utilities
|
|
3
|
+
*/
|
|
4
|
+
import { createHash } from "crypto";
|
|
5
|
+
/**
|
|
6
|
+
* Generate an idempotency key from normalized post data
|
|
7
|
+
*/
|
|
8
|
+
export function generateIdempotencyKey(content, targets, schedule) {
|
|
9
|
+
// Normalize input data
|
|
10
|
+
const normalizedContent = content.trim();
|
|
11
|
+
const normalizedTargets = [...targets].sort();
|
|
12
|
+
const normalizedSchedule = schedule || "";
|
|
13
|
+
// Create a JSON string from normalized data
|
|
14
|
+
const data = JSON.stringify({
|
|
15
|
+
content: normalizedContent,
|
|
16
|
+
targets: normalizedTargets,
|
|
17
|
+
schedule: normalizedSchedule,
|
|
18
|
+
});
|
|
19
|
+
// Generate SHA256 hash
|
|
20
|
+
const hash = createHash("sha256").update(data).digest("hex");
|
|
21
|
+
return hash;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=idempotency.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"idempotency.js","sourceRoot":"","sources":["../../src/utils/idempotency.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEpC;;GAEG;AACH,MAAM,UAAU,sBAAsB,CACpC,OAAe,EACf,OAAiB,EACjB,QAAiB;IAEjB,uBAAuB;IACvB,MAAM,iBAAiB,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IACzC,MAAM,iBAAiB,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC;IAC9C,MAAM,kBAAkB,GAAG,QAAQ,IAAI,EAAE,CAAC;IAE1C,4CAA4C;IAC5C,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC;QAC1B,OAAO,EAAE,iBAAiB;QAC1B,OAAO,EAAE,iBAAiB;QAC1B,QAAQ,EAAE,kBAAkB;KAC7B,CAAC,CAAC;IAEH,uBAAuB;IACvB,MAAM,IAAI,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAE7D,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Secure logging utilities that sanitize sensitive data
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Sanitize data for logging by removing sensitive fields
|
|
6
|
+
*/
|
|
7
|
+
export declare function sanitizeForLog(data: any): any;
|
|
8
|
+
/**
|
|
9
|
+
* Log a message to stderr
|
|
10
|
+
*/
|
|
11
|
+
export declare function log(message: string, ...args: any[]): void;
|
|
12
|
+
/**
|
|
13
|
+
* Log a tool call (without sensitive data)
|
|
14
|
+
*/
|
|
15
|
+
export declare function logToolCall(toolName: string, params: any): void;
|
|
16
|
+
/**
|
|
17
|
+
* Log an error
|
|
18
|
+
*/
|
|
19
|
+
export declare function logError(error: Error, context?: string): void;
|
|
20
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;GAEG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,GAAG,GAAG,GAAG,CAqC7C;AAED;;GAEG;AACH,wBAAgB,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAGzD;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,GAAG,IAAI,CAI/D;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAM7D"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Secure logging utilities that sanitize sensitive data
|
|
3
|
+
*/
|
|
4
|
+
const DEBUG = process.env.POSTPROXY_MCP_DEBUG === "1";
|
|
5
|
+
/**
|
|
6
|
+
* Sanitize data for logging by removing sensitive fields
|
|
7
|
+
*/
|
|
8
|
+
export function sanitizeForLog(data) {
|
|
9
|
+
if (data === null || data === undefined) {
|
|
10
|
+
return data;
|
|
11
|
+
}
|
|
12
|
+
if (typeof data !== "object") {
|
|
13
|
+
return data;
|
|
14
|
+
}
|
|
15
|
+
if (Array.isArray(data)) {
|
|
16
|
+
return data.map(sanitizeForLog);
|
|
17
|
+
}
|
|
18
|
+
const sanitized = {};
|
|
19
|
+
const sensitiveKeys = [
|
|
20
|
+
"apiKey",
|
|
21
|
+
"api_key",
|
|
22
|
+
"api-key",
|
|
23
|
+
"authorization",
|
|
24
|
+
"token",
|
|
25
|
+
"password",
|
|
26
|
+
"secret",
|
|
27
|
+
"POSTPROXY_API_KEY",
|
|
28
|
+
];
|
|
29
|
+
for (const [key, value] of Object.entries(data)) {
|
|
30
|
+
const lowerKey = key.toLowerCase();
|
|
31
|
+
if (sensitiveKeys.some((sk) => lowerKey.includes(sk.toLowerCase()))) {
|
|
32
|
+
sanitized[key] = "[REDACTED]";
|
|
33
|
+
}
|
|
34
|
+
else if (typeof value === "object") {
|
|
35
|
+
sanitized[key] = sanitizeForLog(value);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
sanitized[key] = value;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return sanitized;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Log a message to stderr
|
|
45
|
+
*/
|
|
46
|
+
export function log(message, ...args) {
|
|
47
|
+
const sanitizedArgs = args.map(sanitizeForLog);
|
|
48
|
+
console.error(`[postproxy-mcp] ${message}`, ...sanitizedArgs);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Log a tool call (without sensitive data)
|
|
52
|
+
*/
|
|
53
|
+
export function logToolCall(toolName, params) {
|
|
54
|
+
if (DEBUG) {
|
|
55
|
+
log(`Tool call: ${toolName}`, sanitizeForLog(params));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Log an error
|
|
60
|
+
*/
|
|
61
|
+
export function logError(error, context) {
|
|
62
|
+
const contextMsg = context ? `[${context}] ` : "";
|
|
63
|
+
log(`Error ${contextMsg}${error.message}`, error);
|
|
64
|
+
if (DEBUG && error.stack) {
|
|
65
|
+
log("Stack trace:", error.stack);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,mBAAmB,KAAK,GAAG,CAAC;AAEtD;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,IAAS;IACtC,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACxC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,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