2017-01-11 23:27:41 -05:00
|
|
|
/* eslint-disable func-names, space-before-function-paren, no-var, prefer-rest-params, wrap-iife, no-console, quotes, prefer-template, max-len */
|
2016-12-14 00:26:26 -05:00
|
|
|
/* global u2f */
|
|
|
|
|
2016-07-24 16:45:11 -04:00
|
|
|
(function() {
|
|
|
|
this.U2FError = (function() {
|
2017-01-02 05:25:28 -05:00
|
|
|
function U2FError(errorCode, u2fFlowType) {
|
2016-07-24 16:45:11 -04:00
|
|
|
this.errorCode = errorCode;
|
2017-05-08 15:15:29 -04:00
|
|
|
this.message = this.message.bind(this);
|
2016-07-24 16:45:11 -04:00
|
|
|
this.httpsDisabled = window.location.protocol !== 'https:';
|
2017-01-02 05:25:28 -05:00
|
|
|
this.u2fFlowType = u2fFlowType;
|
2016-07-24 16:45:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
U2FError.prototype.message = function() {
|
2017-01-02 05:25:28 -05:00
|
|
|
if (this.errorCode === u2f.ErrorCodes.BAD_REQUEST && this.httpsDisabled) {
|
|
|
|
return 'U2F only works with HTTPS-enabled websites. Contact your administrator for more details.';
|
|
|
|
} else if (this.errorCode === u2f.ErrorCodes.DEVICE_INELIGIBLE) {
|
|
|
|
if (this.u2fFlowType === 'authenticate') return 'This device has not been registered with us.';
|
|
|
|
if (this.u2fFlowType === 'register') return 'This device has already been registered with us.';
|
2016-07-24 16:45:11 -04:00
|
|
|
}
|
2017-01-02 05:25:28 -05:00
|
|
|
return "There was a problem communicating with your device.";
|
2016-07-24 16:45:11 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
return U2FError;
|
|
|
|
})();
|
2017-02-10 01:50:50 -05:00
|
|
|
}).call(window);
|