()
| 71 | // signIn kicks off the PKCE flow. The function does not return — the tab |
| 72 | // navigates away to OpenRouter. |
| 73 | export async function signIn() { |
| 74 | const verifier = randomVerifier(); |
| 75 | sessionStorage.setItem(VERIFIER_KEY, verifier); |
| 76 | const challenge = await s256(verifier); |
| 77 | |
| 78 | const url = new URL("https://openrouter.ai/auth"); |
| 79 | url.searchParams.set("callback_url", callbackURL()); |
| 80 | url.searchParams.set("code_challenge", challenge); |
| 81 | url.searchParams.set("code_challenge_method", "S256"); |
| 82 | |
| 83 | location.assign(url.toString()); |
| 84 | } |
| 85 | |
| 86 | // handleCallback completes the PKCE flow if the page was loaded with a `code` |
| 87 | // query parameter. It removes the param from the URL on success so a refresh |
nothing calls this directly
no test coverage detected