Skip to content

Commit f85bfcf

Browse files
committed
chore: update
1 parent cb66bb9 commit f85bfcf

File tree

6 files changed

+12
-11
lines changed

6 files changed

+12
-11
lines changed

packages/core/src/node/auth-revoke.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export async function revokeAuthToken(
1414
): Promise<void> {
1515
// Remove from persistent storage
1616
storage.mutate((state) => {
17-
delete state.trusted[token]
17+
state.trusted[token] = undefined
1818
})
1919

2020
const rpcHost = context.rpc as unknown as RpcFunctionsHost

packages/core/src/node/context-internal.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export interface InternalAnonymousAuthStorage {
1111
ua: string
1212
origin: string
1313
timestamp: number
14-
}>
14+
} | undefined>
1515
}
1616

1717
export interface DevToolsInternalContext {

packages/core/src/node/rpc/anonymous/auth.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export const anonymousAuth = defineRpcFunction({
3232
throw new Error('Failed to retrieve the current RPC session')
3333

3434
if (session.meta.isTrusted || storage.value().trusted[query.authId]) {
35+
console.log('trusted', { isTrusted: session.meta.isTrusted, trusted: storage.value().trusted[query.authId] })
3536
session.meta.clientAuthId = query.authId
3637
session.meta.isTrusted = true
3738
return {
@@ -76,8 +77,8 @@ export const anonymousAuth = defineRpcFunction({
7677
`Origin : ${c.yellow(c.bold(query.origin || 'Unknown'))}`,
7778
`Client Token : ${c.green(c.bold(query.authId))}`,
7879
'',
79-
`Auth URL : ${c.cyan(c.underline(authUrl))}`,
80-
`Temp Token : ${c.cyan(c.bold(tempId))}`,
80+
`Manual Auth URL : ${c.cyan(c.underline(authUrl))}`,
81+
`Manual Auth Token : ${c.cyan(c.bold(tempId))}`,
8182
'',
8283
'This will allow the browser to interact with the server, make file changes and run commands.',
8384
c.red(c.bold('You should only trust your local development browsers.')),

packages/core/src/node/ws.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,17 @@ export async function createWsServer(options: CreateWsServerOptions) {
4646
https,
4747
onConnected: (ws, req, meta) => {
4848
const url = new URL(req.url ?? '', 'http://localhost')
49-
const authId = url.searchParams.get('vite_devtools_auth_id') ?? undefined
49+
const authToken = url.searchParams.get('vite_devtools_auth_token') ?? undefined
5050
if (isClientAuthDisabled) {
5151
meta.isTrusted = true
5252
}
53-
else if (authId && contextInternal.storage.auth.value().trusted[authId]) {
53+
else if (authToken && contextInternal.storage.auth.value().trusted[authToken]) {
5454
meta.isTrusted = true
55-
meta.clientAuthId = authId
55+
meta.clientAuthId = authToken
5656
}
57-
else if (authId && ((context.viteConfig.devtools?.config as any)?.clientAuthTokens ?? []).includes(authId)) {
57+
else if (authToken && ((context.viteConfig.devtools?.config as any)?.clientAuthTokens ?? []).includes(authToken)) {
5858
meta.isTrusted = true
59-
meta.clientAuthId = authId
59+
meta.clientAuthId = authToken
6060
}
6161

6262
wsClients.add(ws)

packages/rpc/src/presets/ws/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function NOOP() {}
1616
export const createWsRpcPreset: RpcClientPreset<(options: WebSocketRpcClientOptions) => ChannelOptions> = defineRpcClientPreset((options: WebSocketRpcClientOptions) => {
1717
let url = options.url
1818
if (options.authId) {
19-
url = `${url}?vite_devtools_auth_id=${encodeURIComponent(options.authId)}`
19+
url = `${url}?vite_devtools_auth_token=${encodeURIComponent(options.authId)}`
2020
}
2121
const ws = new WebSocket(url)
2222
const {

packages/self-inspect/src/node/rpc/functions/get-auth-tokens.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export const getAuthTokens = defineRpcFunction({
1010
return {
1111
handler: async () => {
1212
const trusted = storage.value().trusted
13-
return Object.values(trusted)
13+
return Object.values(trusted).filter(x => !!x)
1414
},
1515
}
1616
},

0 commit comments

Comments
 (0)