This commit is contained in:
janisslsm committed 2026-11-01 12:12:55 +02:00
1 parent 1781d25a15
commit 732c0ad767
33051 files changed
+2591613 -3019689

No files matched your search

@@ -0,0 +1,147 @@
// Metro module 10981 (f10982).
import AuthenticationStore from "../../stores/AuthenticationStore";
import * as _BundleUpdater from "../../lib/native/BundleUpdater";
import { HTTP } from "../../_bundle/sendRequest";
import { getAPIEndpoint, APP_VERSION } from "./BuildOverrideUtils";
let c7395_2;
let env7395 = {};
const c7395_5 = "/__development/build_overrides";
let c7396_0 = async (c26894_0) => {
await _BundleUpdater.default.setBuildOverrideCookieHeader(c26894_0.headers["set-cookie"]);
};
c7395_2 = function() {
const apply = c7396_0.apply;
return c7396_0.apply(this, arguments);
};
export async function applyStaffBuildOverride(overrides) {
let r90;
let token, value;
let c26891_5 = 0;
let c30322_0;
try {
c30322_0 = void 0;
c26891_5 = 1;
const r39 = {
url: getAPIEndpoint(c7395_5),
body: {
overrides,
version: APP_VERSION
},
headers: null,
oldFormErrors: true,
rejectWithError: false
};
const token2 = AuthenticationStore.getToken();
token = token2;
if (token2 == null) {
token = "";
}
r39.headers = {
Authorization: token
};
c30322_0 = await HTTP.put(r39);
await (0, c7395_2)(c30322_0);
r90 = c30322_0;
c26891_5 = 0;
} catch ($e) {
const r32 = $e;
let r8 = r32;
value = r32;
if (c26891_5 !== 0) {
while (true) {
try {
c26891_5 = 0;
} catch (r95) {
r8 = r95;
value = r95;
if (c26891_5 === 0) {
break;
}
continue;
}
return value;
}
}
throw r8;
}
return r90;
}
export async function applyPublicBuildOverride(payload) {
let r84;
let value2;
let c26892_4 = 0;
let c30323_0;
try {
c30323_0 = void 0;
c26892_4 = 1;
c30323_0 = await HTTP.put({
url: getAPIEndpoint("/__development/link"),
body: {
payload,
token: AuthenticationStore.getToken(),
version: APP_VERSION
},
oldFormErrors: true,
rejectWithError: false
});
await (0, c7395_2)(c30323_0);
r84 = c30323_0;
c26892_4 = 0;
} catch ($e) {
const r30 = $e;
let r8 = r30;
value2 = r30;
if (c26892_4 !== 0) {
while (true) {
try {
c26892_4 = 0;
} catch (r89) {
r8 = r89;
value2 = r89;
if (c26892_4 === 0) {
break;
}
continue;
}
return value2;
}
}
throw r8;
}
return r84;
}
export async function clearBuildOverride() {
let c30324_0 = await HTTP.del({
url: getAPIEndpoint(c7395_5),
oldFormErrors: true,
rejectWithError: false
});
await (0, c7395_2)(c30324_0);
return c30324_0;
}
export function getPublicBuildOverrideLink(a0) {
const r14 = {
url: getAPIEndpoint("/__development/create_build_override_link"),
body: a0,
headers: null,
oldFormErrors: true,
rejectWithError: false
};
let Authorization = AuthenticationStore.getToken();
if (Authorization == null) {
Authorization = "";
}
r14.headers = {
Authorization
};
return HTTP.post(r14).then((result) => ({
url: result.body.url,
error: false
}), (a0) => a0.status === 400 ? {
url: false,
error: a0.body
} : {
url: false,
error: `Error making API request (${a0.status})`
});
}
@@ -0,0 +1,59 @@
// Metro module 4106 (f4107).
export const BUILD_OVERRIDE_TARGET_NAMES = {
discord_marketing: "Discord Marketing",
discord_web: "Discord Web",
discord_ios: "Discord iOS",
discord_android: "Discord Android",
discord_developers: "Discord Developers"
};
export const BUILD_OVERRIDE_EXPIRATION_OPTIONS = [{
id: "1hr",
value: 3600,
label: "1 Hour"
}, {
id: "1day",
value: 86400,
label: "1 Day"
}, {
id: "3days",
value: 259200,
label: "3 Days"
}, {
id: "1week",
value: 604800,
label: "1 Week"
}, {
id: "2weeks",
value: 1209600,
label: "2 Weeks"
}, {
id: "3weeks",
value: 1814400,
label: "3 Weeks"
}, {
id: "1month",
value: 2628000,
label: "1 Month"
}];
export const BUILD_OVERRIDE_RELEASE_CHANNEL_OPTIONS = [{
id: "all",
value: "all",
label: "All"
}, {
id: "canary",
value: "canary",
label: "Canary"
}, {
id: "ptb",
value: "ptb",
label: "PTB"
}, {
id: "stable",
value: "stable",
label: "Stable"
}, {
id: "staging",
value: "staging",
label: "Staging"
}];
export const BUILD_OVERRIDE_COOKIE_NAME = "buildOverride";
@@ -0,0 +1,94 @@
// Metro module 10468 (f10469).
import * as _BuildOverrideUtils from "./BuildOverrideUtils";
import { validateURL, getBuildOverrideMeta } from "./BuildOverrideUtils";
import Dispatcher from "../../Dispatcher";
import Module589 from "../../_bundle/Module589";
let c7015_3 = {
NotResolved: 0,
0: "NotResolved",
Resolving: 1,
1: "Resolving",
Resolved: 2,
2: "Resolved",
Invalid: 3,
3: "Invalid"
};
let NotResolved = c7015_3.NotResolved;
const overrides = null;
let c7015_6 = {};
class BuildOverrideStore extends Module589.Store {
static displayName = "BuildOverrideStore";
getCurrentBuildOverride() {
if (NotResolved === c7015_3.NotResolved) {
NotResolved = c7015_3.Resolving;
_BuildOverrideUtils.getBuildOverride().then((result) => {
Dispatcher.dispatch({
type: "CURRENT_BUILD_OVERRIDE_RESOLVED",
overrides: result
});
});
}
return {
state: NotResolved,
overrides
};
}
getBuildOverride(a0) {
const url = a0;
if (!(a0 in c7015_6)) {
const r17 = validateURL(a0);
if (r17 != null) {
const r21 = {
...c7015_6
};
r21[a0] = {
url: a0,
validatedURL: r17.url,
payload: String(r17.payload),
state: c7015_3.Resolving
};
c7015_6 = r21;
getBuildOverrideMeta(r17.url).then((result) => {
Dispatcher.dispatch({
type: "BUILD_OVERRIDE_RESOLVED",
url,
override: result
});
});
} else {
const r18 = {
...c7015_6
};
r18[a0] = {
url: a0,
state: c7015_3.Invalid
};
c7015_6 = r18;
}
}
return c7015_6[a0];
}
getBuildOverrides() {
return c7015_6;
}
}
const buildOverrideStore = new BuildOverrideStore(Dispatcher, {
BUILD_OVERRIDE_RESOLVED: function handleBuildOverrideResolved({ url: url2, override }) {
const state = override == null ? c7015_3.Invalid : c7015_3.Resolved;
const r12 = {
...c7015_6
};
r12[url2] = {
...c7015_6[url2],
state,
override
};
c7015_6 = r12;
},
CURRENT_BUILD_OVERRIDE_RESOLVED: function handleCurrentBuildOverrideResolved({ overrides: overrides2 }) {
NotResolved = c7015_3.Resolved;
overrides = overrides2;
}
});
export default buildOverrideStore;
export { c7015_3 as State };
@@ -0,0 +1,156 @@
// Metro module 4105 (f4106).
import { BUILD_OVERRIDE_COOKIE_NAME } from "./BuildOverrideConstants";
import { PRIMARY_DOMAIN } from "../../Constants";
import { getConstants } from "../../utils/native/ClientInfoUtils";
import { isAndroid, isIOS, getNativePlatform } from "../../utils/PlatformUtils";
import URLUtils from "../../utils/URLUtils";
import { HTTP } from "../../_bundle/sendRequest";
import { format } from "../../_bundle/Url_1469";
import Module4107 from "../../_bundle/Module4107";
let version, c2364_6, c2364_7, c2364_8, c2364_9;
PRIMARY_DOMAIN;
const constants = getConstants();
const r39 = isAndroid() ? constants.Version.split(" - ")[0] : isIOS() ? constants.Version : void 0;
export function getAPIEndpoint(a0) {
return `${location.protocol}//${location.host}${a0}`;
}
export function isManualBuildOverrideLink(a0) {
return a0 != null && c2364_7.test(a0);
}
export function manualOverrideLinkMeta(a0) {
const r9 = a0.match(c2364_7);
if (r9 != null && r9.length === 2) {
const nativePlatform = getNativePlatform();
const id = r9[1];
const targetBuildOverride = {};
targetBuildOverride[`discord_${nativePlatform}`] = {
type: "branch",
id
};
return {
targetBuildOverride,
validForUserIds: [],
expiresAt: "Mon, 1 Jan 2038 00:00:00 GMT"
};
}
return null;
}
version = r39;
c2364_6 = new RegExp("^https://(?:ptb\\.|canary\\.)?(discordapp|discord)\\.com/__development/link?[\\S]+$", "i");
c2364_7 = new RegExp("^dev://branch/([\\w-./]+)$", "i");
c2364_8 = new Set(["canary.discord.com", "ptb.discord.com", "discord.com", "canary.discordapp.com", "ptb.discordapp.com", "discordapp.com"]);
c2364_9 = new Set(["/__development/link", "/__development/link/"]);
export { version as APP_VERSION };
export function getBuildOverride() {
let r40;
const r8 = URLUtils.safeParseWithQuery(`${location.protocol}//${location.host}/__development/build_overrides`);
if (r8 == null) {
r40 = Promise.resolve(null);
} else {
r8.search = null;
if (version) {
r8.query.version = version;
}
r40 = HTTP.get({
url: format(r8),
oldFormErrors: true,
rejectWithError: false
}).then((result) => result.body || null, () => null);
}
return r40;
}
export function getBuildOverrideMeta(a0) {
let r38;
if (a0 != null && c2364_7.test(a0)) {
const r43 = Promise;
const r47 = a0.match(c2364_7);
const r48 = r47 == null;
let r49 = null;
if (!r48) {
const length = r47.length;
r49 = null;
if (length === 2) {
const nativePlatform = getNativePlatform();
const id = r47[1];
const targetBuildOverride = {};
targetBuildOverride[`discord_${nativePlatform}`] = {
type: "branch",
id
};
r49 = {
targetBuildOverride,
validForUserIds: [],
expiresAt: "Mon, 1 Jan 2038 00:00:00 GMT"
};
}
}
return r43.resolve(r49);
}
const r10 = URLUtils.safeParseWithQuery(a0);
if (r10 == null) {
r38 = Promise.resolve(null);
} else {
r10.search = null;
r10.query.meta = "true";
if (version) {
r10.query.version = version;
}
r10.host = window.location.host;
r38 = HTTP.get({
url: format(r10),
oldFormErrors: true,
rejectWithError: false
}).then((result) => result.body || null, () => null);
}
return r38;
}
export function probablyHasBuildOverride() {
return window.document.cookie.indexOf(`${BUILD_OVERRIDE_COOKIE_NAME}=`) !== -1;
}
export function getBuildOverrideExperiments() {
let r31;
try {
const r16 = Module4107.parse(window.document.cookie)[BUILD_OVERRIDE_COOKIE_NAME];
if (r16 == null) {
r31 = {};
} else {
const r19 = JSON;
const r21 = atob;
r31 = r19.parse(r21(r16.substring(r16.indexOf(".") + 1))).$meta.experiments;
if (r31 == null) {
r31 = {};
}
}
} catch ($e) {
return {};
}
return r31;
}
export function isBuildOverrideLink(a0) {
return a0 != null && c2364_6.test(a0);
}
export function validateURL(a0) {
if (a0 != null && c2364_7.test(a0)) {
return {
payload: null,
url: a0
};
}
const r19 = URLUtils.safeParseWithQuery(a0);
if (r19 == null) {
return null;
}
if (c2364_8.has(r19.hostname) && "s" in r19.query && c2364_9.has(r19.pathname)) {
const query = r19.query;
for (const key in query) {
if (key !== "s") {
delete r19.query[key];
}
}
return {
payload: r19.query.s,
url: format(r19)
};
}
return null;
}
@@ -0,0 +1,111 @@
// Metro module 13008 (f13009).
import { Image as Image2, View } from "react-native";
import BuildOverrideStore from "../BuildOverrideStore";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import Module712 from "../../../_bundle/Module712";
import useTheme from "../../../hooks/useTheme";
import { isThemeDark } from "../../../design/shared";
import Module13009 from "../../../_bundle/Module13009";
import Module13010 from "../../../_bundle/Module13010";
import { useStateFromStores } from "../../../_bundle/Module589";
import { DEVICE_FIELD, setBuildOverrideFromLink } from "./BuildOverrideUtils";
import Module3771 from "../../../_bundle/Module3771";
import { SafeAreaPaddingView } from "../../../components_native/common/SafeAreaView";
import { Text } from "../../../design/components/Text/native/Text";
import { intl, t } from "../../../intl/index.native";
import { Button } from "../../../design/components/Button/native/Button.native";
import ModalActionCreators from "../../../actions/ModalActionCreators";
const useStyles = createStyles({
container: {
flex: 1,
height: "100%",
alignItems: "center",
backgroundColor: Module712.colors.BACKGROUND_BASE_LOWER,
paddingHorizontal: 16
},
content: {
marginTop: 160,
flex: 1,
alignItems: "center"
},
imageWrapper: {
width: 100,
height: 100,
borderRadius: Module712.radii.round,
marginBottom: 16,
backgroundColor: Module712.colors.BACKGROUND_BASE_LOWEST,
alignItems: "center",
justifyContent: "center"
},
text: {
lineHeight: 24,
textAlign: "center"
},
buildOverrideName: {
marginTop: 8
},
buildOverrideExpiration: {
lineHeight: 24
},
buildOverrideInvalid: {
marginTop: 8
},
buttonWrapper: {
alignSelf: "stretch"
},
actionButton: {
marginBottom: 8
}
});
export default function BuildOverrideModal(props) {
let overrideUrl = props.overrideUrl;
if (overrideUrl === void 0) {
overrideUrl = "";
}
let c20336_0 = overrideUrl;
const styles = useStyles();
const source = isThemeDark(useTheme()) ? Module13009 : Module13010;
const stateFromStores = useStateFromStores([BuildOverrideStore], () => BuildOverrideStore.getBuildOverride(c20336_0), [overrideUrl]);
const override = stateFromStores.override;
const r2 = override == null;
let r10 = void 0;
if (!r2) {
const targetBuildOverride = override.targetBuildOverride;
r10 = targetBuildOverride == null ? void 0 : targetBuildOverride[DEVICE_FIELD]?.id;
}
const expirationDuration = Module3771.duration(Module3771().diff(override?.expiresAt)).humanize();
return <SafeAreaPaddingView top bottom style={styles.container}>
<View style={styles.content}>
<View style={styles.imageWrapper}>
<Image2 source={source} />
</View>
<Text style={styles.text} variant="text-md/medium">
{intl.string(t["6ILkNN"])}
</Text>
{r10 != null ? <>
<Text style={styles.buildOverrideName} variant="heading-xl/extrabold" color="mobile-text-heading-primary">{r10}</Text>
<Text style={styles.buildOverrideExpiration} variant="text-md/medium" color="text-default">
{intl.format(t.lOsPpu, {
expirationDuration
})}
</Text>
</> : <Text style={styles.buildOverrideInvalid} variant="heading-xl/extrabold" color="mobile-text-heading-primary">
{intl.string(t["cz+sue"])}
</Text>}
</View>
<View style={styles.buttonWrapper}>
{r10 != null ? <>
<View style={styles.actionButton}>
<Button text={intl.string(t.v0MBqF)} grow onPress={() => {
let validatedURL = stateFromStores.validatedURL;
if (validatedURL == null) {
validatedURL = "";
}
setBuildOverrideFromLink(validatedURL);
}} />
</View>
<Button text={intl.string(t.b5KKph)} variant="secondary" grow onPress={() => ModalActionCreators.pop()} />
</> : <Button text={intl.string(t.WRkdCQ)} grow onPress={() => ModalActionCreators.pop()} />}
</View>
</SafeAreaPaddingView>;
};
@@ -0,0 +1,142 @@
// Metro module 10980 (f10981).
import BuildOverrideStore from "../BuildOverrideStore";
import { isAndroid } from "../../../utils/PlatformUtils";
import * as _ApplyBuildOverrideUtils from "../ApplyBuildOverrideUtils";
import { applyStaffBuildOverride, applyPublicBuildOverride } from "../ApplyBuildOverrideUtils";
import BundleUpdater from "../../../lib/native/BundleUpdater";
import AlertActionCreators from "../../../actions/native/AlertActionCreators";
import { isManualBuildOverrideLink } from "../BuildOverrideUtils";
let c7394_5, setBuildOverride, clearBuildOverride;
const setBuildOverrideForBranch = function setBuildOverrideForBranch(a0) {
setBuildOverride({
type: "branch",
id: a0
});
};
setBuildOverride = async function setBuildOverride(c26887_0) {
let c26887_2;
c26887_2 = void 0;
const r28 = {};
r28[c7394_5] = c26887_0;
let c30318_0 = await applyStaffBuildOverride(r28);
if (c30318_0.status !== 400) {
BundleUpdater.checkForUpdateAndReload();
} else {
AlertActionCreators.show({
title: "Override Error",
body: c30318_0.body[c7394_5],
isDismissable: true
});
}
};
clearBuildOverride = async function clearBuildOverride() {
let c26888_1;
c26888_1 = void 0;
let c30319_0 = await _ApplyBuildOverrideUtils.clearBuildOverride();
if (c30319_0.status !== 400) {
BundleUpdater.checkForUpdateAndReload();
} else {
AlertActionCreators.show({
title: "Clear Override Error",
body: c30319_0.body,
isDismissable: true
});
}
};
c7394_5 = isAndroid() ? "discord_android" : "discord_ios";
export { c7394_5 as DEVICE_FIELD };
export { setBuildOverrideForBranch };
export function setBuildOverrideForId(a0) {
setBuildOverride({
type: "id",
id: a0
});
}
export { setBuildOverride };
export function refreshBuildOverride() {
BundleUpdater.checkForUpdateAndReload();
}
export { clearBuildOverride };
export async function toggleOverride(c26889_0) {
let c26889_2;
let c30320_0;
L28: {
L27: {
L21: {
c26889_2 = void 0;
c30320_0 = void 0;
const overrides = BuildOverrideStore.getCurrentBuildOverride().overrides;
const r14 = overrides == null ? void 0 : overrides[c7394_5]?.id;
const buildOverride = BuildOverrideStore.getBuildOverride(c26889_0);
const override = buildOverride.override;
const r16 = override == null;
let r34 = void 0;
if (!r16) {
const targetBuildOverride = override.targetBuildOverride;
r34 = targetBuildOverride == null ? void 0 : targetBuildOverride[c7394_5]?.id;
}
if (r14 === r34) {
clearBuildOverride();
break L28;
}
if (buildOverride.payload == null) {
break L28;
}
if (isManualBuildOverrideLink(c26889_0) && r34 != null) {
setBuildOverrideForBranch(r34);
break L21;
}
c30320_0 = await applyPublicBuildOverride(buildOverride.payload);
if (c30320_0.status !== 400) {
BundleUpdater.checkForUpdateAndReload();
break L27;
}
AlertActionCreators.show({
title: "Override Error",
body: c30320_0.body[c7394_5],
isDismissable: true
});
break L27;
}
return void 0;
}
return void 0;
}
}
export async function setBuildOverrideFromLink(c26890_0) {
let c26890_2;
let c30321_0;
L23: {
L22: {
c26890_2 = void 0;
c30321_0 = void 0;
const overrides = BuildOverrideStore.getCurrentBuildOverride().overrides;
const r14 = overrides == null ? void 0 : overrides[c7394_5]?.id;
const buildOverride = BuildOverrideStore.getBuildOverride(c26890_0);
const override = buildOverride.override;
const r33 = override == null;
let r34 = void 0;
if (!r33) {
const targetBuildOverride = override.targetBuildOverride;
r34 = targetBuildOverride == null ? void 0 : targetBuildOverride[c7394_5]?.id;
}
if (r14 === r34) {
break L23;
}
if (buildOverride.payload == null) {
break L23;
}
c30321_0 = await applyPublicBuildOverride(buildOverride.payload);
if (c30321_0.status !== 400) {
BundleUpdater.checkForUpdateAndReload();
break L22;
}
AlertActionCreators.show({
title: "Override Error",
body: c30321_0.body[c7394_5],
isDismissable: true
});
}
return void 0;
}
}
@@ -0,0 +1,79 @@
// Metro module 12365 (f12366).
import _slicedToArray from "../../_bundle/_slicedToArray";
import AuthenticationStore from "../../stores/AuthenticationStore";
import { BUILD_OVERRIDE_TARGET_NAMES } from "./BuildOverrideConstants";
import { PublicReleaseChannels } from "../../Constants";
import { intl, t } from "../../intl/index.native";
import Module12 from "../../_bundle/Module12";
export default function validateBuildOverride(a0, a1, a2) {
if (a0 != null && a1 != null) {
const { releaseChannel, expiresAt, validForUserIds, allowedVersions } = a0;
const r35 = Object.keys(a0.targetBuildOverride);
if (Module12.intersection(r35, a1).length === 0) {
return {
valid: false,
reason: intl.formatToPlainString(t.wySUzv, {
requestedTargets: r35.map((item) => {
let r4 = BUILD_OVERRIDE_TARGET_NAMES[item];
if (r4 == null) {
r4 = "unknown";
}
return r4;
}).join(", ")
})
};
}
if (releaseChannel != null && releaseChannel !== window.GLOBAL_ENV.RELEASE_CHANNEL) {
return {
valid: false,
reason: intl.formatToPlainString(t.GOEF0C, {
releaseChannel: releaseChannel === PublicReleaseChannels.PTB ? releaseChannel.toUpperCase() : `${releaseChannel.charAt(0).toUpperCase()}${releaseChannel.slice(1)}`
})
};
}
if (allowedVersions != null) {
let r46 = false;
if (a2 == null) {
r46 = false;
} else if (allowedVersions.includes(a2)) {
r46 = true;
} else {
const [r16] = a2.split(".");
for (const item of allowedVersions) {
const r61 = _slicedToArray(item.split("."), 2);
const r62 = r61[0];
if (r61[1] !== "*") {
continue;
}
if (r16 !== r62) {
continue;
}
r46 = true;
break;
}
}
if (!r46) {
return {
valid: false,
reason: intl.formatToPlainString(t.GOEF0C, {
releaseChannel: allowedVersions.join(", ")
})
};
}
}
const r84 = expiresAt != null ? new Date(expiresAt).getTime() : null;
return r84 != null && r84 < Date.now() ? {
valid: false,
reason: intl.string(t["8eRE6S"])
} : validForUserIds.length > 0 && !validForUserIds.includes(AuthenticationStore.getId()) ? {
valid: false,
reason: intl.string(t.qZgV0a)
} : {
valid: true
};
}
return {
valid: false,
reason: intl.string(t.d34xi4)
};
};