@flakiness/sdk 1.0.1 → 1.0.2

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/lib/index.js CHANGED
@@ -1339,7 +1339,7 @@ var StaticServer = class {
1339
1339
  ".ico": "image/x-icon",
1340
1340
  ".txt": "text/plain"
1341
1341
  };
1342
- constructor(pathPrefix, folderPath, cors) {
1342
+ constructor(pathPrefix, folderPath, cors = []) {
1343
1343
  this._pathPrefix = "/" + pathPrefix.replace(/^\//, "").replace(/\/$/, "");
1344
1344
  this._absoluteFolderPath = path3.resolve(folderPath);
1345
1345
  this._cors = cors;
@@ -1414,9 +1414,10 @@ var StaticServer = class {
1414
1414
  }
1415
1415
  _handleRequest(req, res) {
1416
1416
  const { url, method } = req;
1417
- if (this._cors) {
1417
+ if (this._cors.length && req.headers.origin && this._cors.includes(req.headers.origin)) {
1418
1418
  res.setHeader("Access-Control-Allow-Headers", "*");
1419
- res.setHeader("Access-Control-Allow-Origin", this._cors);
1419
+ res.setHeader("Vary", "Origin");
1420
+ res.setHeader("Access-Control-Allow-Origin", req.headers.origin);
1420
1421
  res.setHeader("Access-Control-Allow-Methods", "*");
1421
1422
  if (req.method === "OPTIONS") {
1422
1423
  res.writeHead(204);
@@ -1468,7 +1469,11 @@ async function showReport(reportFolder) {
1468
1469
  const projectPublicId = config.projectPublicId();
1469
1470
  const reportViewerEndpoint = config.reportViewerUrl();
1470
1471
  const token = randomUUIDBase62();
1471
- const server = new StaticServer(token, reportFolder, reportViewerEndpoint);
1472
+ const server = new StaticServer(token, reportFolder, [
1473
+ reportViewerEndpoint,
1474
+ // trace.playwright.dev is used to load & display Playwright Test traces.
1475
+ "https://trace.playwright.dev"
1476
+ ]);
1472
1477
  await server.start(9373, "127.0.0.1");
1473
1478
  const url = new URL(reportViewerEndpoint);
1474
1479
  url.searchParams.set("port", String(server.port()));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flakiness/sdk",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "private": false,
5
5
  "repository": {
6
6
  "type": "git",
@@ -1 +1 @@
1
- {"version":3,"file":"showReport.d.ts","sourceRoot":"","sources":["../../src/showReport.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,UAAU,CAAC,YAAY,EAAE,MAAM,iBAqBpD"}
1
+ {"version":3,"file":"showReport.d.ts","sourceRoot":"","sources":["../../src/showReport.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,UAAU,CAAC,YAAY,EAAE,MAAM,iBAyBpD"}
@@ -2,9 +2,9 @@ export declare class StaticServer {
2
2
  private _server;
3
3
  private _absoluteFolderPath;
4
4
  private _pathPrefix;
5
- private _cors?;
5
+ private _cors;
6
6
  private _mimeTypes;
7
- constructor(pathPrefix: string, folderPath: string, cors?: string);
7
+ constructor(pathPrefix: string, folderPath: string, cors?: string[]);
8
8
  port(): number | undefined;
9
9
  address(): string | undefined;
10
10
  private _startServer;
@@ -1 +1 @@
1
- {"version":3,"file":"staticServer.d.ts","sourceRoot":"","sources":["../../src/staticServer.ts"],"names":[],"mappings":"AAQA,qBAAa,YAAY;IACvB,OAAO,CAAC,OAAO,CAAc;IAC7B,OAAO,CAAC,mBAAmB,CAAS;IACpC,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,KAAK,CAAC,CAAS;IAEvB,OAAO,CAAC,UAAU,CAWhB;gBAEU,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM;IAQjE,IAAI;IAOJ,OAAO,IAAI,MAAM,GAAC,SAAS;YASb,YAAY;IAkBpB,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,MAAoB;IAyB7C,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAc5B,OAAO,CAAC,cAAc;IAMtB,OAAO,CAAC,cAAc;CAiEvB"}
1
+ {"version":3,"file":"staticServer.d.ts","sourceRoot":"","sources":["../../src/staticServer.ts"],"names":[],"mappings":"AAQA,qBAAa,YAAY;IACvB,OAAO,CAAC,OAAO,CAAc;IAC7B,OAAO,CAAC,mBAAmB,CAAS;IACpC,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,KAAK,CAAW;IAExB,OAAO,CAAC,UAAU,CAWhB;gBAEU,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,GAAE,MAAM,EAAO;IAQvE,IAAI;IAOJ,OAAO,IAAI,MAAM,GAAC,SAAS;YASb,YAAY;IAkBpB,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,MAAoB;IAyB7C,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAc5B,OAAO,CAAC,cAAc;IAMtB,OAAO,CAAC,cAAc;CAkEvB"}