Skip to content

Commit 224f2e3

Browse files
committed
refactor(data-inspector): use devframe_auth_token for the SPA handshake param
Align the standalone attach URL's token param with devframe core's canonical DEVFRAME_AUTH_TOKEN_QUERY_PARAM ('devframe_auth_token'), which the WS transport already uses, so the CLI producer, the SPA consumer, and the socket handshake share one name and one source of truth instead of the bespoke di_token.
1 parent 79b5e48 commit 224f2e3

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

plugins/data-inspector/src/cli.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import process from 'node:process'
1717
import { fileURLToPath } from 'node:url'
1818
import { cac } from 'cac'
1919
import { createDevServer } from 'devframe/adapters/dev'
20-
import { DEVFRAME_CONNECTION_META_FILENAME } from 'devframe/constants'
20+
import { DEVFRAME_AUTH_TOKEN_QUERY_PARAM, DEVFRAME_CONNECTION_META_FILENAME } from 'devframe/constants'
2121
import { serveStaticNodeMiddleware } from 'devframe/utils/serve-static'
2222
import { getPort } from 'get-port-please'
2323
import pkg from '../package.json' with { type: 'json' }
@@ -103,7 +103,7 @@ export function createDataInspectorCli() {
103103
})
104104
})
105105
await new Promise<void>(done => server.listen(port, flags.host, done))
106-
const url = `http://${flags.host}:${port}/${token ? `?di_token=${token}` : ''}`
106+
const url = `http://${flags.host}:${port}/${token ? `?${DEVFRAME_AUTH_TOKEN_QUERY_PARAM}=${token}` : ''}`
107107
console.log(`data-inspector attached to ${websocket}`)
108108
console.log(`open ${url}`)
109109
})

plugins/data-inspector/src/spa/composables/rpc.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import type {
2626
SuggestOutcome,
2727
} from '../../engine'
2828
import { connectDevframe } from 'devframe/client'
29+
import { DEVFRAME_AUTH_TOKEN_QUERY_PARAM } from 'devframe/constants'
2930
import { reactive, shallowRef } from 'vue'
3031
import { runQuery, runQueryAtPath, skeletonOf, suggest as suggestQuery } from '../../engine'
3132

@@ -163,14 +164,15 @@ function createStaticBackend(dataset: StaticDataset): DataBackend {
163164

164165
/**
165166
* Read and strip the pre-shared auth token the attach CLI appends to the SPA
166-
* URL (`?di_token=…`), so it never lingers in the address bar or history.
167+
* URL (`?devframe_auth_token=…`), so it never lingers in the address bar or
168+
* history.
167169
*/
168170
function consumeAuthToken(): string | undefined {
169171
const params = new URLSearchParams(location.search)
170-
const token = params.get('di_token')
172+
const token = params.get(DEVFRAME_AUTH_TOKEN_QUERY_PARAM)
171173
if (!token)
172174
return undefined
173-
params.delete('di_token')
175+
params.delete(DEVFRAME_AUTH_TOKEN_QUERY_PARAM)
174176
const search = params.toString()
175177
history.replaceState(null, '', search ? `?${search}` : location.pathname)
176178
return token

0 commit comments

Comments
 (0)