decord/alpha/source/modules/rpc/helpers/validateEmbeddedAppFrame.tsx

82 lines
3.2 KiB
TypeScript
Raw Normal View History

// Module ID: 14837
// Function ID: 14838
2026-08-24 06:08:38 +00:00
// Name: validateEmbeddedAppFrame
// Dependencies: [9393, 14838, 4733, 1074, 9394, 9395, 9669, 9215, 9664, 2]
2026-08-24 06:08:38 +00:00
// Exports: tryValidateEmbeddedAppFrame
// Module 14837 (validateEmbeddedAppFrame)
import ApplicationFlagUtils from "ApplicationFlagUtils" /* 9215 */;
import RPCErrorDefault from "RPCError" /* 9664 */;
import RPCHelpers from "RPCHelpers" /* 9669 */;
import FramesStore from "FramesStore" /* 9393 */;
import VibegrationsBuilderPreviewStore from "VibegrationsBuilderPreviewStore" /* 14838 */;
2026-08-24 06:08:38 +00:00
require = fn;
2026-08-24 06:08:38 +00:00
function validateEmbeddedAppFrame(transport) {
const result = RPCHelpers.validatePostMessageTransport(transport.transport);
const validateApplicationResult = RPCHelpers.validateApplication(transport.application);
if (obj3.hasApplicationFlag(transport.application, constants.EMBEDDED)) {
2026-08-24 06:08:38 +00:00
if (transport.source.type !== TransportTypes.POST_MESSAGE) {
const obj4 = { errorCode: constants2.INVALID_COMMAND };
const tmp31 = new RPCErrorDefault(obj4, "command requires an embedded app frame");
2026-08-24 06:08:38 +00:00
throw tmp31;
} else {
const tmp35 = asLaunched(FramesStore.getFrameByIframeId(transport.source.iframeId));
2026-08-24 06:08:38 +00:00
let tmp13 = null;
if (null != tmp35) {
const type = tmp35.surface.type;
if (tmp(9395).EmbeddedSurfaceType.APP_CHANNEL !== type) {
if (tmp(9395).EmbeddedSurfaceType.VOICE_CHANNEL !== type) {
if (tmp(9395).EmbeddedSurfaceType.MAIN === type) {
if (tmp35.applicationId === VibegrationsBuilderPreviewStore.getBuilderPreviewApplicationId()) {
let obj5 = { channelId: "channel", guildId: "channelId" };
} else {
obj5 = null;
}
tmp13 = obj5;
2026-08-24 06:08:38 +00:00
} else {
const surface = tmp35.surface;
tmp13 = null;
2026-08-24 06:08:38 +00:00
}
}
}
const obj6 = { channelId: tmp35.surface.channelId, guildId: tmp35.surface.guildId };
tmp13 = obj6;
2026-08-24 06:08:38 +00:00
}
if (null == tmp13) {
const obj7 = { errorCode: constants2.UNAUTHORIZED_FOR_APPLICATION };
const tmp24 = new RPCErrorDefault(obj7, "Command not available for this application");
2026-08-24 06:08:38 +00:00
throw tmp24;
} else {
const obj8 = { applicationId: validateApplicationResult, iframeId: transport.source.iframeId };
2026-08-24 06:08:38 +00:00
const merged = Object.assign(tmp13);
return obj8;
2026-08-24 06:08:38 +00:00
}
}
} else {
const obj14 = { errorCode: constants2.UNAUTHORIZED_FOR_APPLICATION };
const tmp10 = new RPCErrorDefault(obj14, "This application cannot access this API");
throw tmp10;
2026-08-24 06:08:38 +00:00
}
obj3 = ApplicationFlagUtils;
2026-08-24 06:08:38 +00:00
}
const TransportTypes = fn(4733).TransportTypes;
const Constants = fn(1074);
({ ApplicationFlags: metroRequire, RPCErrors: closure_7 } = Constants);
const asLaunched = fn(9394).asLaunched;
const size = fn(2);
let result = size.fileFinishedImporting("modules/rpc/helpers/validateEmbeddedAppFrame.tsx");
2026-08-24 06:08:38 +00:00
export default validateEmbeddedAppFrame;
export const tryValidateEmbeddedAppFrame = function tryValidateEmbeddedAppFrame(transport) {
2026-08-24 06:08:38 +00:00
try {
return validateEmbeddedAppFrame(transport);
2026-08-24 06:08:38 +00:00
} catch (tmp3) {
if (tmp3 instanceof RPCErrorDefault) {
2026-08-24 06:08:38 +00:00
return null;
} else {
throw tmp3;
}
}
};