80 lines
2.5 KiB
TypeScript
80 lines
2.5 KiB
TypeScript
// 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)
|
|
};
|
|
};
|