Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function setInLexicalEnvironment ({env, path, value, reporting, node, newBinding = false}: ISetInLexicalEnvironmentOptions): void {
const [firstBinding] = path.split(".");
if (has(env.env, firstBinding) || newBinding || env.parentEnv == null) {
// If the value didn't change, do no more
if (has(env.env, path) && get(env.env, path) === value) return;
// Otherwise, mutate it
set(env.env, path, value);
// Inform reporting hooks if any is given
if (reporting.reportBindings != null && !isInternalSymbol(path)) {
reporting.reportBindings({path, value, node});
}
}
else {
let currentParentEnv: LexicalEnvironment|undefined = env.parentEnv;
while (currentParentEnv != null) {
if (has(currentParentEnv.env, firstBinding)) {
Object.keys(state.fieldsStatus).forEach((key) => {
if (key === fieldName || (includeChildren && key.indexOf(`${fieldName}.`) > -1))
delete state.fieldsStatus[key]
})
const indexRegexp = /\.(\d{1,})$/
// Verify if its a array prop
if (indexRegexp.test(fieldName)) {
let initialIndex = parseInt(fieldName.match(indexRegexp)![1])
while(true) {
const presProp = fieldName.replace(indexRegexp, `.${initialIndex}`);
const nextProp = fieldName.replace(indexRegexp, `.${initialIndex + 1}`);
if (!OPath.has(state, nextProp))
break
OPath.set(state, presProp, OPath.get(state, nextProp))
initialIndex++
}
}
return state
}
async function getItems(base64){
// API stores data as base64 encoded gzipped Minecraft NBT data
let buf = Buffer.from(base64, 'base64');
let data = await parseNbt(buf);
data = nbt.simplify(data);
let items = data.i;
// Check backpack contents and add them to the list of items
for(let [index, item] of items.entries()){
if(objectPath.has(item, 'tag.display.Name') && (item.tag.display.Name.endsWith('Backpack') || item.tag.display.Name.endsWith('Itchy New Year Cake Bag'))){
let keys = Object.keys(item.tag.ExtraAttributes);
let backpackData;
keys.forEach(key => {
if(key.endsWith('backpack_data') || key == 'new_year_cake_bag_data')
backpackData = item.tag.ExtraAttributes[key];
});
if(!Array.isArray(backpackData))
continue;
let backpackContents = await getBackpackContents(backpackData);
backpackContents.forEach(backpackItem => {
// If the value didn't change, do no more
if (has(env.env, path) && get(env.env, path) === value) return;
// Otherwise, mutate it
set(env.env, path, value);
// Inform reporting hooks if any is given
if (reporting.reportBindings != null && !isInternalSymbol(path)) {
reporting.reportBindings({path, value, node});
}
}
else {
let currentParentEnv: LexicalEnvironment|undefined = env.parentEnv;
while (currentParentEnv != null) {
if (has(currentParentEnv.env, firstBinding)) {
// If the value didn't change, do no more
if (has(currentParentEnv.env, path) && get(currentParentEnv.env, path) === value) return;
// Otherwise, mutate it
set(currentParentEnv.env, path, value);
// Inform reporting hooks if any is given
if (reporting.reportBindings != null && !isInternalSymbol(path)) {
reporting.reportBindings({path, value, node});
}
return;
}
else {
currentParentEnv = currentParentEnv.parentEnv;
}
}
let speed = parseInt(split[1]);
if(!isNaN(speed))
item.stats.speed = speed;
}
})
}
}
// Add snow canon and blaster to weapons
if(objectPath.has(item, 'tag.ExtraAttributes.id') && ['SNOW_CANNON', 'SNOW_BLASTER'].includes(item.tag.ExtraAttributes.id))
item.type = 'bow';
// Workaround for detecting item types if another language is set by the player on Hypixel
if(objectPath.has(item, 'tag.ExtraAttributes.id') && item.tag.ExtraAttributes.id != 'ENCHANTED_BOOK'){
if(objectPath.has(item, 'tag.ExtraAttributes.enchantments')){
if('sharpness' in item.tag.ExtraAttributes.enchantments
|| 'crticial' in item.tag.ExtraAttributes.enchantments
|| 'ender_slayer' in item.tag.ExtraAttributes.enchantments
|| 'execute' in item.tag.ExtraAttributes.enchantments
|| 'first_strike' in item.tag.ExtraAttributes.enchantments
|| 'giant_killer' in item.tag.ExtraAttributes.enchantments
|| 'lethality' in item.tag.ExtraAttributes.enchantments
|| 'life_steal' in item.tag.ExtraAttributes.enchantments
|| 'looting' in item.tag.ExtraAttributes.enchantments
|| 'luck' in item.tag.ExtraAttributes.enchantments
|| 'scavenger' in item.tag.ExtraAttributes.enchantments
|| 'vampirism' in item.tag.ExtraAttributes.enchantments
|| 'bane_of_arthropods' in item.tag.ExtraAttributes.enchantments
|| 'smite' in item.tag.ExtraAttributes.enchantments)
item.type = 'sword';
let speed = parseInt(split[1]);
if(!isNaN(speed))
item.stats.speed = speed;
}
})
}
}
// Add snow canon and blaster to weapons
if(objectPath.has(item, 'tag.ExtraAttributes.id') && ['SNOW_CANNON', 'SNOW_BLASTER'].includes(item.tag.ExtraAttributes.id))
item.type = 'bow';
// Workaround for detecting item types if another language is set by the player on Hypixel
if(objectPath.has(item, 'tag.ExtraAttributes.id') && item.tag.ExtraAttributes.id != 'ENCHANTED_BOOK'){
if(objectPath.has(item, 'tag.ExtraAttributes.enchantments')){
if('sharpness' in item.tag.ExtraAttributes.enchantments
|| 'crticial' in item.tag.ExtraAttributes.enchantments
|| 'ender_slayer' in item.tag.ExtraAttributes.enchantments
|| 'execute' in item.tag.ExtraAttributes.enchantments
|| 'first_strike' in item.tag.ExtraAttributes.enchantments
|| 'giant_killer' in item.tag.ExtraAttributes.enchantments
|| 'lethality' in item.tag.ExtraAttributes.enchantments
|| 'life_steal' in item.tag.ExtraAttributes.enchantments
|| 'looting' in item.tag.ExtraAttributes.enchantments
|| 'luck' in item.tag.ExtraAttributes.enchantments
|| 'scavenger' in item.tag.ExtraAttributes.enchantments
|| 'vampirism' in item.tag.ExtraAttributes.enchantments
|| 'bane_of_arthropods' in item.tag.ExtraAttributes.enchantments
|| 'smite' in item.tag.ExtraAttributes.enchantments)
item.type = 'sword';
function verify_filter(req, res) {
var logger = req.app.get('logger');
if(!objectPath.has(req, 'session.auth_session'))
return Promise.reject('No auth_session variable');
if(!objectPath.has(req, 'session.auth_session.first_factor'))
return Promise.reject('No first factor variable');
if(!objectPath.has(req, 'session.auth_session.second_factor'))
return Promise.reject('No second factor variable');
if(!objectPath.has(req, 'session.auth_session.userid'))
return Promise.reject('No userid variable');
var host = objectPath.get(req, 'headers.host');
var domain = host.split(':')[0];
if(!req.session.auth_session.first_factor ||
!req.session.auth_session.second_factor)
export function getRelevantDictFromLexicalEnvironment (env: LexicalEnvironment, path: string): LexicalEnvironment["env"]|undefined {
const [firstBinding] = path.split(".");
if (has(env.env, firstBinding)) return env.env;
if (env.parentEnv != null) return getRelevantDictFromLexicalEnvironment(env.parentEnv, path);
return undefined;
}
function getId(item){
if(objectPath.has(item, 'tag.ExtraAttributes.id'))
return item.tag.ExtraAttributes.id;
return null;
}