You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
commit 79e595b added a secret token
which is required to connect via web socket (to prevent random websites
from connecting to elm-watch). However, I somehow messed up the fix. The
web socket still connects. But it is at least given a difference state,
which makes the web socket connection less useful. No messages with
interesting information was sent to the client, and all commands sent
from the client except one were ignored. The only command the client
could perform is `PressedOpenEditor`, which would execute your
configured command for opening your editor. Not that harmful (unless you
have an insecure editor command), but very annoying (and scary) if it would happen.
This commit responds with 401 and does not initiate a web socket
connection if the secret is wrong. This completely fixes the issue.
It results in worse error messages if this were to happen on `localhost`
for some reason. I include the header `X-Reason: Invalid token` or
`X-Reason: Invalid URL`. They are intentionally vague to not expose too
much to an unauthorized requester, but should help debugging slightly at
least, if needed. And small info message is printed in the terminal.
Copy file name to clipboardExpand all lines: src/Errors.ts
+3-28Lines changed: 3 additions & 28 deletions
Original file line number
Diff line number
Diff line change
@@ -1368,48 +1368,23 @@ ${text(error.message)}
1368
1368
`;
1369
1369
}
1370
1370
1371
-
exportfunctionwebSocketBadUrl(
1372
-
expectedStart: string,
1373
-
actualUrlString: string,
1374
-
): string{
1375
-
return`
1376
-
I expected the web socket connection URL to start with:
1377
-
1378
-
${expectedStart}
1379
-
1380
-
But it looks like this:
1381
-
1382
-
${actualUrlString}
1383
-
1384
-
The web socket code I generate is supposed to always connect using a correct URL, so something is up here.
1385
-
`.trim();
1386
-
}
1387
-
1388
1371
exportfunctionwebSocketParamsDecodeError(
1389
1372
error: Codec.DecoderError,
1390
-
actualUrlString: string,
1373
+
urlParams: URLSearchParams,
1391
1374
): string{
1392
1375
return`
1393
1376
I ran into trouble parsing the web socket connection URL parameters:
1394
1377
1395
1378
${printJsonError(error).text}
1396
1379
1397
-
The URL looks like this:
1380
+
The URL parameters look like this:
1398
1381
1399
-
${actualUrlString}
1382
+
${urlParams.toString()}
1400
1383
1401
1384
The web socket code I generate is supposed to always connect using a correct URL, so something is up here. Maybe the JavaScript code running in the browser was compiled with an older version of elm-watch? If so, try reloading the page.
1402
1385
`;
1403
1386
}
1404
1387
1405
-
exportfunctionwebSocketWrongToken(): string{
1406
-
return`
1407
-
The web socket connected with the wrong security token. The security token is used to block malicious connections.
1408
-
1409
-
The web socket code I generate is supposed to always connect using the correct token, so something is up here. Maybe the JavaScript code running in the browser was compiled with an older version of elm-watch? If so, try reloading the page.
0 commit comments