MCPcopy Index your code
hub / github.com/CapSoftware/Cap / createHybridDesktopSession

Function createHybridDesktopSession

apps/desktop/src/utils/auth.ts:95–122  ·  view source on GitHub ↗
(signal: AbortSignal)

Source from the content-addressed store, hash-verified

93}
94
95async function createHybridDesktopSession(signal: AbortSignal) {
96 const deepLink = await startDeepLinkSession(signal);
97 const localCallback = await startLocalCallbackSession(signal);
98
99 return {
100 url: await createSessionRequestUrl(localCallback.port, "desktop"),
101 complete: async () => {
102 const result = await Promise.race([
103 deepLink.complete.then((data) => ({
104 source: "deep-link" as const,
105 data,
106 })),
107 localCallback.complete.then((data) => ({
108 source: "local" as const,
109 data,
110 })),
111 ]);
112
113 await deepLink.dispose();
114 await localCallback.dispose();
115
116 if (!result.data) return null;
117 if (signal.aborted) throw new Error("Sign in aborted");
118
119 return result.data;
120 },
121 };
122}
123
124async function startLocalCallbackSession(signal: AbortSignal) {
125 await invoke("plugin:oauth|stop").catch(() => {});

Callers 1

createSignInMutationFunction · 0.85

Calls 4

startDeepLinkSessionFunction · 0.85
disposeMethod · 0.80
createSessionRequestUrlFunction · 0.70

Tested by

no test coverage detected