| Server IP : 66.29.153.156 / Your IP : 216.73.217.22 Web Server : LiteSpeed System : Linux premium322.web-hosting.com 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64 User : lastyfjz ( 1521) PHP Version : 8.1.34 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/lastyfjz/././unicitys.com/wp-content/plugins/extendify/src/Shared/api/ |
Upload File : |
import apiFetch from '@wordpress/api-fetch';
const getRecaptchaToken = (action, siteKey) =>
new Promise((resolve, reject) => {
const existing = document.querySelector(
`script[src*="recaptcha/enterprise"]`,
);
const load = () =>
window.grecaptcha.enterprise.ready(async () => {
try {
resolve(
await window.grecaptcha.enterprise.execute(siteKey, { action }),
);
} catch (error) {
reject(error);
}
});
if (existing) {
load();
return;
}
const script = document.createElement('script');
script.src = `https://www.google.com/recaptcha/enterprise.js?render=${siteKey}`;
script.async = true;
script.onload = load;
document.head.appendChild(script);
});
const createAccount = async ({
slug,
email,
marketingConsent,
termsAgreed,
signal,
scriptData,
}) => {
await apiFetch({
path: `extendify/v1/${slug}/create-account`,
method: 'POST',
data: {
email,
marketingConsent,
termsAgreed,
...scriptData,
},
signal,
});
};
/*
* Plugin entries shape:
* createAccountCallback: (data) => Promise<void> — performs the account creation request
* idempotent: boolean (default true) — false skips retries; use when re-sending the same request could cause errors
*/
export const pluginsActivation = {
simplybook: {
idempotent: false,
createAccountCallback: async ({ scriptData, ...data }) => {
const captchaToken = await getRecaptchaToken(
scriptData?.recaptchaAction,
scriptData?.recaptchaSiteKey,
);
await createAccount({
slug: 'simplybook',
...data,
scriptData: { captcha_token: captchaToken },
});
},
},
'translatepress-multilingual': {
createAccountCallback: (data) =>
createAccount({ slug: 'translatepress-multilingual', ...data }),
},
imagify: {
createAccountCallback: (data) =>
createAccount({ slug: 'imagify', ...data }),
},
};