miniflux-legacy/assets/js/persona.js

8 lines
16 KiB
JavaScript
Raw Normal View History

/**
* Uncompressed source can be found at https://login.persona.org/include.orig.js
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
(function(){var a,b=function(){function f(a){return Array.isArray?Array.isArray(a):a.constructor.toString().indexOf("Array")!=-1}function e(a,b,d){var e=c[b][d];for(var f=0;f<e.length;f++)e[f].win===a&&e.splice(f,1);c[b][d].length===0&&delete c[b][d]}function d(a,b,d,e){function f(b){for(var c=0;c<b.length;c++)if(b[c].win===a)return!0;return!1}var g=!1;if(b==="*")for(var h in c){if(!c.hasOwnProperty(h))continue;if(h==="*")continue;if(typeof c[h][d]=="object"){g=f(c[h][d]);if(g)break}}else c["*"]&&c["*"][d]&&(g=f(c["*"][d])),!g&&c[b]&&c[b][d]&&(g=f(c[b][d]));if(g)throw"A channel is already bound to the same window which overlaps with origin '"+b+"' and has scope '"+d+"'";typeof c[b]!="object"&&(c[b]={}),typeof c[b][d]!="object"&&(c[b][d]=[]),c[b][d].push({win:a,handler:e})}"use strict";var b=Math.floor(Math.random()*1000001),c={},g={},h=function(a){try{var b=JSON.parse(a.data);if(typeof b!="object"||b===null)throw"malformed"}catch(a){return}var d=a.source,e=a.origin,f,h,i;if(typeof b.method=="string"){var j=b.method.split("::");j.length==2?(f=j[0],i=j[1]):i=b.method}typeof b.id!="undefined"&&(h=b.id);if(typeof i=="string"){var k=!1;if(c[e]&&c[e][f])for(var l=0;l<c[e][f].length;l++)if(c[e][f][l].win===d){c[e][f][l].handler(e,i,b),k=!0;break}if(!k&&c["*"]&&c["*"][f])for(var l=0;l<c["*"][f].length;l++)if(c["*"][f][l].win===d){c["*"][f][l].handler(e,i,b);break}}else typeof h!="undefined"&&g[h]&&g[h](e,i,b)};window.addEventListener?window.addEventListener("message",h,!1):window.attachEvent&&window.attachEvent("onmessage",h);return{build:function(c){var h=function(a){if(c.debugOutput&&window.console&&window.console.log){try{typeof a!="string"&&(a=JSON.stringify(a))}catch(b){}console.log("["+k+"] "+a)}};if(!window.postMessage)throw"jschannel cannot run this browser, no postMessage";if(!window.JSON||!window.JSON.stringify||!window.JSON.parse)throw"jschannel cannot run this browser, no JSON parsing/serialization";if(typeof c!="object")throw"Channel build invoked without a proper object argument";if(!c.window||!c.window.postMessage)throw"Channel.build() called without a valid window argument";if(window===c.window)throw"target window is same as present window -- not allowed";var i=!1;if(typeof c.origin=="string"){var j;c.origin==="*"?i=!0:null!==(j=c.origin.match(/^https?:\/\/(?:[-a-zA-Z0-9_\.])+(?::\d+)?/))&&(c.origin=j[0].toLowerCase(),i=!0)}if(!i)throw"Channel.build() called with an invalid origin";if(typeof c.scope!="undefined"){if(typeof c.scope!="string")throw"scope, when specified, must be a string";if(c.scope.split("::").length>1)throw"scope may not contain double colons: '::'"}var k=function(){var a="",b="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";for(var c=0;c<5;c++)a+=b.charAt(Math.floor(Math.random()*b.length));return a}(),l={},m={},n={},o=!1,p=[],q=function(a,b,c){var d=!1,e=!1;return{origin:b,invoke:function(b,d){if(!n[a])throw"attempting to invoke a callback of a nonexistent transaction: "+a;var e=!1;for(var f=0;f<c.length;f++)if(b===c[f]){e=!0;break}if(!e)throw"request supports no such callback '"+b+"'";u({id:a,callback:b,params:d})},error:function(b,c){e=!0;if(!n[a])throw"error called for nonexistent message: "+a;delete n[a],u({id:a,error:b,message:c})},complete:function(b){e=!0;if(!n[a])throw"complete called for nonexistent message: "+a;delete n[a],u({id:a,result:b})},delayReturn:function(a){typeof a=="boolean"&&(d=a===!0);return d},completed:function(){return e}}},r=function(a,b,c){return window.setTimeout(function(){if(m[a]){var d="timeout ("+b+"ms) exceeded on method '"+c+"'";(1,m[a].error)("timeout_error",d),delete m[a],delete g[a]}},b)},s=function(b,d,e){if(typeof c.gotMessageObserver=="function")try{c.gotMessageObserver(b,e)}catch(i){h("gotMessageObserver() raised an exception: "+i.toString())}if(e.id&&d){if(l[d]){var j=q(e.id,b,e.callbacks?e.callbacks:[]);n[e.id]={};try{if(e.callbacks&&f(e.callbacks)&&e.callbacks.length>0)for(var k=0;k<e.callbacks.length;k++){var o=e.callbacks[k],p=e.params,r=o.split("/");for(var s=0;s<r.length-1;s++){var t=r[s];typeof p[t]!="object"&&(p[t]={}),p=p[t]}p