Skip to content

Commit 6c2c3bd

Browse files
committed
refactor(auth): fold the meta token into getStoredAuthToken's existing arg
Pass `options.authToken || connectionMeta.authToken` as the single token argument instead of adding a second parameter, per review.
1 parent 28a0593 commit 6c2c3bd

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

  • packages/devframe/src/client

packages/devframe/src/client/rpc.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -215,13 +215,9 @@ export interface DevframeRpcClientMode {
215215
callOptional: DevframeRpcClient['callOptional']
216216
}
217217

218-
function getStoredAuthToken(userAuthToken?: string, metaAuthToken?: string): string | undefined {
218+
function getStoredAuthToken(userAuthToken?: string): string | undefined {
219219
const getters = [
220-
// Explicit option wins, then a token baked into the (hub-served) meta —
221-
// the cross-origin channel a framed plugin relies on since it can't read
222-
// the hub's `localStorage` — then this origin's own stored token.
223220
() => userAuthToken,
224-
() => metaAuthToken,
225221
() => localStorage.getItem(CONNECTION_AUTH_TOKEN_KEY) ?? undefined,
226222
() => (window as any)?.[CONNECTION_AUTH_TOKEN_KEY],
227223
() => (globalThis as any)?.[CONNECTION_AUTH_TOKEN_KEY],
@@ -337,7 +333,10 @@ export async function getDevframeRpcClient(
337333
const context: DevframeRpcContext = {
338334
rpc: undefined!,
339335
}
340-
const authToken = getStoredAuthToken(options.authToken, connectionMeta.authToken)
336+
// An explicit option wins, then a token baked into the (hub-served) meta —
337+
// the cross-origin channel a framed plugin relies on since it can't read the
338+
// hub's `localStorage` — then this origin's own stored token.
339+
const authToken = getStoredAuthToken(options.authToken || connectionMeta.authToken)
341340
// Persist a resolved token so one supplied out-of-band — e.g. a host that
342341
// bootstraps trust by passing `authToken` (read from its own page URL query)
343342
// — survives reconnects. The token is still sent to the server via the WS

0 commit comments

Comments
 (0)