@pelcro/react-pelcro-js 2.6.0-beta.5 → 2.6.0-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +75 -28
- package/dist/index.esm.js +75 -28
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -8476,6 +8476,7 @@ const optionsController = options => {
|
|
|
8476
8476
|
enableURLTriggers: initViewFromURL,
|
|
8477
8477
|
enableTheme: applyPelcroTheme,
|
|
8478
8478
|
enablePaywalls: initPaywalls,
|
|
8479
|
+
loadSecuritySDK: initSecuritySdk,
|
|
8479
8480
|
enableGoogleAnalytics: initGATracking
|
|
8480
8481
|
}; // Only execute enabled options
|
|
8481
8482
|
|
|
@@ -8537,6 +8538,18 @@ const loadPaymentSDKs = () => {
|
|
|
8537
8538
|
window.Pelcro.helpers.loadSDK("https://js.braintreegateway.com/web/3.69.0/js/paypal-checkout.min.js", "braintree-paypal-sdk");
|
|
8538
8539
|
}
|
|
8539
8540
|
};
|
|
8541
|
+
const initSecuritySdk = () => {
|
|
8542
|
+
const {
|
|
8543
|
+
whenSiteReady
|
|
8544
|
+
} = usePelcro.getStore();
|
|
8545
|
+
whenSiteReady(() => {
|
|
8546
|
+
var _window$Pelcro$site$r2;
|
|
8547
|
+
|
|
8548
|
+
const securityKey = (_window$Pelcro$site$r2 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r2 === void 0 ? void 0 : _window$Pelcro$site$r2.security_key;
|
|
8549
|
+
if (!securityKey) return;
|
|
8550
|
+
window.Pelcro.helpers.loadSDK(`https://www.google.com/recaptcha/enterprise.js?render=${securityKey}`, "pelcro-security-enteprise");
|
|
8551
|
+
});
|
|
8552
|
+
};
|
|
8540
8553
|
const initGATracking = () => {
|
|
8541
8554
|
var _ReactGA$initialize, _ReactGA$plugin, _ReactGA$plugin$requi;
|
|
8542
8555
|
|
|
@@ -8623,9 +8636,9 @@ const applyPelcroTheme = () => {
|
|
|
8623
8636
|
};
|
|
8624
8637
|
|
|
8625
8638
|
whenSiteReady(() => {
|
|
8626
|
-
var _window$Pelcro$site$
|
|
8639
|
+
var _window$Pelcro$site$r3, _window$Pelcro$site$r4;
|
|
8627
8640
|
|
|
8628
|
-
const primaryColorHex = (_window$Pelcro$site$
|
|
8641
|
+
const primaryColorHex = (_window$Pelcro$site$r3 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r3 === void 0 ? void 0 : (_window$Pelcro$site$r4 = _window$Pelcro$site$r3.design_settings) === null || _window$Pelcro$site$r4 === void 0 ? void 0 : _window$Pelcro$site$r4.primary_color;
|
|
8629
8642
|
|
|
8630
8643
|
if (!primaryColorHex) {
|
|
8631
8644
|
return;
|
|
@@ -8824,6 +8837,7 @@ const defaultOptions = {
|
|
|
8824
8837
|
enableURLTriggers: true,
|
|
8825
8838
|
enableTheme: true,
|
|
8826
8839
|
enablePaywalls: true,
|
|
8840
|
+
loadSecuritySDK: true,
|
|
8827
8841
|
enableGoogleAnalytics: false
|
|
8828
8842
|
};
|
|
8829
8843
|
const PelcroModalController = ({
|
|
@@ -9764,35 +9778,53 @@ const RegisterContainer = ({
|
|
|
9764
9778
|
jobTitle,
|
|
9765
9779
|
selectFields
|
|
9766
9780
|
} = filteredData;
|
|
9767
|
-
|
|
9768
|
-
|
|
9769
|
-
|
|
9770
|
-
|
|
9771
|
-
|
|
9772
|
-
|
|
9773
|
-
|
|
9774
|
-
|
|
9775
|
-
|
|
9776
|
-
|
|
9777
|
-
|
|
9778
|
-
dispatch({
|
|
9779
|
-
type: DISABLE_REGISTRATION_BUTTON,
|
|
9780
|
-
payload: false
|
|
9781
|
+
|
|
9782
|
+
if (!hasSecurityTokenEnabled()) {
|
|
9783
|
+
sendRegisterRequest();
|
|
9784
|
+
return;
|
|
9785
|
+
}
|
|
9786
|
+
|
|
9787
|
+
window.grecaptcha.enterprise.ready(async () => {
|
|
9788
|
+
var _window$Pelcro$site$r;
|
|
9789
|
+
|
|
9790
|
+
const token = await window.grecaptcha.enterprise.execute((_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.security_key, {
|
|
9791
|
+
action: "register"
|
|
9781
9792
|
});
|
|
9793
|
+
sendRegisterRequest(token);
|
|
9794
|
+
});
|
|
9782
9795
|
|
|
9783
|
-
|
|
9796
|
+
function sendRegisterRequest(securityToken) {
|
|
9797
|
+
window.Pelcro.user.register({
|
|
9798
|
+
email,
|
|
9799
|
+
password,
|
|
9800
|
+
first_name: firstName,
|
|
9801
|
+
last_name: lastName,
|
|
9802
|
+
security_token: securityToken,
|
|
9803
|
+
metadata: {
|
|
9804
|
+
organization,
|
|
9805
|
+
jobTitle,
|
|
9806
|
+
...selectFields
|
|
9807
|
+
}
|
|
9808
|
+
}, (err, res) => {
|
|
9784
9809
|
dispatch({
|
|
9785
|
-
type:
|
|
9786
|
-
payload:
|
|
9787
|
-
type: "error",
|
|
9788
|
-
content: getErrorMessages(err)
|
|
9789
|
-
}
|
|
9810
|
+
type: DISABLE_REGISTRATION_BUTTON,
|
|
9811
|
+
payload: false
|
|
9790
9812
|
});
|
|
9791
|
-
|
|
9792
|
-
|
|
9793
|
-
|
|
9794
|
-
|
|
9795
|
-
|
|
9813
|
+
|
|
9814
|
+
if (err) {
|
|
9815
|
+
dispatch({
|
|
9816
|
+
type: SHOW_ALERT,
|
|
9817
|
+
payload: {
|
|
9818
|
+
type: "error",
|
|
9819
|
+
content: getErrorMessages(err)
|
|
9820
|
+
}
|
|
9821
|
+
});
|
|
9822
|
+
onFailure(err);
|
|
9823
|
+
} else {
|
|
9824
|
+
onSuccess(res);
|
|
9825
|
+
}
|
|
9826
|
+
});
|
|
9827
|
+
}
|
|
9796
9828
|
};
|
|
9797
9829
|
|
|
9798
9830
|
const handleSocialLogin = ({
|
|
@@ -9943,6 +9975,15 @@ const RegisterContainer = ({
|
|
|
9943
9975
|
store: store$e
|
|
9944
9976
|
})));
|
|
9945
9977
|
};
|
|
9978
|
+
/**
|
|
9979
|
+
* Checks if the current site has security token enabled
|
|
9980
|
+
* @return {boolean}
|
|
9981
|
+
*/
|
|
9982
|
+
|
|
9983
|
+
function hasSecurityTokenEnabled() {
|
|
9984
|
+
const hasSecuritySdkLoaded = Boolean(window.grecaptcha);
|
|
9985
|
+
return hasSecuritySdkLoaded;
|
|
9986
|
+
}
|
|
9946
9987
|
|
|
9947
9988
|
var _path$l;
|
|
9948
9989
|
|
|
@@ -10332,8 +10373,11 @@ const RegisterPassword = props => /*#__PURE__*/React__default['default'].createE
|
|
|
10332
10373
|
const RegisterButton = ({
|
|
10333
10374
|
name,
|
|
10334
10375
|
onClick,
|
|
10376
|
+
className,
|
|
10335
10377
|
...otherProps
|
|
10336
10378
|
}) => {
|
|
10379
|
+
var _window$Pelcro$site$r;
|
|
10380
|
+
|
|
10337
10381
|
const {
|
|
10338
10382
|
state: {
|
|
10339
10383
|
emailError,
|
|
@@ -10359,7 +10403,10 @@ const RegisterButton = ({
|
|
|
10359
10403
|
onClick === null || onClick === void 0 ? void 0 : onClick();
|
|
10360
10404
|
},
|
|
10361
10405
|
disabled: isDisabled,
|
|
10362
|
-
isLoading: buttonDisabled
|
|
10406
|
+
isLoading: buttonDisabled,
|
|
10407
|
+
className: `${className} g-recaptcha`,
|
|
10408
|
+
"data-action": "register",
|
|
10409
|
+
"data-sitekey": (_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.security_key
|
|
10363
10410
|
}, otherProps), name !== null && name !== void 0 ? name : t("messages.createAccount"));
|
|
10364
10411
|
};
|
|
10365
10412
|
|
package/dist/index.esm.js
CHANGED
|
@@ -8446,6 +8446,7 @@ const optionsController = options => {
|
|
|
8446
8446
|
enableURLTriggers: initViewFromURL,
|
|
8447
8447
|
enableTheme: applyPelcroTheme,
|
|
8448
8448
|
enablePaywalls: initPaywalls,
|
|
8449
|
+
loadSecuritySDK: initSecuritySdk,
|
|
8449
8450
|
enableGoogleAnalytics: initGATracking
|
|
8450
8451
|
}; // Only execute enabled options
|
|
8451
8452
|
|
|
@@ -8507,6 +8508,18 @@ const loadPaymentSDKs = () => {
|
|
|
8507
8508
|
window.Pelcro.helpers.loadSDK("https://js.braintreegateway.com/web/3.69.0/js/paypal-checkout.min.js", "braintree-paypal-sdk");
|
|
8508
8509
|
}
|
|
8509
8510
|
};
|
|
8511
|
+
const initSecuritySdk = () => {
|
|
8512
|
+
const {
|
|
8513
|
+
whenSiteReady
|
|
8514
|
+
} = usePelcro.getStore();
|
|
8515
|
+
whenSiteReady(() => {
|
|
8516
|
+
var _window$Pelcro$site$r2;
|
|
8517
|
+
|
|
8518
|
+
const securityKey = (_window$Pelcro$site$r2 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r2 === void 0 ? void 0 : _window$Pelcro$site$r2.security_key;
|
|
8519
|
+
if (!securityKey) return;
|
|
8520
|
+
window.Pelcro.helpers.loadSDK(`https://www.google.com/recaptcha/enterprise.js?render=${securityKey}`, "pelcro-security-enteprise");
|
|
8521
|
+
});
|
|
8522
|
+
};
|
|
8510
8523
|
const initGATracking = () => {
|
|
8511
8524
|
var _ReactGA$initialize, _ReactGA$plugin, _ReactGA$plugin$requi;
|
|
8512
8525
|
|
|
@@ -8593,9 +8606,9 @@ const applyPelcroTheme = () => {
|
|
|
8593
8606
|
};
|
|
8594
8607
|
|
|
8595
8608
|
whenSiteReady(() => {
|
|
8596
|
-
var _window$Pelcro$site$
|
|
8609
|
+
var _window$Pelcro$site$r3, _window$Pelcro$site$r4;
|
|
8597
8610
|
|
|
8598
|
-
const primaryColorHex = (_window$Pelcro$site$
|
|
8611
|
+
const primaryColorHex = (_window$Pelcro$site$r3 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r3 === void 0 ? void 0 : (_window$Pelcro$site$r4 = _window$Pelcro$site$r3.design_settings) === null || _window$Pelcro$site$r4 === void 0 ? void 0 : _window$Pelcro$site$r4.primary_color;
|
|
8599
8612
|
|
|
8600
8613
|
if (!primaryColorHex) {
|
|
8601
8614
|
return;
|
|
@@ -8794,6 +8807,7 @@ const defaultOptions = {
|
|
|
8794
8807
|
enableURLTriggers: true,
|
|
8795
8808
|
enableTheme: true,
|
|
8796
8809
|
enablePaywalls: true,
|
|
8810
|
+
loadSecuritySDK: true,
|
|
8797
8811
|
enableGoogleAnalytics: false
|
|
8798
8812
|
};
|
|
8799
8813
|
const PelcroModalController = ({
|
|
@@ -9734,35 +9748,53 @@ const RegisterContainer = ({
|
|
|
9734
9748
|
jobTitle,
|
|
9735
9749
|
selectFields
|
|
9736
9750
|
} = filteredData;
|
|
9737
|
-
|
|
9738
|
-
|
|
9739
|
-
|
|
9740
|
-
|
|
9741
|
-
|
|
9742
|
-
|
|
9743
|
-
|
|
9744
|
-
|
|
9745
|
-
|
|
9746
|
-
|
|
9747
|
-
|
|
9748
|
-
dispatch({
|
|
9749
|
-
type: DISABLE_REGISTRATION_BUTTON,
|
|
9750
|
-
payload: false
|
|
9751
|
+
|
|
9752
|
+
if (!hasSecurityTokenEnabled()) {
|
|
9753
|
+
sendRegisterRequest();
|
|
9754
|
+
return;
|
|
9755
|
+
}
|
|
9756
|
+
|
|
9757
|
+
window.grecaptcha.enterprise.ready(async () => {
|
|
9758
|
+
var _window$Pelcro$site$r;
|
|
9759
|
+
|
|
9760
|
+
const token = await window.grecaptcha.enterprise.execute((_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.security_key, {
|
|
9761
|
+
action: "register"
|
|
9751
9762
|
});
|
|
9763
|
+
sendRegisterRequest(token);
|
|
9764
|
+
});
|
|
9752
9765
|
|
|
9753
|
-
|
|
9766
|
+
function sendRegisterRequest(securityToken) {
|
|
9767
|
+
window.Pelcro.user.register({
|
|
9768
|
+
email,
|
|
9769
|
+
password,
|
|
9770
|
+
first_name: firstName,
|
|
9771
|
+
last_name: lastName,
|
|
9772
|
+
security_token: securityToken,
|
|
9773
|
+
metadata: {
|
|
9774
|
+
organization,
|
|
9775
|
+
jobTitle,
|
|
9776
|
+
...selectFields
|
|
9777
|
+
}
|
|
9778
|
+
}, (err, res) => {
|
|
9754
9779
|
dispatch({
|
|
9755
|
-
type:
|
|
9756
|
-
payload:
|
|
9757
|
-
type: "error",
|
|
9758
|
-
content: getErrorMessages(err)
|
|
9759
|
-
}
|
|
9780
|
+
type: DISABLE_REGISTRATION_BUTTON,
|
|
9781
|
+
payload: false
|
|
9760
9782
|
});
|
|
9761
|
-
|
|
9762
|
-
|
|
9763
|
-
|
|
9764
|
-
|
|
9765
|
-
|
|
9783
|
+
|
|
9784
|
+
if (err) {
|
|
9785
|
+
dispatch({
|
|
9786
|
+
type: SHOW_ALERT,
|
|
9787
|
+
payload: {
|
|
9788
|
+
type: "error",
|
|
9789
|
+
content: getErrorMessages(err)
|
|
9790
|
+
}
|
|
9791
|
+
});
|
|
9792
|
+
onFailure(err);
|
|
9793
|
+
} else {
|
|
9794
|
+
onSuccess(res);
|
|
9795
|
+
}
|
|
9796
|
+
});
|
|
9797
|
+
}
|
|
9766
9798
|
};
|
|
9767
9799
|
|
|
9768
9800
|
const handleSocialLogin = ({
|
|
@@ -9913,6 +9945,15 @@ const RegisterContainer = ({
|
|
|
9913
9945
|
store: store$e
|
|
9914
9946
|
})));
|
|
9915
9947
|
};
|
|
9948
|
+
/**
|
|
9949
|
+
* Checks if the current site has security token enabled
|
|
9950
|
+
* @return {boolean}
|
|
9951
|
+
*/
|
|
9952
|
+
|
|
9953
|
+
function hasSecurityTokenEnabled() {
|
|
9954
|
+
const hasSecuritySdkLoaded = Boolean(window.grecaptcha);
|
|
9955
|
+
return hasSecuritySdkLoaded;
|
|
9956
|
+
}
|
|
9916
9957
|
|
|
9917
9958
|
var _path$l;
|
|
9918
9959
|
|
|
@@ -10302,8 +10343,11 @@ const RegisterPassword = props => /*#__PURE__*/React__default.createElement(Pass
|
|
|
10302
10343
|
const RegisterButton = ({
|
|
10303
10344
|
name,
|
|
10304
10345
|
onClick,
|
|
10346
|
+
className,
|
|
10305
10347
|
...otherProps
|
|
10306
10348
|
}) => {
|
|
10349
|
+
var _window$Pelcro$site$r;
|
|
10350
|
+
|
|
10307
10351
|
const {
|
|
10308
10352
|
state: {
|
|
10309
10353
|
emailError,
|
|
@@ -10329,7 +10373,10 @@ const RegisterButton = ({
|
|
|
10329
10373
|
onClick === null || onClick === void 0 ? void 0 : onClick();
|
|
10330
10374
|
},
|
|
10331
10375
|
disabled: isDisabled,
|
|
10332
|
-
isLoading: buttonDisabled
|
|
10376
|
+
isLoading: buttonDisabled,
|
|
10377
|
+
className: `${className} g-recaptcha`,
|
|
10378
|
+
"data-action": "register",
|
|
10379
|
+
"data-sitekey": (_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.security_key
|
|
10333
10380
|
}, otherProps), name !== null && name !== void 0 ? name : t("messages.createAccount"));
|
|
10334
10381
|
};
|
|
10335
10382
|
|