@anton.andrusenko/shopify-mcp-admin 2.1.1 → 2.2.1

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,24 @@
1
+ import {
2
+ MCP_AUTH_ERRORS,
3
+ createJsonRpcError,
4
+ createMcpAuthMiddleware,
5
+ getWwwAuthenticateHeader,
6
+ isOAuthAccessToken,
7
+ parseBearerToken,
8
+ validateMcpApiKey,
9
+ validateMcpBearerToken,
10
+ validateOAuthAccessToken
11
+ } from "./chunk-PQKNBYJN.js";
12
+ import "./chunk-5QMYOO4B.js";
13
+ import "./chunk-EGGOXEIC.js";
14
+ export {
15
+ MCP_AUTH_ERRORS,
16
+ createJsonRpcError,
17
+ createMcpAuthMiddleware,
18
+ getWwwAuthenticateHeader,
19
+ isOAuthAccessToken,
20
+ parseBearerToken,
21
+ validateMcpApiKey,
22
+ validateMcpBearerToken,
23
+ validateOAuthAccessToken
24
+ };
@@ -0,0 +1,38 @@
1
+ import {
2
+ configSchema,
3
+ getAllowedOrigins,
4
+ getAuthMode,
5
+ getConfiguredRole,
6
+ getDatabaseUrl,
7
+ getEncryptionKey,
8
+ getServerMode,
9
+ getShutdownDrainMs,
10
+ getShutdownDrainSeconds,
11
+ getStoreUrl,
12
+ isDebugEnabled,
13
+ isHSTSEnabled,
14
+ isLazyLoadingEnabled,
15
+ isMetricsEnabled,
16
+ isRemoteMode,
17
+ requireEncryptionKey,
18
+ requireStoreUrl
19
+ } from "./chunk-EGGOXEIC.js";
20
+ export {
21
+ configSchema,
22
+ getAllowedOrigins,
23
+ getAuthMode,
24
+ getConfiguredRole,
25
+ getDatabaseUrl,
26
+ getEncryptionKey,
27
+ getServerMode,
28
+ getShutdownDrainMs,
29
+ getShutdownDrainSeconds,
30
+ getStoreUrl,
31
+ isDebugEnabled,
32
+ isHSTSEnabled,
33
+ isLazyLoadingEnabled,
34
+ isMetricsEnabled,
35
+ isRemoteMode,
36
+ requireEncryptionKey,
37
+ requireStoreUrl
38
+ };
@@ -0,0 +1,112 @@
1
+ import {
2
+ log
3
+ } from "./chunk-5QMYOO4B.js";
4
+ import "./chunk-EGGOXEIC.js";
5
+
6
+ // src/middleware/security.ts
7
+ import cors from "cors";
8
+ var DEFAULT_SECURITY_OPTIONS = {
9
+ allowedOrigins: ["*"],
10
+ exposedHeaders: ["Mcp-Session-Id"],
11
+ enableHSTS: false,
12
+ enableSecurityHeaders: true
13
+ };
14
+ var CORS_ALLOWED_METHODS = ["GET", "POST", "DELETE", "OPTIONS"];
15
+ var CORS_ALLOWED_HEADERS = [
16
+ "Content-Type",
17
+ "Authorization",
18
+ "Mcp-Session-Id",
19
+ "MCP-Protocol-Version"
20
+ ];
21
+ var CORS_MAX_AGE = 86400;
22
+ var SECURITY_HEADERS = {
23
+ "X-Frame-Options": "DENY",
24
+ "X-Content-Type-Options": "nosniff",
25
+ "X-XSS-Protection": "1; mode=block",
26
+ "Referrer-Policy": "strict-origin-when-cross-origin"
27
+ };
28
+ var HSTS_HEADER_VALUE = "max-age=31536000; includeSubDomains";
29
+ function createCorsMiddleware(options) {
30
+ const opts = {
31
+ ...DEFAULT_SECURITY_OPTIONS,
32
+ ...options
33
+ };
34
+ const isWildcard = opts.allowedOrigins.length === 1 && opts.allowedOrigins[0] === "*";
35
+ log.debug(
36
+ `CORS middleware configured with ${isWildcard ? "wildcard (*)" : `${opts.allowedOrigins.length} allowed`} origins`
37
+ );
38
+ return cors({
39
+ // Dynamic origin handler for configured origins
40
+ origin: (origin, callback) => {
41
+ if (!origin) {
42
+ callback(null, true);
43
+ return;
44
+ }
45
+ if (isWildcard) {
46
+ callback(null, true);
47
+ return;
48
+ }
49
+ if (opts.allowedOrigins.includes(origin)) {
50
+ callback(null, origin);
51
+ return;
52
+ }
53
+ log.debug(`CORS: Origin ${origin} not in allowed list`);
54
+ callback(null, false);
55
+ },
56
+ // Allowed HTTP methods
57
+ methods: CORS_ALLOWED_METHODS,
58
+ // Allowed request headers
59
+ //
60
+ // IMPORTANT: For browser-based MCP clients (Claude custom connectors), the client may
61
+ // include additional non-simple headers (e.g. tracing or client metadata). If we
62
+ // hardcode allowedHeaders, CORS preflight can fail and the connector will remain
63
+ // "Disconnected" even though OAuth succeeds.
64
+ //
65
+ // The `cors` package will, by default, reflect `Access-Control-Request-Headers` from
66
+ // the preflight request when `allowedHeaders` is not explicitly set.
67
+ //
68
+ // We keep CORS_ALLOWED_HEADERS exported for documentation/tests, but do not enforce it.
69
+ // Headers exposed to browser JavaScript
70
+ exposedHeaders: opts.exposedHeaders,
71
+ // Allow credentials (cookies, authorization headers)
72
+ credentials: true,
73
+ // Preflight cache duration (24 hours)
74
+ maxAge: CORS_MAX_AGE,
75
+ // Let OPTIONS requests succeed
76
+ preflightContinue: false,
77
+ optionsSuccessStatus: 204
78
+ });
79
+ }
80
+ function createSecurityMiddleware(options) {
81
+ const opts = {
82
+ ...DEFAULT_SECURITY_OPTIONS,
83
+ ...options
84
+ };
85
+ const logHeaders = opts.enableSecurityHeaders ? `Security headers: enabled, HSTS: ${opts.enableHSTS ? "enabled" : "disabled"}` : "Security headers: disabled";
86
+ log.debug(`Security middleware configured: ${logHeaders}`);
87
+ return (_req, res, next) => {
88
+ if (opts.enableSecurityHeaders) {
89
+ for (const [header, value] of Object.entries(SECURITY_HEADERS)) {
90
+ res.setHeader(header, value);
91
+ }
92
+ }
93
+ if (opts.enableHSTS) {
94
+ res.setHeader("Strict-Transport-Security", HSTS_HEADER_VALUE);
95
+ }
96
+ next();
97
+ };
98
+ }
99
+ function createSecurityMiddlewareStack(options) {
100
+ return [createCorsMiddleware(options), createSecurityMiddleware(options)];
101
+ }
102
+ export {
103
+ CORS_ALLOWED_HEADERS,
104
+ CORS_ALLOWED_METHODS,
105
+ CORS_MAX_AGE,
106
+ DEFAULT_SECURITY_OPTIONS,
107
+ HSTS_HEADER_VALUE,
108
+ SECURITY_HEADERS,
109
+ createCorsMiddleware,
110
+ createSecurityMiddleware,
111
+ createSecurityMiddlewareStack
112
+ };