openblox
Version:
Roblox API Wrapper For Both Classic And OpenCloud APIs.
71 lines (70 loc) • 2.91 kB
JavaScript
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var config_exports = {};
__export(config_exports, {
config: () => config,
setConfig: () => setConfig,
updateConfig: () => updateConfig
});
module.exports = __toCommonJS(config_exports);
var import_lodash = require("lodash");
var import_utils = require("../utils/utils");
var import_cacheAdapters = require("../cache/cacheAdapters");
const initialCookie = process.env.ROBLOX_COOKIE;
const config = {
cookie: initialCookie && `.ROBLOSECURITY=${initialCookie}; RBXEventTrackerV2=CreateDate=1/1/1 1:1:1 PM&rbxid=1&browserid=1;`,
cloudKey: process.env.ROBLOX_CLOUD_KEY,
cache: [(0, import_cacheAdapters.TtlCacheAdapter)({ included: { lifetime: 300 } })]
};
function mergeDeepConfigs(target, ...sources) {
if (!sources.length) return target;
const source = sources.shift();
if ((0, import_lodash.isObject)(target) && (0, import_lodash.isObject)(source)) {
for (const key in source) {
if ((0, import_lodash.isObject)(source[key])) {
if (!target[key]) Object.assign(target, { [key]: {} });
if (key == "cache") {
Object.assign(target[key], source[key]);
} else {
(0, import_utils.mergeDeep)(target[key], source[key]);
}
} else {
Object.assign(target, { [key]: source[key] });
}
}
}
return (0, import_utils.mergeDeep)(target, ...sources);
}
const setConfig = (newConfig) => {
const newConfigCookie = newConfig?.cookie;
if (newConfigCookie) newConfig.cookie = `.ROBLOSECURITY=${newConfigCookie}; RBXEventTrackerV2=CreateDate=1/1/1 1:1:1 PM&rbxid=1&browserid=1;`;
Object.keys(config).forEach((key) => delete config[key]);
Object.assign(config, newConfig);
};
const updateConfig = (updateConfigWith) => {
const updateConfigWithCookie = updateConfigWith?.cookie;
if (updateConfigWithCookie) updateConfigWith.cookie = `.ROBLOSECURITY=${updateConfigWithCookie}; RBXEventTrackerV2=CreateDate=1/1/1 1:1:1 PM&rbxid=1&browserid=1;`;
mergeDeepConfigs(config, updateConfigWith);
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
config,
setConfig,
updateConfig
});
;