Дочинили авторизацию

This commit is contained in:
mi
2026-07-16 15:50:34 +03:00
parent d86e663690
commit 3a3d26bd6e
9 changed files with 118 additions and 5 deletions
@@ -40,7 +40,7 @@ const secureStore = {
};
const random = () => Crypto.randomUUID().replaceAll("-", "") + Crypto.randomUUID().replaceAll("-", "");
const redirectUri = AuthSession.makeRedirectUri({ scheme: "han-chat", path: "oauth/callback" });
const redirectUri = AuthSession.makeRedirectUri({ scheme: "han-chat", path: "auth/callback" });
const tokenEndpoint = `${oidcIssuer}/protocol/openid-connect/token`;
export function configureAuthFailure(callback: () => void) {
@@ -95,6 +95,10 @@ export async function beginAuthorization() {
state,
nonce,
})}`;
if (Platform.OS === "web" && typeof window !== "undefined") {
window.location.assign(url);
return new Promise<never>(() => undefined);
}
const result = await WebBrowser.openAuthSessionAsync(url, redirectUri);
if (result.type !== "success") return { type: result.type as "cancel" | "dismiss" };
const callback = new URL(result.url);