63 lines
2.8 KiB
TypeScript
63 lines
2.8 KiB
TypeScript
// Metro module 8202 (f8203).
|
|
import { SPOTIFY_HOSTNAMES } from "../modules/spotify/SpotifyConstants";
|
|
import { getHostname, getProtocol } from "./MaskedLinkStoreMethodsAdditional.native";
|
|
import URLUtils from "../utils/URLUtils";
|
|
import { Storage } from "../_bundle/Module595";
|
|
import Module589 from "../_bundle/Module589";
|
|
import Dispatcher from "../Dispatcher";
|
|
let c5211_4 = "MaskedLinkStore";
|
|
let trustedDomains = new Set();
|
|
let trustedProtocols = new Set();
|
|
const MEDIA_PROXY_ENDPOINT = window.GLOBAL_ENV.MEDIA_PROXY_ENDPOINT;
|
|
let c5211_7 = MEDIA_PROXY_ENDPOINT == null ? void 0 : MEDIA_PROXY_ENDPOINT.replace("//", "");
|
|
class MaskedLinkStore extends Module589.Store {
|
|
static displayName = "MaskedLinkStore";
|
|
initialize() {
|
|
let r18 = Storage.get(c5211_4);
|
|
if (r18 == null) {
|
|
r18 = {};
|
|
}
|
|
const isArray = Array.isArray(r18);
|
|
const r8 = r18;
|
|
if (isArray) {
|
|
trustedDomains = new Set(r8 != null ? Array.from(r8) : null);
|
|
trustedProtocols = new Set();
|
|
} else {
|
|
const { trustedDomains: trustedDomains2, trustedProtocols: trustedProtocols2 } = r8;
|
|
trustedDomains = new Set(trustedDomains2 != null ? Array.from(trustedDomains2) : null);
|
|
trustedProtocols = new Set(trustedProtocols2 != null ? Array.from(trustedProtocols2) : null);
|
|
}
|
|
}
|
|
isTrustedDomain(a0) {
|
|
const hostname = getHostname(a0);
|
|
return window.GLOBAL_ENV.INVITE_HOST !== hostname ? window.GLOBAL_ENV.GIFT_CODE_HOST !== hostname ? window.GLOBAL_ENV.GUILD_TEMPLATE_HOST !== hostname ? c5211_7 !== hostname ? location.hostname !== hostname ? SPOTIFY_HOSTNAMES.includes(hostname) || URLUtils.isDiscordHostname(hostname) || trustedDomains.has(hostname) : true : true : true : true : true;
|
|
}
|
|
isTrustedProtocol(a0) {
|
|
return trustedProtocols.has(getProtocol(a0));
|
|
}
|
|
}
|
|
const maskedLinkStore = new MaskedLinkStore(Dispatcher, {
|
|
MASKED_LINK_ADD_TRUSTED_DOMAIN: function handleAddTrustedDomain({ url }) {
|
|
const hostname = getHostname(url);
|
|
if (window.GLOBAL_ENV.INVITE_HOST !== hostname ? window.GLOBAL_ENV.GIFT_CODE_HOST !== hostname ? window.GLOBAL_ENV.GUILD_TEMPLATE_HOST !== hostname ? c5211_7 !== hostname ? location.hostname !== hostname ? SPOTIFY_HOSTNAMES.includes(hostname) || URLUtils.isDiscordHostname(hostname) || trustedDomains.has(hostname) : true : true : true : true : true) {
|
|
return false;
|
|
}
|
|
trustedDomains.add(getHostname(url));
|
|
Storage.set(c5211_4, {
|
|
trustedDomains,
|
|
trustedProtocols
|
|
});
|
|
},
|
|
MASKED_LINK_ADD_TRUSTED_PROTOCOL: function handleAddTrustedProtocol({ url }) {
|
|
if (trustedProtocols.has(getProtocol(url))) {
|
|
return false;
|
|
}
|
|
trustedProtocols.add(getProtocol(url));
|
|
Storage.set(c5211_4, {
|
|
trustedDomains,
|
|
trustedProtocols
|
|
});
|
|
}
|
|
});
|
|
export default maskedLinkStore;
|