Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions packages/kit/src/client/connection.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { getDevToolsRpcClient } from './connection'

const mocks = vi.hoisted(() => ({
getDevframeRpcClient: vi.fn(async () => ({})),
}))

vi.mock('@devframes/hub/client', () => ({
getDevframeRpcClient: mocks.getDevframeRpcClient,
}))

describe('getDevToolsRpcClient', () => {
beforeEach(() => {
mocks.getDevframeRpcClient.mockClear()
})

it('disables devframe simple auth in favor of the Vite DevTools auth UI', async () => {
await getDevToolsRpcClient({ baseURL: '/__devtools/' })

expect(mocks.getDevframeRpcClient).toHaveBeenCalledWith({
baseURL: '/__devtools/',
simpleAuth: false,
})
})

it('does not allow callers to enable the browser-prompt fallback', async () => {
await getDevToolsRpcClient({ simpleAuth: true })

expect(mocks.getDevframeRpcClient).toHaveBeenCalledWith({
simpleAuth: false,
})
})
})
8 changes: 7 additions & 1 deletion packages/kit/src/client/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,15 @@ import { getDevframeRpcClient } from '@devframes/hub/client'
* `__connection.json` without dialing its own base's (wrong) endpoint — is
* handled natively by devframe's client via `ConnectionMeta.baseUrl` since
* devframe 0.7.2 (devframes/devframe#98), so no extra rewriting is needed here.
*
* Vite DevTools provides its own interactive authorization view, so disable
* devframe's native browser-prompt fallback for every kit-managed connection.
*/
export function getDevToolsRpcClient(
options: DevframeRpcClientOptions = {},
): Promise<DevframeRpcClient> {
return getDevframeRpcClient(options)
return getDevframeRpcClient({
...options,
simpleAuth: false,
})
}
Loading