decord/source/modules/rpc/server/commands/subscriptions.tsx

151 lines
5.6 KiB
TypeScript
Raw Normal View History

2026-08-24 06:08:38 +00:00
// Module ID: 13934
// Function ID: 13935
// Dependencies: [5, 676, 8789, 13935, 698, 13936, 2]
2026-07-20 16:05:17 +00:00
2026-08-24 06:08:38 +00:00
// Module 13934
import prototypeDefault from "prototype" /* 8789 */;
import closure_3 from "asyncGeneratorStep" /* 5 */;
import ME from "ME" /* 676 */;
2026-07-20 16:05:17 +00:00
2026-07-23 10:11:24 +00:00
const require = arg1;
2026-07-29 08:29:29 +00:00
({ AnalyticEvents: c4, RPCCommands, RPCErrors: c5 } = ME);
2026-07-20 16:05:17 +00:00
let obj = {
handler(arg0) {
2026-08-24 06:08:38 +00:00
({ server: require, socket: importDefault, evt: dependencyMap, args: closure_3 } = arg0);
2026-07-29 08:29:29 +00:00
return callback(function*() {
if (initialSubscriptionPayload === 2) {
initialSubscriptionPayload = 3;
HermesBuiltin.throwTypeError();
} else if (tmp4 === 3) {
if (arg0 === 1) {
throw arg1;
} else if (arg0 === 2) {
let obj = { value: null, done: true };
obj[0] = arg1;
return obj;
} else {
2026-08-24 06:08:38 +00:00
return { value: "HermesInternal", done: null };
2026-07-29 08:29:29 +00:00
}
} else {
try {
initialSubscriptionPayload = 2;
if (0 === closure_2) {
if (arg0 === 1) {
initialSubscriptionPayload = 3;
throw arg1;
} else if (arg0 === 2) {
initialSubscriptionPayload = 3;
obj = { value: null, done: true };
obj[0] = arg1;
return obj;
} else {
2026-08-24 06:08:38 +00:00
closure_1 = 0;
closure_0 = tmp2;
closure_0 = undefined;
2026-07-29 08:29:29 +00:00
closure_1 = undefined;
closure_2 = undefined;
initialSubscriptionPayload = undefined;
2026-08-24 06:08:38 +00:00
closure_0 = tmp67;
if (null == closure_1_0.events[dependencyMap]) {
obj1 = { errorCode: null };
obj1[0] = closure_1_5.INVALID_EVENT;
2026-07-29 08:29:29 +00:00
const _HermesInternal = HermesInternal;
2026-08-24 06:08:38 +00:00
let tmp35 = closure_1_1(8789);
2026-07-29 08:29:29 +00:00
tmp35 = new tmp35(obj1, "Invalid event: " + dependencyMap);
throw tmp35;
2026-08-24 06:08:38 +00:00
} else if (closure_1_1(13935)(closure_1_1.authorization.scopes, tmp67.scope)) {
2026-07-29 08:29:29 +00:00
const obj2 = { event: null, scope: null, application_id: null, socket_scope: null };
obj2[0] = dependencyMap;
2026-08-04 21:03:28 +00:00
if (typeof tmp67.scope === "object") {
2026-07-29 08:29:29 +00:00
const _JSON = JSON;
let scope = JSON.stringify(tmp67.scope);
} else {
scope = tmp67.scope;
}
obj2[1] = scope;
2026-08-24 06:08:38 +00:00
obj2[2] = closure_1_1.application.id;
obj2[3] = closure_1_1.authorization.scopes.toString();
tmp72(698).track(closure_1_4.RPC_SUBSCRIPTION_REQUESTED, obj2);
2026-07-29 08:29:29 +00:00
if (null != tmp67.validation) {
closure_2 = 1;
initialSubscriptionPayload = 1;
const obj3 = { value: null, done: false };
obj3[0] = obj13.getJoi();
return obj3;
}
2026-08-24 06:08:38 +00:00
const str2 = closure_1_1.authorization.scopes;
2026-07-29 08:29:29 +00:00
const tmp72Result = tmp72(698);
} else {
const obj4 = { errorCode: null };
2026-08-24 06:08:38 +00:00
obj4[0] = closure_1_5.INVALID_PERMISSIONS;
const tmp10 = new tmp72(8789)(obj4, "Not authenticated or invalid scope");
2026-07-29 08:29:29 +00:00
throw tmp10;
}
2026-08-24 06:08:38 +00:00
obj13 = closure_1_0;
2026-07-29 08:29:29 +00:00
}
} else if (arg0 === 1) {
initialSubscriptionPayload = 3;
throw arg1;
} else if (arg0 === 2) {
initialSubscriptionPayload = 3;
obj = { value: null, done: true };
obj[0] = arg1;
return obj;
} else {
closure_1 = arg1;
2026-08-24 06:08:38 +00:00
if (null != closure_1.validate(initialSubscriptionPayload, closure_0.validation(closure_1), { convert: false }).error) {
2026-07-29 08:29:29 +00:00
let obj5 = { errorCode: null };
2026-08-24 06:08:38 +00:00
obj5[0] = closure_1_5.INVALID_PAYLOAD;
const tmp64 = new closure_1_1(8789)(obj5, "Invalid subscription parameters provided");
2026-07-29 08:29:29 +00:00
throw tmp64;
}
}
const obj6 = { args: null, socket: null };
obj6[0] = initialSubscriptionPayload;
obj6[1] = closure_1;
2026-08-24 06:08:38 +00:00
closure_2 = closure_0.handler(obj6);
obj5 = closure_1_0(13936);
2026-07-29 08:29:29 +00:00
initialSubscriptionPayload = obj5.getInitialSubscriptionPayload(closure_1, closure_2, initialSubscriptionPayload);
const promise = new Promise((arg0) => {
setImmediate(() => {
2026-08-24 06:08:38 +00:00
closure_1_0.addSubscription(closure_1_1, closure_1_2, closure_1_3, closure_2);
if (null != closure_3) {
const result = closure_1_0.dispatchToSubscriptions(closure_1_2, (socket) => socket.socket.id === id.id, closure_3);
2026-07-29 08:29:29 +00:00
}
});
arg0({ evt: closure_2 });
});
initialSubscriptionPayload = 3;
const obj7 = { value: null, done: true };
obj7[0] = promise;
return obj7;
} catch (tmp44) {
initialSubscriptionPayload = tmp;
throw tmp44;
}
}
})();
2026-07-20 16:05:17 +00:00
}
};
obj = {
handler(arg0) {
({ server, evt } = arg0);
if (null == server.events[evt]) {
2026-07-29 08:29:29 +00:00
let obj = { errorCode: null };
obj[0] = constants.INVALID_EVENT;
2026-07-20 16:05:17 +00:00
const _HermesInternal = HermesInternal;
2026-08-24 06:08:38 +00:00
let tmp6 = prototypeDefault;
2026-07-20 16:05:17 +00:00
tmp6 = new tmp6(obj, "Invalid event: " + evt);
throw tmp6;
} else {
server.removeSubscription(tmp, evt, tmp2);
2026-07-29 08:29:29 +00:00
obj = { evt: null };
obj[0] = evt;
2026-07-20 16:05:17 +00:00
return obj;
}
}
};
2026-08-24 06:08:38 +00:00
let result = require("set").fileFinishedImporting("modules/rpc/server/commands/subscriptions.tsx");
2026-07-20 16:05:17 +00:00
export default { [RPCCommands.SUBSCRIBE]: obj, [RPCCommands.UNSUBSCRIBE]: obj };