Skip to content

Commit 69316c4

Browse files
committed
fix: require auth token with getImageMeta and getTextAssetContent
1 parent 4abd280 commit 69316c4

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ export interface ServerFunctions {
5454
clearAnalyzeBuilds(token: string, names?: string[]): Promise<void>
5555

5656
// Queries
57-
getImageMeta(filepath: string): Promise<ImageMeta | undefined>
58-
getTextAssetContent(filepath: string, limit?: number): Promise<string | undefined>
57+
getImageMeta(token: string, filepath: string): Promise<ImageMeta | undefined>
58+
getTextAssetContent(token: string, filepath: string, limit?: number): Promise<string | undefined>
5959
writeStaticAssets(token: string, file: AssetEntry[], folder: string): Promise<string[]>
6060
deleteStaticAsset(token: string, filepath: string): Promise<void>
6161
renameStaticAsset(token: string, oldPath: string, newPath: string): Promise<void>

packages/devtools/client/components/AssetDetails.vue

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,10 @@ const props = defineProps<{
99
const emit = defineEmits<{ (...args: any): void }>()
1010
const asset = useVModel(props, 'modelValue', emit, { passive: true })
1111
12-
const openInEditor = useOpenInEditor()
13-
14-
const imageMeta = computedAsync(() => {
12+
const imageMeta = computedAsync(async () => {
1513
if (asset.value.type !== 'image')
1614
return undefined
17-
return rpc.getImageMeta(asset.value.filePath)
15+
return rpc.getImageMeta(await ensureDevAuthToken(), asset.value.filePath)
1816
})
1917
2018
const editDialog = ref(false)
@@ -27,7 +25,7 @@ const textContent = computedAsync(async () => {
2725
// eslint-disable-next-line no-unused-expressions
2826
textContentCounter.value
2927
30-
const content = await rpc.getTextAssetContent(asset.value.filePath)
28+
const content = await rpc.getTextAssetContent(await ensureDevAuthToken(), asset.value.filePath)
3129
newTextContent.value = content
3230
return content
3331
})

packages/devtools/src/server-rpc/assets.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ export function setupAssetsRPC({ nuxt, ensureDevAuthToken, refresh, options }: N
6969
async getStaticAssets() {
7070
return await scan()
7171
},
72-
async getImageMeta(filepath: string) {
72+
async getImageMeta(token: string, filepath: string) {
73+
await ensureDevAuthToken(token)
74+
7375
if (_imageMetaCache.has(filepath))
7476
return _imageMetaCache.get(filepath)
7577
try {
@@ -83,7 +85,9 @@ export function setupAssetsRPC({ nuxt, ensureDevAuthToken, refresh, options }: N
8385
return undefined
8486
}
8587
},
86-
async getTextAssetContent(filepath: string, limit = 300) {
88+
async getTextAssetContent(token: string, filepath: string, limit = 300) {
89+
await ensureDevAuthToken(token)
90+
8791
try {
8892
const content = await fsp.readFile(filepath, 'utf-8')
8993
return content.slice(0, limit)

0 commit comments

Comments
 (0)