diff --git a/example/rp/index.html b/example/rp/index.html index f75a093edaca1375b829e0cf01320b829faa3b33..3dc8a490d276bffa6288f29ba33aaa9d0f2e74d4 100644 --- a/example/rp/index.html +++ b/example/rp/index.html @@ -161,12 +161,12 @@ $(document).ready(function() { $(".specify button.assertion").attr('disabled', 'true'); - navigator.id.request({ + navigator.id.experimental.request({ privacyURL: $('#privacy').attr('checked') ? "/privacy.html" : undefined, tosURL: $('#tos').attr('checked') ? "/TOS.html" : undefined, requiredEmail: requiredEmail, - oncomplete: function() { - loggit("oncomplete"); + onclose: function() { + loggit("onclose"); $(".specify button.assertion").removeAttr('disabled'); } }); diff --git a/resources/static/include_js/include.js b/resources/static/include_js/include.js index 4f8efdac14a98be4aca61e9d85f33e9576767ee2..e8255e426f2a38475ab2f319faea771a172a2608 100644 --- a/resources/static/include_js/include.js +++ b/resources/static/include_js/include.js @@ -952,8 +952,8 @@ if (compatMode === undefined) compatMode = requiredMode; else if (compatMode != requiredMode) { - throw "you cannot combine browserid event APIs with navigator.id.getVerifiedEmail() or navigator.id.get()" + - "this site should instead use navigator.id.request() and the browserid event API"; + throw "you cannot combine the navigator.id.watch() API with navigator.id.getVerifiedEmail() or navigator.id.get()" + + "this site should instead use navigator.id.request() and navigator.id.watch()"; } } @@ -1019,57 +1019,6 @@ } } - navigator.id.experimental = { - watch: function(options) { - checkCompat(false); - internalWatch(options); - } - }; - - navigator.id.logout = function() { - // allocate iframe if it is not allocated - _open_hidden_iframe(); - - // send logout message - commChan.notify({ method: 'logout' }); - }; - - // backwards compatibility function - navigator.id.get = function(callback, options) { - checkCompat(true); - internalWatch({ - onlogin: function(assertion) { - if (callback) { - callback(assertion); - callback = null - } - } - }); - options.oncomplete = function() { - if (callback) { - callback(null); - callback = null; - } - internalWatch({}); - }; - if (options && options.silent) { - if (callback) setTimeout(function() { callback(null); }, 0); - } else { - internalRequest(options); - } - }; - - // backwards compatibility function - navigator.id.getVerifiedEmail = function(callback) { - checkCompat(true); - navigator.id.get(callback); - }; - - navigator.id.request = function(options) { - checkCompat(false); - return internalRequest(options); - }; - function internalRequest(options) { // focus an existing window if (w) { @@ -1134,12 +1083,62 @@ } // complete - if (options && options.oncomplete) options.oncomplete(); - delete options.oncomplete; + if (options && options.onclose) options.onclose(); + delete options.onclose; }); }; - navigator.id._shimmed = true; + navigator.id = { + // The experimental API, not yet final + experimental: { + request: function(options) { + checkCompat(false); + return internalRequest(options); + }, + watch: function(options) { + checkCompat(false); + internalWatch(options); + } + }, + // logout from the current website + logout: function() { + // allocate iframe if it is not allocated + _open_hidden_iframe(); + // send logout message + commChan.notify({ method: 'logout' }); + }, + // get an assertion + get: function(callback, options) { + checkCompat(true); + internalWatch({ + onlogin: function(assertion) { + if (callback) { + callback(assertion); + callback = null + } + } + }); + options.oncomplete = function() { + if (callback) { + callback(null); + callback = null; + } + internalWatch({}); + }; + if (options && options.silent) { + if (callback) setTimeout(function() { callback(null); }, 0); + } else { + internalRequest(options); + } + }, + // backwards compatibility with old API + getVerifiedEmail: function(callback) { + checkCompat(true); + navigator.id.get(callback); + }, + // required for forwards compatibility with native implementations + _shimmed: true + }; } }());