MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / bootstrapLocalAuthToken

Function bootstrapLocalAuthToken

packages/react/src/api/local-auth.tsx:60–92  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

58 * localStorage. Identical in dev and prod.
59 */
60export const bootstrapLocalAuthToken = (): void => {
61 const url = globalThis.window ? new URL(window.location.href) : null;
62 const fromUrl = url?.searchParams.get("_token") ?? null;
63 const stripCacheBust = url?.searchParams.has(DESKTOP_LAUNCH_CACHE_BUST_PARAM) ?? false;
64 if (stripCacheBust) {
65 url!.searchParams.delete(DESKTOP_LAUNCH_CACHE_BUST_PARAM);
66 }
67
68 if (isDesktopBridge()) {
69 if (fromUrl) {
70 url!.searchParams.delete("_token");
71 }
72 if (stripCacheBust || fromUrl) {
73 globalThis.window?.history?.replaceState(null, "", url!.pathname + url!.search + url!.hash);
74 }
75 return;
76 }
77
78 if (fromUrl) {
79 persistToken(fromUrl);
80 url!.searchParams.delete("_token");
81 globalThis.window?.history?.replaceState(null, "", url!.pathname + url!.search + url!.hash);
82 applyBearer(fromUrl);
83 return;
84 }
85
86 if (stripCacheBust) {
87 globalThis.window?.history?.replaceState(null, "", url!.pathname + url!.search + url!.hash);
88 }
89
90 const stored = readStoredToken();
91 if (stored) applyBearer(stored);
92};
93
94/**
95 * Persist a token entered manually (the login gate) and reload. The gate

Callers 1

entry-client.tsxFile · 0.90

Calls 6

isDesktopBridgeFunction · 0.85
persistTokenFunction · 0.85
applyBearerFunction · 0.85
readStoredTokenFunction · 0.85
getMethod · 0.65
deleteMethod · 0.65

Tested by

no test coverage detected