Skip to content

Commit 55154bf

Browse files
authored
Merge branch 'main' into main
2 parents 04c46fe + 1400383 commit 55154bf

File tree

4 files changed

+32
-14
lines changed

4 files changed

+32
-14
lines changed

CHANGELOG.md

+14
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@
22

33
## Unreleased
44

5+
## [v1.7.0](https://github.com/coder/vscode-coder/releases/tag/v1.7.0) (2025-04-03)
6+
7+
### Added
8+
9+
- Add new `/openDevContainer` path, similar to the `/open` path, except this
10+
allows connecting to a dev container inside a workspace. For now, the dev
11+
container must already be running for this to work.
12+
13+
### Fixed
14+
15+
- When not using token authentication, avoid setting `undefined` for the token
16+
header, as Node will throw an error when headers are undefined. Now, we will
17+
not set any header at all.
18+
519
## [v1.6.0](https://github.com/coder/vscode-coder/releases/tag/v1.6.0) (2025-04-01)
620

721
### Added

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"displayName": "Coder",
55
"description": "Open any workspace with a single click.",
66
"repository": "https://github.com/coder/vscode-coder",
7-
"version": "1.6.0",
7+
"version": "1.7.0",
88
"engines": {
99
"vscode": "^1.73.0"
1010
},

src/api.ts

+9-6
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import { getProxyForUrl } from "./proxy"
1313
import { Storage } from "./storage"
1414
import { expandPath } from "./util"
1515

16+
export const coderSessionTokenHeader = "Coder-Session-Token"
17+
1618
/**
1719
* Return whether the API will need a token for authorization.
1820
* If mTLS is in use (as specified by the cert or key files being set) then
@@ -242,14 +244,15 @@ export async function waitForBuild(
242244
const baseUrl = new URL(baseUrlRaw)
243245
const proto = baseUrl.protocol === "https:" ? "wss:" : "ws:"
244246
const socketUrlRaw = `${proto}//${baseUrl.host}${path}`
247+
const token = restClient.getAxiosInstance().defaults.headers.common[coderSessionTokenHeader] as string | undefined
245248
const socket = new ws.WebSocket(new URL(socketUrlRaw), {
246-
headers: {
247-
"Coder-Session-Token": restClient.getAxiosInstance().defaults.headers.common["Coder-Session-Token"] as
248-
| string
249-
| undefined,
250-
},
251-
followRedirects: true,
252249
agent: agent,
250+
followRedirects: true,
251+
headers: token
252+
? {
253+
[coderSessionTokenHeader]: token,
254+
}
255+
: undefined,
253256
})
254257
socket.binaryType = "nodebuffer"
255258
socket.on("message", (data) => {

src/inbox.ts

+8-7
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Workspace, GetInboxNotificationResponse } from "coder/site/src/api/type
33
import { ProxyAgent } from "proxy-agent"
44
import * as vscode from "vscode"
55
import { WebSocket } from "ws"
6+
import { coderSessionTokenHeader } from "./api"
67
import { errToStr } from "./api-helper"
78
import { type Storage } from "./storage"
89

@@ -37,15 +38,15 @@ export class Inbox implements vscode.Disposable {
3738
const socketProto = baseUrl.protocol === "https:" ? "wss:" : "ws:"
3839
const socketUrl = `${socketProto}//${baseUrl.host}/api/v2/notifications/inbox/watch?format=plaintext&templates=${watchTemplatesParam}&targets=${watchTargetsParam}`
3940

40-
const coderSessionTokenHeader = "Coder-Session-Token"
41+
const token = restClient.getAxiosInstance().defaults.headers.common[coderSessionTokenHeader] as string | undefined
4142
this.#socket = new WebSocket(new URL(socketUrl), {
42-
followRedirects: true,
4343
agent: httpAgent,
44-
headers: {
45-
[coderSessionTokenHeader]: restClient.getAxiosInstance().defaults.headers.common[coderSessionTokenHeader] as
46-
| string
47-
| undefined,
48-
},
44+
followRedirects: true,
45+
headers: token
46+
? {
47+
[coderSessionTokenHeader]: token,
48+
}
49+
: undefined,
4950
})
5051

5152
this.#socket.on("open", () => {

0 commit comments

Comments
 (0)