@scenarist/msw-adapter 0.4.3 → 0.4.5
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dynamic-handler.d.ts","sourceRoot":"","sources":["../../src/handlers/dynamic-handler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,KAAK,EACV,cAAc,EACd,iBAAiB,EAIjB,gBAAgB,EAChB,cAAc,EACd,MAAM,EACP,MAAM,iBAAiB,CAAC;AAKzB,MAAM,MAAM,qBAAqB,GAAG;IAClC,QAAQ,CAAC,SAAS,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,MAAM,CAAC;IACjD,QAAQ,CAAC,iBAAiB,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,cAAc,GAAG,SAAS,CAAC;IAC3E,QAAQ,CAAC,qBAAqB,EAAE,CAC9B,UAAU,EAAE,MAAM,KACf,iBAAiB,GAAG,SAAS,CAAC;IACnC,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;IAC5C,QAAQ,CAAC,cAAc,CAAC,EAAE,cAAc,CAAC;IACzC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAoIF,eAAO,MAAM,oBAAoB,GAC/B,SAAS,qBAAqB,KAC7B,
|
|
1
|
+
{"version":3,"file":"dynamic-handler.d.ts","sourceRoot":"","sources":["../../src/handlers/dynamic-handler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,KAAK,EACV,cAAc,EACd,iBAAiB,EAIjB,gBAAgB,EAChB,cAAc,EACd,MAAM,EACP,MAAM,iBAAiB,CAAC;AAKzB,MAAM,MAAM,qBAAqB,GAAG;IAClC,QAAQ,CAAC,SAAS,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,MAAM,CAAC;IACjD,QAAQ,CAAC,iBAAiB,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,cAAc,GAAG,SAAS,CAAC;IAC3E,QAAQ,CAAC,qBAAqB,EAAE,CAC9B,UAAU,EAAE,MAAM,KACf,iBAAiB,GAAG,SAAS,CAAC;IACnC,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;IAC5C,QAAQ,CAAC,cAAc,CAAC,EAAE,cAAc,CAAC;IACzC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAoIF,eAAO,MAAM,oBAAoB,GAC/B,SAAS,qBAAqB,KAC7B,WA+IF,CAAC"}
|
|
@@ -173,23 +173,37 @@ export const createDynamicHandler = (options) => {
|
|
|
173
173
|
// Log the error via Logger if available
|
|
174
174
|
if (options.logger) {
|
|
175
175
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
176
|
+
// Security: Only include stack traces in non-production environments
|
|
177
|
+
// to prevent information exposure through log aggregation systems.
|
|
178
|
+
// Stack traces can reveal internal file paths, dependency versions,
|
|
179
|
+
// and implementation details that could aid attackers.
|
|
180
|
+
const includeStack = process.env.NODE_ENV !== "production";
|
|
176
181
|
options.logger.error(LogCategories.REQUEST, `Handler error: ${errorMessage}`, {
|
|
177
182
|
testId,
|
|
178
183
|
requestUrl: request.url,
|
|
179
184
|
requestMethod: request.method,
|
|
180
185
|
}, {
|
|
181
186
|
errorName: error instanceof Error ? error.name : "Unknown",
|
|
182
|
-
stack: error instanceof Error ? error.stack : undefined,
|
|
187
|
+
stack: includeStack && error instanceof Error ? error.stack : undefined,
|
|
183
188
|
});
|
|
184
189
|
}
|
|
185
190
|
// Use specific error code from ScenaristError, or fallback to HANDLER_ERROR
|
|
186
191
|
const errorCode = error instanceof ScenaristError ? error.code : "HANDLER_ERROR";
|
|
187
|
-
// Return a 500 error response
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
192
|
+
// Return a 500 error response
|
|
193
|
+
// Security: Only include message for ScenaristErrors (intentional, safe messages)
|
|
194
|
+
// For unexpected errors (HANDLER_ERROR), do not expose internal error messages
|
|
195
|
+
// which may contain sensitive information like file paths, credentials, etc.
|
|
196
|
+
const responseBody = error instanceof ScenaristError
|
|
197
|
+
? {
|
|
198
|
+
error: "Internal mock server error",
|
|
199
|
+
message: error.message,
|
|
200
|
+
code: errorCode,
|
|
201
|
+
}
|
|
202
|
+
: {
|
|
203
|
+
error: "Internal mock server error",
|
|
204
|
+
code: errorCode,
|
|
205
|
+
};
|
|
206
|
+
return new Response(JSON.stringify(responseBody), {
|
|
193
207
|
status: 500,
|
|
194
208
|
headers: { "Content-Type": "application/json" },
|
|
195
209
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scenarist/msw-adapter",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.5",
|
|
4
4
|
"description": "Internal: MSW integration layer for Scenarist framework adapters",
|
|
5
5
|
"author": "Paul Hammond (citypaul) <paul@packsoftware.co.uk>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
],
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"path-to-regexp": "^6.3.0",
|
|
45
|
-
"@scenarist/core": "0.4.
|
|
45
|
+
"@scenarist/core": "0.4.5"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"msw": "^2.0.0"
|