60 lines
2.2 KiB
TypeScript
60 lines
2.2 KiB
TypeScript
// Metro module 11001 (f11002).
|
|
import { OAUTH2_ERROR_RESULT_MODAL_KEY, OAUTH2_SUCCESS_RESULT_MODAL_KEY } from "./Constants";
|
|
import ModalActionCreators from "../../../actions/ModalActionCreators";
|
|
import URLUtils from "../../../utils/URLUtils";
|
|
import { getBrowserManagerSelectedBrowser } from "../../links/native/BrowserManager";
|
|
import { WebBrowserType } from "../../../ConstantsIOS";
|
|
import Linking from "../../../lib/native/Linking";
|
|
let c7411_5 = /oauth2\/authorized/;
|
|
let c7411_6 = /oauth2\/error/;
|
|
export default function authorizeCallback(a0) {
|
|
const { location: location2, canceled, application, guild } = a0;
|
|
let wasDeepLink = a0.wasDeepLink;
|
|
if (location2 != null) {
|
|
let r32 = URLUtils.toURLSafe(location2);
|
|
if (r32 == null) {
|
|
r32 = {};
|
|
}
|
|
const { host, pathname, searchParams } = r32;
|
|
if (host != null && URLUtils.isDiscordHostname(host) && pathname != null) {
|
|
if (pathname.match(c7411_5) != null) {
|
|
ModalActionCreators.pushLazy(import("./SuccessResult"), {
|
|
application,
|
|
guild
|
|
}, OAUTH2_SUCCESS_RESULT_MODAL_KEY);
|
|
return void 0;
|
|
}
|
|
if (pathname.match(c7411_6) != null) {
|
|
if (!canceled) {
|
|
const r70 = import("./ErrorResult");
|
|
const r71 = searchParams == null;
|
|
let error = void 0;
|
|
if (!r71) {
|
|
const r75 = searchParams.get("error_description");
|
|
error = r75 == null ? void 0 : r75.toString();
|
|
}
|
|
if (error == null) {
|
|
const r78 = searchParams == null;
|
|
let r79 = void 0;
|
|
if (!r78) {
|
|
const r81 = searchParams.get("error");
|
|
r79 = r81 == null ? void 0 : r81.toString();
|
|
}
|
|
error = r79;
|
|
}
|
|
ModalActionCreators.pushLazy(r70, {
|
|
error
|
|
}, OAUTH2_ERROR_RESULT_MODAL_KEY);
|
|
}
|
|
return void 0;
|
|
}
|
|
}
|
|
if (wasDeepLink) {
|
|
wasDeepLink = getBrowserManagerSelectedBrowser() === WebBrowserType.IN_APP;
|
|
}
|
|
Linking.openURL(location2, wasDeepLink ? WebBrowserType.SAFARI : void 0);
|
|
} else if (!canceled) {
|
|
ModalActionCreators.pushLazy(import("./ErrorResult"), void 0, OAUTH2_ERROR_RESULT_MODAL_KEY);
|
|
}
|
|
};
|