@prmichaelsen/mcp-auth 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.
Files changed (43) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +195 -0
  3. package/dist/auth/base-provider.js +173 -0
  4. package/dist/auth/base-provider.js.map +7 -0
  5. package/dist/auth/index.js +11 -0
  6. package/dist/auth/index.js.map +7 -0
  7. package/dist/auth/providers/env-provider.js +71 -0
  8. package/dist/auth/providers/env-provider.js.map +7 -0
  9. package/dist/auth/providers/index.js +11 -0
  10. package/dist/auth/providers/index.js.map +7 -0
  11. package/dist/auth/providers/simple-resolver.js +185 -0
  12. package/dist/auth/providers/simple-resolver.js.map +7 -0
  13. package/dist/auth/types.js +1 -0
  14. package/dist/auth/types.js.map +7 -0
  15. package/dist/index.js +111 -0
  16. package/dist/index.js.map +7 -0
  17. package/dist/server/config.js +1 -0
  18. package/dist/server/config.js.map +7 -0
  19. package/dist/server/decorators.js +149 -0
  20. package/dist/server/decorators.js.map +7 -0
  21. package/dist/server/index.js +25 -0
  22. package/dist/server/index.js.map +7 -0
  23. package/dist/server/mcp-server.js +269 -0
  24. package/dist/server/mcp-server.js.map +7 -0
  25. package/dist/server/tool.js +66 -0
  26. package/dist/server/tool.js.map +7 -0
  27. package/dist/types.js +1 -0
  28. package/dist/types.js.map +7 -0
  29. package/dist/utils/errors.js +143 -0
  30. package/dist/utils/errors.js.map +7 -0
  31. package/dist/utils/index.js +81 -0
  32. package/dist/utils/index.js.map +7 -0
  33. package/dist/utils/logger.js +200 -0
  34. package/dist/utils/logger.js.map +7 -0
  35. package/dist/utils/validation.js +172 -0
  36. package/dist/utils/validation.js.map +7 -0
  37. package/dist/wrapper/config.js +1 -0
  38. package/dist/wrapper/config.js.map +7 -0
  39. package/dist/wrapper/index.js +10 -0
  40. package/dist/wrapper/index.js.map +7 -0
  41. package/dist/wrapper/server-wrapper.js +427 -0
  42. package/dist/wrapper/server-wrapper.js.map +7 -0
  43. package/package.json +93 -0
