<commit_before>const commands = {
	go(data) {
		if (typeof data.path !== 'string' || data.path.trim().length === 0) {
			return console.error('`path` not defined');
		}
		FlowRouter.go(data.path);
	},


	'set-user-status'(data) {
		AccountBox.setStatus(data.status);
	},

	'call-custom-oauth-login'(data, event) {
		const customOAuthCallback = (response) => {
			event.source.postMessage({
				event: 'custom-oauth-callback',
				response: response
			}, event.origin);
		};

		if (typeof data.service === 'string') {
			const customOauth = ServiceConfiguration.configurations.findOne({service: data.service});

			if (customOauth) {
				const customLoginWith = Meteor['loginWith' + _.capitalize(customOauth.service, true)];
				const customRedirectUri = window.OAuth._redirectUri(customOauth.service, customOauth);
				customLoginWith.call(Meteor, {'redirectUrl': customRedirectUri}, customOAuthCallback);
			}
		}
	},

	'login-with-token'(data) {
		if (typeof data.token === 'string') {
			Meteor.loginWithToken(data.token, function() {
				console.log('Iframe command [login-with-token]: result', arguments);
			});
		}
	}
};

window.addEventListener('message', (e) => {
	if (RocketChat.settings.get('Iframe_Integration_receive_enable') !== true) {
		return;
	}

	if (typeof e.data !== 'object' || typeof e.data.externalCommand !== 'string') {
		return;
	}

	let origins = RocketChat.settings.get('Iframe_Integration_receive_origin');

	if (origins !== '*' && origins.split(',').indexOf(e.origin) === -1) {
		return console.error('Origin not allowed', e.origin);
	}

	const command = commands[e.data.externalCommand];
	if (command) {
		command(e.data, e);
	}
});<commit_msg>Add iframe command 'logout'<commit_after>const commands = {
	go(data) {
		if (typeof data.path !== 'string' || data.path.trim().length === 0) {
			return console.error('`path` not defined');
		}
		FlowRouter.go(data.path);
	},


	'set-user-status'(data) {
		AccountBox.setStatus(data.status);
	},

	'call-custom-oauth-login'(data, event) {
		const customOAuthCallback = (response) => {
			event.source.postMessage({
				event: 'custom-oauth-callback',
				response: response
			}, event.origin);
		};

		if (typeof data.service === 'string') {
			const customOauth = ServiceConfiguration.configurations.findOne({service: data.service});

			if (customOauth) {
				const customLoginWith = Meteor['loginWith' + _.capitalize(customOauth.service, true)];
				const customRedirectUri = window.OAuth._redirectUri(customOauth.service, customOauth);
				customLoginWith.call(Meteor, {'redirectUrl': customRedirectUri}, customOAuthCallback);
			}
		}
	},

	'login-with-token'(data) {
		if (typeof data.token === 'string') {
			Meteor.loginWithToken(data.token, function() {
				console.log('Iframe command [login-with-token]: result', arguments);
			});
		}
	},

	'logout'() {
		const user = Meteor.user();
		Meteor.logout(() => {
			RocketChat.callbacks.run('afterLogoutCleanUp', user);
			Meteor.call('logoutCleanUp', user);
			return FlowRouter.go('home');
		});
	}
};

window.addEventListener('message', (e) => {
	if (RocketChat.settings.get('Iframe_Integration_receive_enable') !== true) {
		return;
	}

	if (typeof e.data !== 'object' || typeof e.data.externalCommand !== 'string') {
		return;
	}

	let origins = RocketChat.settings.get('Iframe_Integration_receive_origin');

	if (origins !== '*' && origins.split(',').indexOf(e.origin) === -1) {
		return console.error('Origin not allowed', e.origin);
	}

	const command = commands[e.data.externalCommand];
	if (command) {
		command(e.data, e);
	}
});
{'fraction_non_alphanumeric': 0.17645413870246085, 'fraction_numerical': 0.0011185682326621924, 'mean_word_length': 4.395173453996984, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4254188', 'n_tokens_mistral': 1329, 'n_tokens_neox': 1180, 'n_words': 204}