ReCaptcha v3 not feeding response token object in IE 11 - javascript

I'm working on an MVC .Net application.
We introduced reCaptcha v3 in it recently, it works perfectly in Chrome and Firefox, but not at all in IE.
Here is the code contained in the header section:
<script src="https://www.google.com/recaptcha/api.js?render=#ViewBag.CaptchaSiteKey"></script>
<script type="text/javascript">
grecaptcha.ready(function () {
var test = grecaptcha.execute('#ViewBag.CaptchaSiteKey', { action: '#ViewBag.CaptchaEnvironment'+'_' + '#ViewBag.CaptchaActionName'}).then(
function (token) {
// verify the token on the server
document.getElementById("RecaptchaResponse").value = token;
}, function (reason) {
document.getElementById("RecaptchaResponse").value = reason;
});
});
</script>
The Viewbag variables are set as expected, nothing is missing.
The object that need to be fed is created in the form contained in my body section:
input id="RecaptchaResponse" name="RecaptchaResponse" type="hidden" autocomplete="off"
But remains empty when using in IE11.
I've read many articles that were kind of speaking about such behavior, but nothing worked.
Thanks you in advance

Google reCAPTCHA v3 utilizes "JavaScript Promises" in order to function properly.
In your code example, grecaptcha.execute(...) is issuing a "promise" for a token. Once that promise is "fulfilled", the .then(function() { ... }) portion of your code is executed.
Modern versions of Chrome/Firefox support JavaScript Promises. Unfortunately, IE11 does not. In order for promises to work on IE11, you would need to include a polyfill (see: https://github.com/stefanpenner/es6-promise).

Related

Resource not found when attempting to send voice message through AWS Pinpoint

I currently have a Node.js service to send a voice call through AWS Pinpoint. However, I'm getting a Resource not found response after making a call. I tested with PinpointSMSVoice.sendVoiceMessage which succeeds in making the call. The one that doesn't work is Pinpoint.sendMessages. My request object looks like this:
{
ApplicationId: 'project-id',
MessageRequest: {
Addresses: {
['destination-number']: {
ChannelType: 'VOICE',
Substitutions: {
// Using a template
}
}
},
MessageConfiguration: {
VoiceMessage: {
LanguageCode: 'en-US',
OriginationNumber: 'origination-number'
}
},
TemplateConfiguration: {
VoiceTemplate: {
Name: 'voice-template
}
}
}
};
pinpoint.sendMessages(requestObj, callback);
I should note that I am not in sandbox mode, it was approved and moved to production mode. I have tested the same setup with SMS which works perfectly well. I'm not quite sure what the difference is between PinpointSMSVoice.sendVoiceMessage and Pinpoint.sendMessages, except for the fact that Pinpoint.sendMessages allows me to set a template. Any ideas on what else I could be missing?
I'm encountering the same issue. It works using PinPointSMSVoice client, but that won't let me use a template. I've also tested this using V3 of the AWS JS SDK, which modularizes the clients #aws-sdk/client-pinpoint-sms-voice and #aws-sdk/client-pinpoint, but the behaviour is the same. It works uses the same tempplate in the 'Test Message' feature in the console, so seems to be a JS SDK issue. I suggest you raise the issue with JS SDK team https://github.com/aws/aws-sdk-js-v3
When you use PinPoint to perform the sendVoiceMessage operation, you need to set the content type to application/json. If you do not, you get this exception. To see an example (this is the AWS Java API), see this Github URL:
https://github.com/awsdocs/aws-doc-sdk-examples/blob/master/javav2/example_code/pinpoint/src/main/java/com/example/pinpoint/SendVoiceMessage.java

Why reCAPTCHA doesnt work in actual Chrome?

I was developing a site on a local server (Open Server) with a built-in Google Chrome browser version 68.0.3440.106. Captcha v2 is connected to forms, but on more modern versions of the same browser I get the error Uncaught (in promise) null on anchor: 1. I don’t understand what the problem is, and how to solve it.
Here is my code:
"use strict";
var idCaptcha1;
var onloadReCaptchaInvisible = function () {
try {
//login
idCaptcha1 = grecaptcha.render('recaptcha1', {
"sitekey": "mycaptchakey",
"callback": "onSubmitReCaptcha1",
"size": "invisible"
});
} catch (e) {
//nothing
}
}
function onSubmitReCaptcha1(token) {
sendForm('signin', idCaptcha1);
}
So its working fine in old browser, when I want to send ajax form, it trigger captcha and user can work with it. What I did wrong? Except didnt update browser of local server of course ><

JavaScript Methods Not Executing Consistently In Mobile Safari vs. Android Chrome

I have a method in JavaScript that looks as follows:
function onAction() {
getValue1();
getValue2();
getValue3();
}
When I call onAction() I see two different behaviors between Mobile Safari and Android Chrome. In Safari, I get the values for all three methods. On Android Chrome, I only get the value of the last method. It doesn't matter which one is last. I suspected it may be an execution timing issue and attempted the following:
function onAction() {
new Promise(function(resolve,reject) {
resolve(1);
})
.then(function() {
getValue1();
})
.then(function() {
getValue2();
})
.then(function() {
getValue3();
});
}
Again, it works fine in Mobile Safari, but not Android Chrome.
I'm sure I'm missing something obvious, but it's eluding me. If it matters, the getValue* functions are used to get values via each platform's mechanism for Native Code->JavaScript bridging.
Any help is appreciated. Please let me know if I can supply any more information.
Regards,
Rob
**Additional Info **
The getValueX functions don't return any values. They trigger values to be pushed over to the native wrapper:
function getReaderSDKVersion() {
var message = {'action' : MPDataEnum.SDKVersion};
raiseMessage(message);
}
function raiseMessage(message) {
if (isPlatformiOS()) {
window.webkit.messageHandlers.interOp.postMessage(message);
} else {
var url = "mpcard://runMethod#" + JSON.stringify(message);
window.location.href = url;
}
}
The issue is answered here:
Triggering shouldStartLoadWithRequest with multiple window.location.href calls
Whereas this was an issue in most browsers, it doesn't appear to affect Mobile Safari now.

Can AngularJS v1.3 work with Ektron v8.7 and its FormBlock server control?

I've been trying to implement AngularJS v1.3 on an Ektron v8.7 site, and I've hit a rather strange roadblock.
When an Ektron server control (in this case, a FormBlock) is on the page, extra javascript is injected into the page. One of these javascript files is Ektron.Xml.js. My page uses AngularJS to make AJAX web service calls, and all this works fine in Chrome, Firefox, and IE 11. However, the AJAX calls fail to even send when I'm using AngularJS v1.3 and IE 10 or below. It works, though, if I target v1.2 of AngularJS. It also works with v1.3 of AngularJS if I remove the Ektron server controls from the page.
Here's what I found. First, there is a difference in AngularJS between v1.2 and v1.3 in how Angular creates the XMLHttpRequest object in httpBackend.js:
AngularJS v1.3 (https://github.com/angular/angular.js/blob/g3_v1_3/src/ng/httpBackend.js)
function createXhr() {
return new window.XMLHttpRequest();
}
AngularJS v1.2 (https://github.com/angular/angular.js/blob/g3_v1_2/src/ng/httpBackend.js)
function createXhr(method) {
//if IE and the method is not RFC2616 compliant, or if XMLHttpRequest
//is not available, try getting an ActiveXObject. Otherwise, use XMLHttpRequest
//if it is available
if (msie <= 8 && (!method.match(/^(get|post|head|put|delete|options)$/i) ||
!window.XMLHttpRequest)) {
return new window.ActiveXObject("Microsoft.XMLHTTP");
} else if (window.XMLHttpRequest) {
return new window.XMLHttpRequest();
}
throw minErr('$httpBackend')('noxhr', "This browser does not support XMLHttpRequest.");
}
Second, one of Ektron's files appears to be changing the constructor for the XmlHttpRequest object.
/WorkArea/FrameworkUI/js/Ektron/Ektron.Xml.js, starting at line #1274
// IE initialization
if (Sarissa._SARISSA_IS_IE) {
// some code omitted for brevity...
XMLHttpRequest = function () {
if (!_SARISSA_XMLHTTP_PROGID) {
_SARISSA_XMLHTTP_PROGID = Sarissa.pickRecentProgID(["Msxml2.XMLHTTP.6.0", "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP", "Microsoft.XMLHTTP"]);
}
return new ActiveXObject(_SARISSA_XMLHTTP_PROGID);
};
// ...
}
From what I can tell, this Sarissa._SARISSA_IS_IE property seems to not recognize IE 11. This bug seems to confirm my suspicion: http://sourceforge.net/p/sarissa/bugs/63/
From the comments in the js file, it appears to include version 0.9.9.4 of Sarissa.
So my question is: Is there anything I can do here? Do newer versions of Ektron still do the same thing? Is this a matter of Ektron needing to include a more recent version of Sarissa? Can I do anything to make AngularJS v1.3 work with Ektron v8.7's server controls?

What is this obscure error in Google Analytics tracking code on a _trackEvent() call?

I am calling the Google Analytics _trackEvent() function on a web page, and get back an error from the obfuscated Google code. In Firebug, it comes back "q is undefined". In Safari developer console: "TypeError: Result of expression 'q' [undefined] is not an object."
As a test, I have reduced the page to only this call, and still get the error back. Besides the necessary elements and the standard Google tracking code, my page is:
<script>
pageTracker._trackEvent('Survey', 'Checkout - Survey', 'Rating', 3);
</script>
Results is that error.
What's going on here?
This problem seems to occure when the page is not fully loaded yet: http://www.google.com/support/forum/p/Google+Analytics/thread?tid=4596554b1e9a1545&hl=en
The provided solution is to wait for pageTracker.cb
function trackEvent(target, action, opt_label, opt_value) {
if(pageTracker && !pageTracker.cb) {
setTimeout(function() {
trackEvent(target, action, opt_label, opt_value);
}, 200);
return;
}
pageTracker._trackEvent(target, action, opt_label, opt_value);
}
Actually the answer no. 1 is not correct. That's because pageTracker.cb never gets set (it's an obfuscated property name) with other versions of GA.
You should call upon initialization:
pageTracker._initData()
This looks like a bug in ga.js introduced when they added _initData() functionality to _trackPageview(). Unfortunately _initData() isn't actually called after the conditional. Hope they fix it before they deprecate_initData() for good.
e.g.
This page suggests the above should work without calling _initData():
http://www.google.com/support/googleanalytics/bin/answer.py?hl=en&answer=55527

Categories

Resources