@@ -0,0 +1,200 @@
1
+ var LogLevel = /* @__PURE__ */ ((LogLevel2) => {
2
+ LogLevel2[LogLevel2["DEBUG"] = 0] = "DEBUG";
3
+ LogLevel2[LogLevel2["INFO"] = 1] = "INFO";
4
+ LogLevel2[LogLevel2["WARN"] = 2] = "WARN";
5
+ LogLevel2[LogLevel2["ERROR"] = 3] = "ERROR";
6
+ return LogLevel2;
7
+ })(LogLevel || {});
8
+ class Logger {
9
+ config;
10
+ minLevel;
11
+ constructor(config = {}) {
12
+ this.config = {
13
+ enabled: config.enabled ?? true,
14
+ level: config.level ?? "info",
15
+ format: config.format ?? "text",
16
+ logBodies: config.logBodies ?? false
17
+ };
18
+ this.minLevel = this.getLevelValue(this.config.level);
19
+ }
20
+ /**
21
+ * Convert log level string to numeric value
22
+ */
23
+ getLevelValue(level) {
24
+ switch (level) {
25
+ case "debug":
26
+ return 0 /* DEBUG */;
27
+ case "info":
28
+ return 1 /* INFO */;
29
+ case "warn":
30
+ return 2 /* WARN */;
31
+ case "error":
32
+ return 3 /* ERROR */;
33
+ default:
34
+ return 1 /* INFO */;
35
+ }
36
+ }
37
+ /**
38
+ * Check if a log level should be logged
39
+ */
40
+ shouldLog(level) {
41
+ return this.config.enabled && level >= this.minLevel;
42
+ }
43
+ /**
44
+ * Format log entry
45
+ */
46
+ formatEntry(entry) {
47
+ if (this.config.format === "json") {
48
+ return JSON.stringify(entry);
49
+ }
50
+ let output = `[${entry.timestamp}] ${entry.level.toUpperCase()}: ${entry.message}`;
51
+ if (entry.context && Object.keys(entry.context).length > 0) {
52
+ output += ` ${JSON.stringify(entry.context)}`;
53
+ }
54
+ if (entry.error) {
55
+ output += `
56
+ Error: ${entry.error.name}: ${entry.error.message}`;
57
+ if (entry.error.stack) {
58
+ output += `
59
+ ${entry.error.stack}`;
60
+ }
61
+ }
62
+ return output;
63
+ }
64
+ /**
65
+ * Create log entry
66
+ */
67
+ createEntry(level, message, context, error) {
68
+ const entry = {
69
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
70
+ level,
71
+ message,
72
+ context
73
+ };
74
+ if (error) {
75
+ entry.error = {
76
+ name: error.name,
77
+ message: error.message,
78
+ stack: error.stack
79
+ };
80
+ }
81
+ return entry;
82
+ }
83
+ /**
84
+ * Write log entry to output
85
+ */
86
+ write(entry) {
87
+ const formatted = this.formatEntry(entry);
88
+ switch (entry.level) {
89
+ case "debug":
90
+ console.debug(formatted);
91
+ break;
92
+ case "info":
93
+ console.info(formatted);
94
+ break;
95
+ case "warn":
96
+ console.warn(formatted);
97
+ break;
98
+ case "error":
99
+ console.error(formatted);
100
+ break;
101
+ default:
102
+ console.log(formatted);
103
+ }
104
+ }
105
+ /**
106
+ * Log debug message
107
+ */
108
+ debug(message, context) {
109
+ if (this.shouldLog(0 /* DEBUG */)) {
110
+ const entry = this.createEntry("debug", message, context);
111
+ this.write(entry);
112
+ }
113
+ }
114
+ /**
115
+ * Log info message
116
+ */
117
+ info(message, context) {
118
+ if (this.shouldLog(1 /* INFO */)) {
119
+ const entry = this.createEntry("info", message, context);
120
+ this.write(entry);
121
+ }
122
+ }
123
+ /**
124
+ * Log warning message
125
+ */
126
+ warn(message, context) {
127
+ if (this.shouldLog(2 /* WARN */)) {
128
+ const entry = this.createEntry("warn", message, context);
129
+ this.write(entry);
130
+ }
131
+ }
132
+ /**
133
+ * Log error message
134
+ */
135
+ error(message, error, context) {
136
+ if (this.shouldLog(3 /* ERROR */)) {
137
+ const entry = this.createEntry("error", message, context, error);
138
+ this.write(entry);
139
+ }
140
+ }
141
+ /**
142
+ * Create a child logger with additional context
143
+ */
144
+ child(context) {
145
+ const childLogger = new Logger(this.config);
146
+ const originalWrite = childLogger.write.bind(childLogger);
147
+ childLogger.write = (entry) => {
148
+ entry.context = { ...context, ...entry.context };
149
+ originalWrite(entry);
150
+ };
151
+ return childLogger;
152
+ }
153
+ /**
154
+ * Update logger configuration
155
+ */
156
+ configure(config) {
157
+ this.config = { ...this.config, ...config };
158
+ this.minLevel = this.getLevelValue(this.config.level);
159
+ }
160
+ }
161
+ const defaultLogger = new Logger();
162
+ function createLogger(config) {
163
+ return new Logger(config);
164
+ }
165
+ function sanitizeForLogging(data) {
166
+ if (typeof data !== "object" || data === null) {
167
+ return data;
168
+ }
169
+ const sensitiveKeys = [
170
+ "password",
171
+ "token",
172
+ "secret",
173
+ "apiKey",
174
+ "accessToken",
175
+ "refreshToken",
176
+ "authorization",
177
+ "cookie"
178
+ ];
179
+ const sanitized = Array.isArray(data) ? [] : {};
180
+ for (const [key, value] of Object.entries(data)) {
181
+ const lowerKey = key.toLowerCase();
182
+ const isSensitive = sensitiveKeys.some((sk) => lowerKey.includes(sk.toLowerCase()));
183
+ if (isSensitive) {
184
+ sanitized[key] = "[REDACTED]";
185
+ } else if (typeof value === "object" && value !== null) {
186
+ sanitized[key] = sanitizeForLogging(value);
187
+ } else {
188
+ sanitized[key] = value;
189
+ }
190
+ }
191
+ return sanitized;
192
+ }
193
+ export {
194
+ LogLevel,
195
+ Logger,
196
+ createLogger,
197
+ defaultLogger,
198
+ sanitizeForLogging
199
+ };
200
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/utils/logger.ts"],
4
+ "sourcesContent": ["/**\n * Logging utility for @prmichaelsen/mcp-auth\n * \n * Provides structured logging with different levels and formats.\n */\n\nimport type { LoggingConfig } from '../types.js';\n\n/**\n * Log levels in order of severity\n */\nexport enum LogLevel {\n DEBUG = 0,\n INFO = 1,\n WARN = 2,\n ERROR = 3\n}\n\n/**\n * Log entry structure\n */\nexport interface LogEntry {\n timestamp: string;\n level: string;\n message: string;\n context?: Record<string, unknown>;\n error?: {\n name: string;\n message: string;\n stack?: string;\n };\n}\n\n/**\n * Logger class for structured logging\n */\nexport class Logger {\n private config: LoggingConfig;\n private minLevel: LogLevel;\n \n constructor(config: Partial<LoggingConfig> = {}) {\n this.config = {\n enabled: config.enabled ?? true,\n level: config.level ?? 'info',\n format: config.format ?? 'text',\n logBodies: config.logBodies ?? false\n };\n \n this.minLevel = this.getLevelValue(this.config.level);\n }\n \n /**\n * Convert log level string to numeric value\n */\n private getLevelValue(level: string): LogLevel {\n switch (level) {\n case 'debug': return LogLevel.DEBUG;\n case 'info': return LogLevel.INFO;\n case 'warn': return LogLevel.WARN;\n case 'error': return LogLevel.ERROR;\n default: return LogLevel.INFO;\n }\n }\n \n /**\n * Check if a log level should be logged\n */\n private shouldLog(level: LogLevel): boolean {\n return this.config.enabled && level >= this.minLevel;\n }\n \n /**\n * Format log entry\n */\n private formatEntry(entry: LogEntry): string {\n if (this.config.format === 'json') {\n return JSON.stringify(entry);\n }\n \n // Text format\n let output = `[${entry.timestamp}] ${entry.level.toUpperCase()}: ${entry.message}`;\n \n if (entry.context && Object.keys(entry.context).length > 0) {\n output += ` ${JSON.stringify(entry.context)}`;\n }\n \n if (entry.error) {\n output += `\\n Error: ${entry.error.name}: ${entry.error.message}`;\n if (entry.error.stack) {\n output += `\\n${entry.error.stack}`;\n }\n }\n \n return output;\n }\n \n /**\n * Create log entry\n */\n private createEntry(\n level: string,\n message: string,\n context?: Record<string, unknown>,\n error?: Error\n ): LogEntry {\n const entry: LogEntry = {\n timestamp: new Date().toISOString(),\n level,\n message,\n context\n };\n \n if (error) {\n entry.error = {\n name: error.name,\n message: error.message,\n stack: error.stack\n };\n }\n \n return entry;\n }\n \n /**\n * Write log entry to output\n */\n private write(entry: LogEntry): void {\n const formatted = this.formatEntry(entry);\n \n // Use appropriate console method based on level\n switch (entry.level) {\n case 'debug':\n console.debug(formatted);\n break;\n case 'info':\n console.info(formatted);\n break;\n case 'warn':\n console.warn(formatted);\n break;\n case 'error':\n console.error(formatted);\n break;\n default:\n console.log(formatted);\n }\n }\n \n /**\n * Log debug message\n */\n debug(message: string, context?: Record<string, unknown>): void {\n if (this.shouldLog(LogLevel.DEBUG)) {\n const entry = this.createEntry('debug', message, context);\n this.write(entry);\n }\n }\n \n /**\n * Log info message\n */\n info(message: string, context?: Record<string, unknown>): void {\n if (this.shouldLog(LogLevel.INFO)) {\n const entry = this.createEntry('info', message, context);\n this.write(entry);\n }\n }\n \n /**\n * Log warning message\n */\n warn(message: string, context?: Record<string, unknown>): void {\n if (this.shouldLog(LogLevel.WARN)) {\n const entry = this.createEntry('warn', message, context);\n this.write(entry);\n }\n }\n \n /**\n * Log error message\n */\n error(message: string, error?: Error, context?: Record<string, unknown>): void {\n if (this.shouldLog(LogLevel.ERROR)) {\n const entry = this.createEntry('error', message, context, error);\n this.write(entry);\n }\n }\n \n /**\n * Create a child logger with additional context\n */\n child(context: Record<string, unknown>): Logger {\n const childLogger = new Logger(this.config);\n \n // Override write to include parent context\n const originalWrite = childLogger.write.bind(childLogger);\n childLogger.write = (entry: LogEntry) => {\n entry.context = { ...context, ...entry.context };\n originalWrite(entry);\n };\n \n return childLogger;\n }\n \n /**\n * Update logger configuration\n */\n configure(config: Partial<LoggingConfig>): void {\n this.config = { ...this.config, ...config };\n this.minLevel = this.getLevelValue(this.config.level);\n }\n}\n\n/**\n * Default logger instance\n */\nexport const defaultLogger = new Logger();\n\n/**\n * Create a new logger instance\n */\nexport function createLogger(config?: Partial<LoggingConfig>): Logger {\n return new Logger(config);\n}\n\n/**\n * Sanitize sensitive data from logs\n */\nexport function sanitizeForLogging(data: any): any {\n if (typeof data !== 'object' || data === null) {\n return data;\n }\n \n const sensitiveKeys = [\n 'password',\n 'token',\n 'secret',\n 'apiKey',\n 'accessToken',\n 'refreshToken',\n 'authorization',\n 'cookie'\n ];\n \n const sanitized: any = Array.isArray(data) ? [] : {};\n \n for (const [key, value] of Object.entries(data)) {\n const lowerKey = key.toLowerCase();\n const isSensitive = sensitiveKeys.some(sk => lowerKey.includes(sk.toLowerCase()));\n \n if (isSensitive) {\n sanitized[key] = '[REDACTED]';\n } else if (typeof value === 'object' && value !== null) {\n sanitized[key] = sanitizeForLogging(value);\n } else {\n sanitized[key] = value;\n }\n }\n \n return san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UAAM,WAAW,IAAI,YAAY;AACjC,UAAM,cAAc,cAAc,KAAK,QAAM,SAAS,SAAS,GAAG,YAAY,CAAC,CAAC;AAEhF,QAAI,aAAa;AACf,gBAAU,GAAG,IAAI;AAAA,IACnB,WAAW,OAAO,UAAU,YAAY,UAAU,MAAM;AACtD,gBAAU,GAAG,IAAI,mBAAmB,KAAK;AAAA,IAC3C,OAAO;AACL,gBAAU,GAAG,IAAI;AAAA,IACnB;AAAA,EACF;AAEA,SAAO;AACT;",
6
+ "names": ["LogLevel"]
7
+ }
@@ -0,0 +1,172 @@
1
+ import { ValidationError } from "./errors.js";
2
+ function validateNonEmptyString(value, fieldName) {
3
+ if (typeof value !== "string" || value.trim().length === 0) {
4
+ throw new ValidationError(`${fieldName} must be a non-empty string`);
5
+ }
6
+ }
7
+ function validateUrl(value, fieldName) {
8
+ validateNonEmptyString(value, fieldName);
9
+ try {
10
+ new URL(value);
11
+ } catch {
12
+ throw new ValidationError(`${fieldName} must be a valid URL`);
13
+ }
14
+ }
15
+ function validatePositiveNumber(value, fieldName) {
16
+ if (typeof value !== "number" || value <= 0 || !Number.isFinite(value)) {
17
+ throw new ValidationError(`${fieldName} must be a positive number`);
18
+ }
19
+ }
20
+ function validatePort(value, fieldName) {
21
+ validatePositiveNumber(value, fieldName);
22
+ if (!Number.isInteger(value) || value < 1 || value > 65535) {
23
+ throw new ValidationError(`${fieldName} must be a valid port number (1-65535)`);
24
+ }
25
+ }
26
+ function validateEnum(value, allowedValues, fieldName) {
27
+ if (!allowedValues.includes(value)) {
28
+ throw new ValidationError(
29
+ `${fieldName} must be one of: ${allowedValues.join(", ")}`
30
+ );
31
+ }
32
+ }
33
+ function validateObject(value, fieldName) {
34
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
35
+ throw new ValidationError(`${fieldName} must be an object`);
36
+ }
37
+ }
38
+ function validateFunction(value, fieldName) {
39
+ if (typeof value !== "function") {
40
+ throw new ValidationError(`${fieldName} must be a function`);
41
+ }
42
+ }
43
+ function validateRequiredFields(obj, requiredFields, objectName = "Object") {
44
+ for (const field of requiredFields) {
45
+ if (!(field in obj) || obj[field] === void 0 || obj[field] === null) {
46
+ throw new ValidationError(`${objectName} is missing required field: ${String(field)}`);
47
+ }
48
+ }
49
+ }
50
+ function validateTransportConfig(config) {
51
+ validateObject(config, "Transport configuration");
52
+ const cfg = config;
53
+ validateRequiredFields(cfg, ["type"], "Transport configuration");
54
+ validateEnum(cfg.type, ["stdio", "sse", "http"], "transport.type");
55
+ if (cfg.type === "sse" || cfg.type === "http") {
56
+ if (cfg.port !== void 0) {
57
+ validatePort(cfg.port, "transport.port");
58
+ }
59
+ if (cfg.host !== void 0) {
60
+ validateNonEmptyString(cfg.host, "transport.host");
61
+ }
62
+ if (cfg.basePath !== void 0) {
63
+ validateNonEmptyString(cfg.basePath, "transport.basePath");
64
+ const basePath = cfg.basePath;
65
+ if (!basePath.startsWith("/")) {
66
+ throw new ValidationError("transport.basePath must start with /");
67
+ }
68
+ }
69
+ }
70
+ }
71
+ function validateRateLimitConfig(config) {
72
+ validateObject(config, "Rate limit configuration");
73
+ const cfg = config;
74
+ validateRequiredFields(cfg, ["enabled", "maxRequests", "windowMs"], "Rate limit configuration");
75
+ if (typeof cfg.enabled !== "boolean") {
76
+ throw new ValidationError("rateLimit.enabled must be a boolean");
77
+ }
78
+ validatePositiveNumber(cfg.maxRequests, "rateLimit.maxRequests");
79
+ validatePositiveNumber(cfg.windowMs, "rateLimit.windowMs");
80
+ if (cfg.keyGenerator !== void 0) {
81
+ validateFunction(cfg.keyGenerator, "rateLimit.keyGenerator");
82
+ }
83
+ }
84
+ function validateLoggingConfig(config) {
85
+ validateObject(config, "Logging configuration");
86
+ const cfg = config;
87
+ validateRequiredFields(cfg, ["enabled", "level"], "Logging configuration");
88
+ if (typeof cfg.enabled !== "boolean") {
89
+ throw new ValidationError("logging.enabled must be a boolean");
90
+ }
91
+ validateEnum(cfg.level, ["debug", "info", "warn", "error"], "logging.level");
92
+ if (cfg.format !== void 0) {
93
+ validateEnum(cfg.format, ["json", "text"], "logging.format");
94
+ }
95
+ if (cfg.logBodies !== void 0 && typeof cfg.logBodies !== "boolean") {
96
+ throw new ValidationError("logging.logBodies must be a boolean");
97
+ }
98
+ }
99
+ function validatePoolingConfig(config) {
100
+ validateObject(config, "Pooling configuration");
101
+ const cfg = config;
102
+ validateRequiredFields(cfg, ["enabled"], "Pooling configuration");
103
+ if (typeof cfg.enabled !== "boolean") {
104
+ throw new ValidationError("pooling.enabled must be a boolean");
105
+ }
106
+ if (cfg.maxServersPerUser !== void 0) {
107
+ validatePositiveNumber(cfg.maxServersPerUser, "pooling.maxServersPerUser");
108
+ }
109
+ if (cfg.idleTimeoutMs !== void 0) {
110
+ validatePositiveNumber(cfg.idleTimeoutMs, "pooling.idleTimeoutMs");
111
+ }
112
+ if (cfg.maxTotalServers !== void 0) {
113
+ validatePositiveNumber(cfg.maxTotalServers, "pooling.maxTotalServers");
114
+ }
115
+ }
116
+ function sanitizeString(input) {
117
+ return input.replace(/[\x00-\x1F\x7F]/g, "").trim();
118
+ }
119
+ function validateUserId(userId) {
120
+ validateNonEmptyString(userId, "userId");
121
+ const sanitized = sanitizeString(userId);
122
+ if (sanitized.length === 0) {
123
+ throw new ValidationError("userId cannot be empty after sanitization");
124
+ }
125
+ if (sanitized.length > 255) {
126
+ throw new ValidationError("userId must be 255 characters or less");
127
+ }
128
+ return sanitized;
129
+ }
130
+ function validateResourceType(resourceType) {
131
+ validateNonEmptyString(resourceType, "resourceType");
132
+ const sanitized = sanitizeString(resourceType).toLowerCase();
133
+ if (sanitized.length === 0) {
134
+ throw new ValidationError("resourceType cannot be empty after sanitization");
135
+ }
136
+ if (!/^[a-z0-9_-]+$/.test(sanitized)) {
137
+ throw new ValidationError(
138
+ "resourceType must contain only lowercase letters, numbers, hyphens, and underscores"
139
+ );
140
+ }
141
+ return sanitized;
142
+ }
143
+ function validateAccessToken(token) {
144
+ validateNonEmptyString(token, "accessToken");
145
+ const sanitized = token.trim();
146
+ if (sanitized.length === 0) {
147
+ throw new ValidationError("accessToken cannot be empty");
148
+ }
149
+ if (sanitized.length > 4096) {
150
+ throw new ValidationError("accessToken is too long (max 4096 characters)");
151
+ }
152
+ return sanitized;
153
+ }
154
+ export {
155
+ sanitizeString,
156
+ validateAccessToken,
157
+ validateEnum,
158
+ validateFunction,
159
+ validateLoggingConfig,
160
+ validateNonEmptyString,
161
+ validateObject,
162
+ validatePoolingConfig,
163
+ validatePort,
164
+ validatePositiveNumber,
165
+ validateRateLimitConfig,
166
+ validateRequiredFields,
167
+ validateResourceType,
168
+ validateTransportConfig,
169
+ validateUrl,
170
+ validateUserId
171
+ };
172
+ //# sourceMappingURL=validation.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/utils/validation.ts"],
4
+ "sourcesContent": ["/**\n * Validation utilities for @prmichaelsen/mcp-auth\n * \n * Provides input validation and sanitization functions.\n */\n\nimport { ValidationError } from './errors.js';\n\n/**\n * Validate that a value is a non-empty string\n */\nexport function validateNonEmptyString(\n value: unknown,\n fieldName: string\n): asserts value is string {\n if (typeof value !== 'string' || value.trim().length === 0) {\n throw new ValidationError(`${fieldName} must be a non-empty string`);\n }\n}\n\n/**\n * Validate that a value is a valid URL\n */\nexport function validateUrl(value: unknown, fieldName: string): asserts value is string {\n validateNonEmptyString(value, fieldName);\n \n try {\n new URL(value);\n } catch {\n throw new ValidationError(`${fieldName} must be a valid URL`);\n }\n}\n\n/**\n * Validate that a value is a positive number\n */\nexport function validatePositiveNumber(\n value: unknown,\n fieldName: string\n): asserts value is number {\n if (typeof value !== 'number' || value <= 0 || !Number.isFinite(value)) {\n throw new ValidationError(`${fieldName} must be a positive number`);\n }\n}\n\n/**\n * Validate that a value is a valid port number\n */\nexport function validatePort(value: unknown, fieldName: string): asserts value is number {\n validatePositiveNumber(value, fieldName);\n \n if (!Number.isInteger(value) || value < 1 || value > 65535) {\n throw new ValidationError(`${fieldName} must be a valid port number (1-65535)`);\n }\n}\n\n/**\n * Validate that a value is one of the allowed values\n */\nexport function validateEnum<T extends string>(\n value: unknown,\n allowedValues: readonly T[],\n fieldName: string\n): asserts value is T {\n if (!allowedValues.includes(value as T)) {\n throw new ValidationError(\n `${fieldName} must be one of: ${allowedValues.join(', ')}`\n );\n }\n}\n\n/**\n * Validate that a value is a valid object\n */\nexport function validateObject(\n value: unknown,\n fieldName: string\n): asserts value is Record<string, unknown> {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) {\n throw new ValidationError(`${fieldName} must be an object`);\n }\n}\n\n/**\n * Validate that a value is a function\n */\nexport function validateFunction(\n value: unknown,\n fieldName: string\n): asserts value is Function {\n if (typeof value !== 'function') {\n throw new ValidationError(`${fieldName} must be a function`);\n }\n}\n\n/**\n * Validate required fields in an object\n */\nexport function validateRequiredFields<T extends Record<string, unknown>>(\n obj: T,\n requiredFields: (keyof T)[],\n objectName: string = 'Object'\n): void {\n for (const field of requiredFields) {\n if (!(field in obj) || obj[field] === undefined || obj[field] === null) {\n throw new ValidationError(`${objectName} is missing required field: ${String(field)}`);\n }\n }\n}\n\n/**\n * Validate transport configuration\n */\nexport function validateTransportConfig(config: unknown): void {\n validateObject(config, 'Transport configuration');\n \n const cfg = config as Record<string, unknown>;\n \n validateRequiredFields(cfg, ['type'], 'Transport configuration');\n validateEnum(cfg.type, ['stdio', 'sse', 'http'] as const, 'transport.type');\n \n if (cfg.type === 'sse' || cfg.type === 'http') {\n if (cfg.port !== undefined) {\n validatePort(cfg.port, 'transport.port');\n }\n \n if (cfg.host !== undefined) {\n validateNonEmptyString(cfg.host, 'transport.host');\n }\n \n if (cfg.basePath !== undefined) {\n validateNonEmptyString(cfg.basePath, 'transport.basePath');\n \n const basePath = cfg.basePath as string;\n if (!basePath.startsWith('/')) {\n throw new ValidationError('transport.basePath must start with /');\n }\n }\n }\n}\n\n/**\n * Validate rate limit configuration\n */\nexport function validateRateLimitConfig(config: unknown): void {\n validateObject(config, 'Rate limit configuration');\n \n const cfg = config as Record<string, unknown>;\n \n validateRequiredFields(cfg, ['enabled', 'maxRequests', 'windowMs'], 'Rate limit configuration');\n \n if (typeof cfg.enabled !== 'boolean') {\n throw new ValidationError('rateLimit.enabled must be a boolean');\n }\n \n validatePositiveNumber(cfg.maxRequests, 'rateLimit.maxRequests');\n validatePositiveNumber(cfg.windowMs, 'rateLimit.windowMs');\n \n if (cfg.keyGenerator !== undefined) {\n validateFunction(cfg.keyGenerator, 'rateLimit.keyGenerator');\n }\n}\n\n/**\n * Validate logging configuration\n */\nexport function validateLoggingConfig(config: unknown): void {\n validateObject(config, 'Logging configuration');\n \n const cfg = config as Record<string, unknown>;\n \n validateRequiredFields(cfg, ['enabled', 'level'], 'Logging configuration');\n \n if (typeof cfg.enabled !== 'boolean') {\n throw new ValidationError('logging.enabled must be a boolean');\n }\n \n validateEnum(cfg.level, ['debug', 'info', 'warn', 'error'] as const, 'logging.level');\n \n if (cfg.format !== undefined) {\n validateEnum(cfg.format, ['json', 'text'] as const, 'logging.format');\n }\n \n if (cfg.logBodies !== undefined && typeof cfg.logBodies !== 'boolean') {\n throw new ValidationError('logging.logBodies must be a boolean');\n }\n}\n\n/**\n * Validate pooling configuration\n */\nexport function validatePoolingConfig(config: unknown): void {\n validateObject(config, 'Pooling configuration');\n \n const cfg = config as Record<string, unknown>;\n \n validateRequiredFields(cfg, ['enabled'], 'Pooling configuration');\n \n if (typeof cfg.enabled !== 'boolean') {\n throw new ValidationError('pooling.enabled must be a boolean');\n }\n \n if (cfg.maxServersPerUser !== undefined) {\n validatePositiveNumber(cfg.maxServersPerUser, 'pooling.maxServersPerUser');\n }\n \n if (cfg.idleTimeoutMs !== undefined) {\n validatePositiveNumber(cfg.idleTimeoutMs, 'pooling.idleTimeoutMs');\n }\n \n if (cfg.maxTotalServers !== undefined) {\n validatePositiveNumber(cfg.maxTotalServers, 'pooling.maxTotalServers');\n }\n}\n\n/**\n * Sanitize string input (remove control characters, trim)\n */\nexport function sanitizeString(input: string): string {\n return input\n .replace(/[\\x00-\\x1F\\x7F]/g, '') // Remove control characters\n .trim();\n}\n\n/**\n * Validate and sanitize user ID\n */\nexport function validateUserId(userId: unknown): string {\n validateNonEmptyString(userId, 'userId');\n \n const sanitized = sanitizeString(userId);\n \n if (sanitized.length === 0) {\n throw new ValidationError('userId cannot be empty after sanitization');\n }\n \n if (sanitized.length > 255) {\n throw new ValidationError('userId must be 255 characters or less');\n }\n \n return sanitized;\n}\n\n/**\n * Validate and sanitize resource type\n */\nexport function validateResourceType(resourceType: unknown): string {\n validateNonEmptyString(resourceType, 'resourceType');\n \n const sanitized = sanitizeString(resourceType).toLowerCase();\n \n if (sanitized.length === 0) {\n throw new ValidationError('resourceType cannot be empty after sanitization');\n }\n \n if (!/^[a-z0-9_-]+$/.test(sanitized)) {\n throw new ValidationError(\n 'resourceType must contain only lowercase letters, numbers, hyphens, and underscores'\n );\n }\n \n return sanitized;\n}\n\n/**\n * Validate access token format (basic check)\n */\nexport function validateAccessToken(token: unknown): string {\n validateNonEmptyString(token, 'accessToken');\n \n const sanitized = token.trim();\n \n if (sanitized.length === 0) {\n throw new ValidationError('accessToken cannot be empty');\n }\n \n if (sanitized.length > 4096) {\n throw new ValidationError('accessToken is too long (max 4096 characters)');\n }\n \n return sanitized;\n}\n"],
5
+ "mappings": "AAMA,SAAS,uBAAuB;AAKzB,SAAS,uBACd,OACA,WACyB;AACzB,MAAI,OAAO,UAAU,YAAY,MAAM,KAAK,EAAE,WAAW,GAAG;AAC1D,UAAM,IAAI,gBAAgB,GAAG,SAAS,6BAA6B;AAAA,EACrE;AACF;AAKO,SAAS,YAAY,OAAgB,WAA4C;AACtF,yBAAuB,OAAO,SAAS;AAEvC,MAAI;AACF,QAAI,IAAI,KAAK;AAAA,EACf,QAAQ;AACN,UAAM,IAAI,gBAAgB,GAAG,SAAS,sBAAsB;AAAA,EAC9D;AACF;AAKO,SAAS,uBACd,OACA,WACyB;AACzB,MAAI,OAAO,UAAU,YAAY,SAA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;AAC1B,UAAM,IAAI,gBAAgB,6BAA6B;AAAA,EACzD;AAEA,MAAI,UAAU,SAAS,MAAM;AAC3B,UAAM,IAAI,gBAAgB,+CAA+C;AAAA,EAC3E;AAEA,SAAO;AACT;",
6
+ "names": []
7
+ }
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -0,0 +1,10 @@
1
+ import { AuthenticatedServerWrapper } from "./server-wrapper.js";
2
+ import { AuthenticatedServerWrapper as AuthenticatedServerWrapper2 } from "./server-wrapper.js";
3
+ function wrapServer(config) {
4
+ return new AuthenticatedServerWrapper(config);
5
+ }
6
+ export {
7
+ AuthenticatedServerWrapper2 as AuthenticatedServerWrapper,
8
+ wrapServer
9
+ };
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/wrapper/index.ts"],
4
+ "sourcesContent": ["/**\n * Server wrapper module exports\n * \n * Provides the main wrapServer() function for wrapping MCP servers with authentication.\n */\n\nimport { AuthenticatedServerWrapper } from './server-wrapper.js';\nimport type { ServerWrapperConfig, MCPServerFactory } from './config.js';\n\n// Export types\nexport type { ServerWrapperConfig, MCPServerFactory, NormalizedServerWrapperConfig } from './config.js';\n\n// Export wrapper class\nexport { AuthenticatedServerWrapper } from './server-wrapper.js';\n\n/**\n * Wrap an MCP server with authentication and multi-tenancy support\n * \n * This is the main entry point for the server wrapping pattern.\n * It creates an authenticated wrapper around your MCP server factory function.\n * \n * @param config - Server wrapper configuration\n * @returns Authenticated server wrapper instance\n * \n * @example\n * ```typescript\n * import { wrapServer } from '@prmichaelsen/mcp-auth';\n * import { createServer } from '@myorg/my-mcp-server';\n * \n * const wrapped = wrapServer({\n * serverFactory: (accessToken, userId) => createServer(accessToken, userId),\n * authProvider: new JWTAuthProvider({ ... }),\n * tokenResolver: new DatabaseTokenResolver({ ... }),\n * resourceType: 'myapi',\n * transport: { type: 'sse', port: 3000 }\n * });\n * \n * await wrapped.start();\n * ```\n */\nexport function wrapServer(config: ServerWrapperConfig): AuthenticatedServerWrapper {\n return new AuthenticatedServerWrapper(config);\n}\n"],
5
+ "mappings": "AAMA,SAAS,kCAAkC;AAO3C,SAAS,8BAAAA,mCAAkC;AA2BpC,SAAS,WAAW,QAAyD;AAClF,SAAO,IAAI,2BAA2B,MAAM;AAC9C;",
6
+ "names": ["AuthenticatedServerWrapper"]
7
+ }