MCPcopy
hub / github.com/mountain-loop/yaak / dynamic

Function dynamic

plugins/auth-oauth2/src/index.ts:319–346  ·  view source on GitHub ↗
(_ctx, { values })

Source from the content-addressed store, hash-verified

317 type: "markdown",
318 content: "Redirect URI to Register",
319 async dynamic(_ctx, { values }) {
320 const grantType = String(values.grantType ?? defaultGrantType);
321 const useExternalBrowser = !!values.useExternalBrowser;
322 const callbackType = (stringArg(values, "callbackType") ||
323 "localhost") as CallbackType;
324
325 // Only show for authorization_code and implicit with external browser enabled
326 if (
327 !["authorization_code", "implicit"].includes(grantType) ||
328 !useExternalBrowser
329 ) {
330 return { hidden: true };
331 }
332
333 // Compute the redirect URI based on callback type
334 const port = intArg(values, "callbackPort") || DEFAULT_LOCALHOST_PORT;
335 let redirectUri: string;
336 if (callbackType === "hosted") {
337 redirectUri = buildHostedCallbackRedirectUri(port);
338 } else {
339 redirectUri = `http://127.0.0.1:${port}/callback`;
340 }
341
342 return {
343 hidden: false,
344 content: `Register \`${redirectUri}\` as a redirect URI with your OAuth provider.`,
345 };
346 },
347 },
348 ],
349 },

Callers

nothing calls this directly

Calls 4

getTokenFunction · 0.90
stringArgFunction · 0.85
intArgFunction · 0.85

Tested by

no test coverage detected