<commit_before>/*global u2f*/ //TODO: currently coming from https://demo.yubico.com/js/u2f-api.js
(function () {
    'use strict';

    angular
      .module('password.mfa')
      .factory('u2fService', u2fService);

    function u2fService($q, $location) {
        var available = false,
            service = {
                isAvailable: isAvailable,
                register: register
            };

        activate();

        return service;

        //////////////////////////////////////////////////////////////////

        function activate() {
            sniffFeature();
        }

        function sniffFeature() {
            // when u2f is supported in browser, the callback will be called no matter what.
            u2f.sign('', '', [], function () {
                available = true;
                console.info('u2f IS available');
            });
        }

        function isAvailable() {
            return available;
        }

        function register(challenge) {
            var deferred = $q.defer(),
                appId = challenge.appId || $location.protocol() + '://' + $location.host();

            u2f.register(appId, [challenge], [], handleKeyResponse);

            return deferred.promise;

            //////////////////////////////////////////////////////////////

            function handleKeyResponse(response) {
                return response.errorCode        ?
                       deferred.reject(response) :
                       deferred.resolve(response);
            }
        }
    }
})();<commit_msg>oops, accidentally left some debugging stuff in.<commit_after>/*global u2f*/ //TODO: currently coming from https://demo.yubico.com/js/u2f-api.js
(function () {
    'use strict';

    angular
      .module('password.mfa')
      .factory('u2fService', u2fService);

    function u2fService($q, $location) {
        var available = false,
            service = {
                isAvailable: isAvailable,
                register: register
            };

        activate();

        return service;

        //////////////////////////////////////////////////////////////////

        function activate() {
            sniffFeature();
        }

        function sniffFeature() {
            // when u2f is supported in browser, the callback will be called no matter what.
            u2f.sign('', '', [], function () {
                available = true;
            });
        }

        function isAvailable() {
            return available;
        }

        function register(challenge) {
            var deferred = $q.defer(),
                appId = challenge.appId || $location.protocol() + '://' + $location.host();

            u2f.register(appId, [challenge], [], handleKeyResponse);

            return deferred.promise;

            //////////////////////////////////////////////////////////////

            function handleKeyResponse(response) {
                return response.errorCode        ?
                       deferred.reject(response) :
                       deferred.resolve(response);
            }
        }
    }
})();
{'fraction_non_alphanumeric': 0.1878417497587649, 'fraction_numerical': 0.005467996140238018, 'mean_word_length': 1.1932299012693934, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3704724', 'n_tokens_mistral': 753, 'n_tokens_neox': 698, 'n_words': 159}