Skip to content

Commit 4418e61

Browse files
antfuclaude
andauthored
feat!: remove deprecated auth token args from builtin RPC functions (#965)
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 836ee1c commit 4418e61

25 files changed

Lines changed: 73 additions & 131 deletions

packages/devtools-kit/src/_types/rpc.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export interface ServerFunctions {
1313
// Static RPCs (can be provide on production build in the future)
1414
getServerConfig: () => NuxtOptions
1515
getServerDebugContext: () => Promise<ServerDebugContext | undefined>
16-
getServerData: (token: string) => Promise<NuxtServerData>
16+
getServerData: () => Promise<NuxtServerData>
1717
getServerRuntimeConfig: () => Record<string, any>
1818
getModuleOptions: () => ModuleOptions
1919
getComponents: () => Component[]
@@ -36,46 +36,46 @@ export interface ServerFunctions {
3636
// Updates
3737
checkForUpdateFor: (name: string) => Promise<PackageUpdateInfo | undefined>
3838
getNpmCommand: (command: NpmCommandType, packageName: string, options?: NpmCommandOptions) => Promise<string[] | undefined>
39-
runNpmCommand: (token: string, command: NpmCommandType, packageName: string, options?: NpmCommandOptions) => Promise<{ processId: string } | undefined>
39+
runNpmCommand: (command: NpmCommandType, packageName: string, options?: NpmCommandOptions) => Promise<{ processId: string } | undefined>
4040

4141
// Terminal
4242
getTerminals: () => TerminalInfo[]
43-
getTerminalDetail: (token: string, id: string) => Promise<TerminalInfo | undefined>
44-
runTerminalAction: (token: string, id: string, action: TerminalAction) => Promise<boolean>
43+
getTerminalDetail: (id: string) => Promise<TerminalInfo | undefined>
44+
runTerminalAction: (id: string, action: TerminalAction) => Promise<boolean>
4545

4646
// Storage
4747
getStorageMounts: () => Promise<StorageMounts>
4848
getStorageKeys: (base?: string) => Promise<string[]>
49-
getStorageItem: (token: string, key: string) => Promise<StorageValue>
50-
setStorageItem: (token: string, key: string, value: StorageValue) => Promise<void>
51-
removeStorageItem: (token: string, key: string) => Promise<void>
49+
getStorageItem: (key: string) => Promise<StorageValue>
50+
setStorageItem: (key: string, value: StorageValue) => Promise<void>
51+
removeStorageItem: (key: string) => Promise<void>
5252

5353
// Analyze
5454
getAnalyzeBuildInfo: () => Promise<AnalyzeBuildsInfo>
5555
generateAnalyzeBuildName: () => Promise<string>
56-
startAnalyzeBuild: (token: string, name: string) => Promise<string>
57-
clearAnalyzeBuilds: (token: string, names?: string[]) => Promise<void>
56+
startAnalyzeBuild: (name: string) => Promise<string>
57+
clearAnalyzeBuilds: (names?: string[]) => Promise<void>
5858

5959
// Queries
60-
getImageMeta: (token: string, filepath: string) => Promise<ImageMeta | undefined>
61-
getTextAssetContent: (token: string, filepath: string, limit?: number) => Promise<string | undefined>
62-
writeStaticAssets: (token: string, file: AssetEntry[], folder: string) => Promise<string[]>
63-
deleteStaticAsset: (token: string, filepath: string) => Promise<void>
64-
renameStaticAsset: (token: string, oldPath: string, newPath: string) => Promise<void>
60+
getImageMeta: (filepath: string) => Promise<ImageMeta | undefined>
61+
getTextAssetContent: (filepath: string, limit?: number) => Promise<string | undefined>
62+
writeStaticAssets: (file: AssetEntry[], folder: string) => Promise<string[]>
63+
deleteStaticAsset: (filepath: string) => Promise<void>
64+
renameStaticAsset: (oldPath: string, newPath: string) => Promise<void>
6565

6666
// Actions
6767
telemetryEvent: (payload: object, immediate?: boolean) => void
6868
customTabAction: (name: string, action: number) => Promise<boolean>
69-
enablePages: (token: string) => Promise<void>
69+
enablePages: () => Promise<void>
7070
openInEditor: (filepath: string) => Promise<boolean>
71-
restartNuxt: (token: string, hard?: boolean) => Promise<void>
72-
installNuxtModule: (token: string, name: string, dry?: boolean) => Promise<InstallModuleReturn>
73-
uninstallNuxtModule: (token: string, name: string, dry?: boolean) => Promise<InstallModuleReturn>
71+
restartNuxt: (hard?: boolean) => Promise<void>
72+
installNuxtModule: (name: string, dry?: boolean) => Promise<InstallModuleReturn>
73+
uninstallNuxtModule: (name: string, dry?: boolean) => Promise<InstallModuleReturn>
7474
enableTimeline: (dry: boolean) => Promise<[string, string]>
7575

7676
// Dev Token
7777
requestForAuth: (info?: string, origin?: string) => Promise<void>
78-
verifyAuthToken: (token: string) => Promise<boolean>
78+
verifyAuthToken: () => Promise<boolean>
7979
}
8080

8181
export interface ClientFunctions {

packages/devtools-kit/src/_types/server-ctx.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,6 @@ export interface NuxtDevtoolsServerContext {
4141
*/
4242
refresh: (event: keyof ServerFunctions) => void
4343

44-
/**
45-
* @deprecated Auth is now handled by Vite DevTools. This is a noop.
46-
*/
47-
ensureDevAuthToken: (token: string) => Promise<void>
48-
4944
extendServerRpc: <ClientFunctions extends object = Record<string, unknown>, ServerFunctions extends object = Record<string, unknown>>(name: string, functions: ServerFunctions) => BirpcGroup<ClientFunctions, ServerFunctions>
5045
}
5146

packages/devtools/client/app.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ onMounted(async () => {
7777
7878
if (!isDevAuthed.value) {
7979
if (devAuthToken.value) {
80-
const result = await rpc.verifyAuthToken(devAuthToken.value)
80+
const result = await rpc.verifyAuthToken()
8181
if (result)
8282
isDevAuthed.value = true
8383
}

packages/devtools/client/components/AssetDetails.vue

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import type { AssetInfo, CodeSnippet } from '~/../src/types'
33
import { devtoolsUiShowNotification } from '#imports'
44
import { computedAsync, useTimeAgo, useVModel } from '@vueuse/core'
55
import { computed, ref } from 'vue'
6-
import { ensureDevAuthToken } from '~/composables/dev-auth'
76
import { useCopy, useOpenInEditor } from '~/composables/editor'
87
import { rpc } from '~/composables/rpc'
98
import { useServerConfig } from '~/composables/state'
@@ -18,7 +17,7 @@ const asset = useVModel(props, 'modelValue', emit, { passive: true })
1817
const imageMeta = computedAsync(async () => {
1918
if (asset.value.type !== 'image')
2019
return undefined
21-
return rpc.getImageMeta(await ensureDevAuthToken(), asset.value.filePath)
20+
return rpc.getImageMeta(asset.value.filePath)
2221
})
2322
2423
const editDialog = ref(false)
@@ -31,15 +30,15 @@ const textContent = computedAsync(async () => {
3130
// eslint-disable-next-line ts/no-unused-expressions
3231
textContentCounter.value
3332
34-
const content = await rpc.getTextAssetContent(await ensureDevAuthToken(), asset.value.filePath)
33+
const content = await rpc.getTextAssetContent(asset.value.filePath)
3534
newTextContent.value = content
3635
return content
3736
})
3837
3938
async function saveTextContent() {
4039
if (textContent.value !== newTextContent.value) {
4140
try {
42-
await rpc.writeStaticAssets(await ensureDevAuthToken(), [{
41+
await rpc.writeStaticAssets([{
4342
path: asset.value.path,
4443
content: newTextContent.value,
4544
override: true,
@@ -134,7 +133,7 @@ const supportsPreview = computed(() => {
134133
const deleteDialog = ref(false)
135134
async function deleteAsset() {
136135
try {
137-
await rpc.deleteStaticAsset(await ensureDevAuthToken(), asset.value.filePath)
136+
await rpc.deleteStaticAsset(asset.value.filePath)
138137
asset.value = undefined as any
139138
deleteDialog.value = false
140139
devtoolsUiShowNotification({
@@ -170,7 +169,7 @@ async function renameAsset() {
170169
try {
171170
const extension = parts.slice(-1)[0]?.split('.').slice(-1)[0]
172171
const fullPath = `${parts.slice(0, -1).join('/')}/${newName.value}.${extension}`
173-
await rpc.renameStaticAsset(await ensureDevAuthToken(), asset.value.filePath, fullPath)
172+
await rpc.renameStaticAsset(asset.value.filePath, fullPath)
174173
asset.value = undefined as any
175174
renameDialog.value = false
176175
devtoolsUiShowNotification({

packages/devtools/client/components/AssetDropZone.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import type { AssetEntry } from '~/../src/types'
33
import { devtoolsUiShowNotification } from '#imports'
44
import { useEventListener, useVModel } from '@vueuse/core'
55
import { ref } from 'vue'
6-
import { ensureDevAuthToken } from '~/composables/dev-auth'
76
import { rpc, wsConnecting, wsError } from '~/composables/rpc'
87
import { telemetry } from '~/composables/telemetry'
98
@@ -95,7 +94,7 @@ async function uploadFiles() {
9594
content,
9695
})
9796
}
98-
await rpc.writeStaticAssets(await ensureDevAuthToken(), [...uploadFiles], props.folder).then(() => {
97+
await rpc.writeStaticAssets([...uploadFiles], props.folder).then(() => {
9998
close()
10099
devtoolsUiShowNotification({
101100
message: 'Files uploaded successfully!',

packages/devtools/client/components/BuildAnalyzeDetails.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import type { AnalyzeBuildMeta } from '../../src/types'
33
import { useRuntimeConfig } from '#imports'
44
import { formatTimeAgo } from '@vueuse/core'
55
import { computed, ref } from 'vue'
6-
import { ensureDevAuthToken } from '~/composables/dev-auth'
76
import { rpc } from '~/composables/rpc'
87
98
const props = defineProps<{
@@ -46,7 +45,7 @@ function formatFileSize(bytes: number) {
4645
}
4746
4847
async function clear(name: string) {
49-
return rpc.clearAnalyzeBuilds(await ensureDevAuthToken(), [name])
48+
return rpc.clearAnalyzeBuilds([name])
5049
}
5150
</script>
5251

packages/devtools/client/components/ModuleItemInstall.vue

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<script setup lang="ts">
22
import type { ModuleActionType, ModuleStaticInfo } from '../../src/types'
33
import { computed } from 'vue'
4-
import { ensureDevAuthToken } from '~/composables/dev-auth'
54
import { ModuleDialog } from '~/composables/dialog'
65
import { rpc } from '~/composables/rpc'
76
import { useInstalledModules } from '~/composables/state-modules'
@@ -21,7 +20,7 @@ const isUninstallable = computed(() => installedInfo.value && installedInfo.valu
2120
2221
async function useModuleAction(item: ModuleStaticInfo, type: ModuleActionType) {
2322
const method = type === 'install' ? rpc.installNuxtModule : rpc.uninstallNuxtModule
24-
const result = await method(await ensureDevAuthToken(), item.npm, true)
23+
const result = await method(item.npm, true)
2524
2625
telemetry(`modules:${type}`, {
2726
moduleName: item.npm,
@@ -41,7 +40,7 @@ async function useModuleAction(item: ModuleStaticInfo, type: ModuleActionType) {
4140
4241
emit('start')
4342
44-
await method(await ensureDevAuthToken(), item.npm, false)
43+
await method(item.npm, false)
4544
}
4645
4746
const anyObj = {} as any

packages/devtools/client/components/RestartDialogs.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import { useNuxtApp } from '#app/nuxt'
33
import { createTemplatePromise } from '@vueuse/core'
44
import { useClient } from '~/composables/client'
5-
import { ensureDevAuthToken } from '~/composables/dev-auth'
65
import { useRestartDialogs } from '~/composables/dialog'
76
import { rpc } from '~/composables/rpc'
87
@@ -22,7 +21,7 @@ nuxt.hook('devtools:terminal:exit', ({ id, code }) => {
2221
.start(dialog.message)
2322
.then(async (result) => {
2423
if (result) {
25-
rpc.restartNuxt(await ensureDevAuthToken())
24+
rpc.restartNuxt()
2625
setTimeout(() => {
2726
client.value?.app.reload()
2827
}, 500)

packages/devtools/client/components/StorageDetails.vue

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { computed, onUnmounted, ref, watch, watchEffect } from 'vue'
88
import { getColorMode } from '~/composables/client'
99
import { rpc } from '~/composables/rpc'
1010
import { useSessionState } from '~/composables/utils'
11-
import { ensureDevAuthToken } from '../composables/dev-auth'
1211
1312
const colorMode = getColorMode()
1413
const nuxtApp = useNuxtApp()
@@ -71,7 +70,7 @@ const filteredKeys = computed(() => {
7170
})
7271
7372
async function fetchItem(key: string) {
74-
const content = await rpc.getStorageItem(await ensureDevAuthToken(), key)
73+
const content = await rpc.getStorageItem(key)
7574
currentItem.value = {
7675
key,
7776
updatedKey: keyName(key),
@@ -87,7 +86,7 @@ async function saveNewItem() {
8786
// If does not exists
8887
const key = `${currentStorage.value}:${newKey.value}`
8988
if (!storageKeys.value?.includes(key))
90-
await rpc.setStorageItem(await ensureDevAuthToken(), key, '')
89+
await rpc.setStorageItem(key, '')
9190
9291
router.replace({ query: { storage: currentStorage.value, key } })
9392
newKey.value = ''
@@ -96,24 +95,23 @@ async function saveNewItem() {
9695
async function saveCurrentItem() {
9796
if (!currentItem.value)
9897
return
99-
await rpc.setStorageItem(await ensureDevAuthToken(), currentItem.value.key, currentItem.value.updatedContent)
98+
await rpc.setStorageItem(currentItem.value.key, currentItem.value.updatedContent)
10099
await fetchItem(currentItem.value.key)
101100
}
102101
103102
async function removeCurrentItem() {
104103
if (!currentItem.value || !currentStorage.value)
105104
return
106-
await rpc.removeStorageItem(await ensureDevAuthToken(), currentItem.value.key)
105+
await rpc.removeStorageItem(currentItem.value.key)
107106
currentItem.value = null
108107
}
109108
110109
async function renameCurrentItem() {
111110
if (!currentItem.value || !currentStorage.value)
112111
return
113112
const renamedKey = `${currentStorage.value}:${currentItem.value.updatedKey}`
114-
const token = await ensureDevAuthToken()
115-
await rpc.setStorageItem(token, renamedKey, currentItem.value.updatedContent)
116-
await rpc.removeStorageItem(token, currentItem.value.key)
113+
await rpc.setStorageItem(renamedKey, currentItem.value.updatedContent)
114+
await rpc.removeStorageItem(currentItem.value.key)
117115
router.replace({ query: { storage: currentStorage.value, key: renamedKey } })
118116
}
119117
</script>

packages/devtools/client/components/TerminalPage.vue

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<script setup lang="ts">
22
import { computed, watchEffect } from 'vue'
3-
import { ensureDevAuthToken } from '~/composables/dev-auth'
43
import { rpc } from '~/composables/rpc'
54
import { useTerminals } from '~/composables/state'
65
import { useCurrentTerminalId } from '~/composables/state-routes'
@@ -9,8 +8,8 @@ const terminals = useTerminals()
98
const terminalId = useCurrentTerminalId()
109
const selected = computed(() => terminals.value?.find(t => t.id === terminalId.value))
1110
12-
async function remove(id: string) {
13-
rpc.runTerminalAction(await ensureDevAuthToken(), id, 'remove')
11+
function remove(id: string) {
12+
rpc.runTerminalAction(id, 'remove')
1413
}
1514
1615
watchEffect(() => {

0 commit comments

Comments
 (0)