AnonSec Shell
Server IP : 209.38.156.173  /  Your IP : 216.73.216.122   [ Reverse IP ]
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux lakekumayuhotel 5.15.0-136-generic #147-Ubuntu SMP Sat Mar 15 15:53:30 UTC 2025 x86_64
User : root ( 0)
PHP Version : 8.1.2-1ubuntu2.22
Disable Function : NONE
Domains : 2 Domains
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/www/html/wp-content/plugins/jetpack/extensions/blocks/ai-assistant/lib/connection/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     [ BACKUP SHELL ]     [ JUMPING ]     [ MASS DEFACE ]     [ SCAN ROOT ]     [ SYMLINK ]     

Current File : /var/www/html/wp-content/plugins/jetpack/extensions/blocks/ai-assistant/lib/connection/index.ts
/**
 * External dependencies
 */
import { isAtomicSite, isSimpleSite } from '@automattic/jetpack-shared-extension-utils';
import debugFactory from 'debug';

const initialState = window?.JP_CONNECTION_INITIAL_STATE;
const debug = debugFactory( 'jetpack-ai-assistant:connection' );
let hasCheckedConnection = false;

const debugOnce = content => {
	if ( ! hasCheckedConnection ) {
		debug( content );
		hasCheckedConnection = true;
	}
};

/**
 * Return the initial connection status.
 *
 * @returns {boolean} true if the user is connected, false otherwise.
 */
export function isUserConnected(): boolean {
	if ( isSimpleSite() ) {
		debugOnce( 'Simple site connected ✅' );
		return true;
	}

	if ( isAtomicSite() ) {
		debugOnce( 'Atomic site connected ✅' );
		return true;
	}

	if ( initialState?.connectionStatus?.isUserConnected ) {
		debugOnce( 'Jetpack user is connected ✅' );
		return true;
	}

	debugOnce( 'User is not connected ❌' );
	return false;
}

export function canUserPurchasePlan(): boolean {
	if ( isSimpleSite() ) {
		// Roles on simple sites can't be inferred from the connection status.
		return true;
	}

	const permissions =
		initialState?.userConnectionData?.currentUser?.permissions ??
		( {} as { manage_options?: boolean } );

	return ! permissions.manage_options === false;
}

Anon7 - 2022
AnonSec Team