@podge/cli 0.2.0-beta.6 → 0.2.0-beta.7

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.
@@ -40,6 +40,20 @@ function startAuthServer(expectedState, timeoutMs = 120000) {
40
40
  }, timeoutMs);
41
41
  server.on("request", (req, res) => {
42
42
  const parsed = url.parse(req.url ?? "", true);
43
+ // CORS headers for cross-origin requests from the web app
44
+ res.setHeader("Access-Control-Allow-Origin", "*");
45
+ res.setHeader("Access-Control-Allow-Methods", "GET, OPTIONS");
46
+ res.setHeader("Access-Control-Allow-Headers", "Content-Type");
47
+ if (req.method === "OPTIONS") {
48
+ res.writeHead(204);
49
+ res.end();
50
+ return;
51
+ }
52
+ if (parsed.pathname === "/state") {
53
+ res.writeHead(200, { "Content-Type": "application/json" });
54
+ res.end(JSON.stringify({ state: expectedState }));
55
+ return;
56
+ }
43
57
  if (parsed.pathname !== "/callback") {
44
58
  res.writeHead(404);
45
59
  res.end("Not found");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@podge/cli",
3
- "version": "0.2.0-beta.6",
3
+ "version": "0.2.0-beta.7",
4
4
  "description": "CLI for Podge — manage workspaces, collections, and search",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",