Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

First xauth checkin for git

  • Loading branch information...
commit 6670a267985404e6296409654177e6ebae441143 0 parents
Jian Shen authored
177 LICENSE
@@ -0,0 +1,177 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
110 README.md
@@ -0,0 +1,110 @@
+XAuth
+=====
+
+An open platform for extending authenticated user services across the web.
+
+* The average internet user has more online services than ever (Emails, Social Networks)
+* Many of these services provide APIs (OpenSocial, OpenGraphProtocol) thru delegated authentication (OAuth) to publisher sites (NYTimes, WSJ)
+* Publisher sites don't have an easy way of knowing which services a visitor uses so they present [all available options](http://factoryjoe.com/blog/2009/04/06/does-openid-need-to-be-hard/) and push the decision to the user
+
+XAuth provides a more efficient method for publishers to recognize when site visitors are logged in to those online services enabling them to present more meaningful and relevant options.
+
+
+### XAuth Usage for Online Service Providers ###
+
+As an online service provider wanting to publish the presence of an authenticated user, include the xauth.js client library on the landing page after a user is authenticated.
+
+ <!-- html of onlineservice.com -->
+ <script type="text/javascript" src="http://xauth.org/xauth.js"></script>
+
+An XAuth object will be created in the global scope allowing you to extend an XAuth Token. The token that you extend can be anything from a boolean flag indicating the presence of an authenticated user to more sophisticated consumable information such as a revokable delegated auth token that publishers can use to access more functionality. **The example code below is only one possible implementation**
+
+ <!-- html of onlineservice.com -->
+ <script type="text/javascript">
+
+ XAuth.extend({
+ token: "user_status=online", // Whatever format the extender wants
+ expire: 1272529884557, // Could be however long your Remember Me lasts
+ extend: ["*"],
+ callback: extendSuccessCallback
+ });
+
+ </script>
+
+Your token will be saved under the domain name of the page this script executes on. Now Publishers have access to your token.
+
+
+### XAuth Usage for Publishers ###
+
+As a publisher wanting to know the presence of an authenticated user, include the xauth.js client library on any page needing the information.
+
+ <!-- html of youface.com -->
+ <script type="text/javascript" src="http://xauth.org/xauth.js"></script>
+
+An XAuth object will be created in the global scope allowing you to retrieve XAuth Tokens. **The example code below is only one possible implementation**
+
+ <!-- html of youface.com -->
+ <script type="text/javascript">
+ function retrieveCallback(response) {
+ var tokens = response.tokens;
+ for(var domain in tokens) {
+ var token = tokens[domain]['token'];
+ var expiration = tokens[domain]['expire']; // could be useful
+ if(token == 'user_status=online') {
+ // Do something smart for the user for this service!
+ }
+ }
+ }
+
+ XAuth.retrieve({
+ retrieve: ["www.meebo.com", "www.youface.com", "onlineservice.com"],
+ callback: retrieveCallback
+ });
+
+ </script>
+
+Your callback function will be passed the response object with a hash of tokens keyed by hostname. You can iterate thru the list of tokens available to you at the time and then be able to present more relevant UI to the visitor to your site, such as sorting already logged in social sharing sites first.
+
+
+### How does XAuth work? ###
+
+XAuth relies on three features available only in modern browsers (HTML5) and is 100% front end technology (meaning it could one day just be a feature of the browser ;)
+
+* [`localStorage`](http://dev.w3.org/html5/webstorage/#the-localstorage-attribute) - persistent storage mechanism to store the tokens completely client-side
+* [`postMessage`](http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html) - ability to send information between domains and securely determine what domain information is coming from
+* [`JSON`](http://wiki.ecmascript.org/doku.php?id=es3.1:json_support) - safer methods than eval for serializing and deserializing JSON strings into JavaScript objects when passed via postMessage
+
+#### When you include the xauth.js script ####
+
+An `XAuth` object is created in the global scope having three methods: `extend`, `retrieve`, `expire` and one member flag `disabled` to tell you if this browser has the capabilities to support XAuth. The code sets up a listener for postMessage events on the window.
+
+#### When you call an XAuth method (extend, expire or retrieve) ####
+
+Your passed in parameters are cleaned and turned into a consumable request object of the form:
+
+ {
+ cmd: 'xauth::methodname', // based on what you called
+ id: unique_numeric_id, // generated by xauth.js
+ ... other key value parameters specific to this method ...
+ callback: yourCallbackFunctionReference
+ }
+
+These request objects are cached, serialized into JSON strings and then sent via postMessage to a hidden iframe (http://xauth.org/server.html) that is created on demand, after the first XAuth method call is made. Any XAuth method calls made prior to the iframe being ready are automatically placed in a queue.
+
+#### The xauth.org iframe and security ####
+
+The xauth.org iframe code is the enforcer of the rules defined in the XAuth spec, including deciding who has access to tokens in a retrieve request, writing tokens to localStorage in an extend request and deleting expired tokens.
+
+After setting up a postMessage event listener, any incoming message event is deserialized into a consumable request object (see above) or is otherwise ignored. It is the browser's responsibility to properly implement the window.postMessage security model and include an immutable and unspoofable event.origin property on every incoming postMessage event, telling the iframe exactly where an event originated from. The iframe processes the request on behalf of the retriever identified by event.origin and sends a postMessage back to the calling retriever window with the results.
+
+
+### Site performance impacts ###
+
+We've tried to keep the code brief (unlike this documentation). The xauth.js file that you include on a page is about **1kb**. If you make a call to an XAuth method, an iframe to http://xauth.org/server.html is created which results in an additional **2kb** of bandwidth. Both of these files are heavily cached and gzip compressed from CDNs. There are no other http requests after both files are loaded. All of the logic behind XAuth lives inside the browser. In the future, it would be great to see this kind of functionality built straight into the browser, thereby decoupling the central domain dependency.
+
+
+### More Resources ###
+
+Discuss XAuth at http://groups.google.com/group/xauth
+Learn even more at http://xauth.org/info
+Check out code at http://github.com/xauth/xauth/
22 build.sh
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+if [ ! -d "release" ]; then
+ mkdir "release"
+fi
+
+YUI="gij -jar tools/yuicompressor-2.4.2.jar --type js"
+
+# Compress server and client code
+echo '<!doctype html><script type="text/javascript">' > release/server.html
+$YUI src/server.js >> release/server.html
+echo '</script>' >> release/server.html
+
+$YUI src/xauth.js > release/xauth.js
+
+# Copy rest of static files
+cp -R src/info release
+cp -R src/spec release
+cp src/index.html release
+
+find ./release -name '.svn' -exec rm -r -f {} \;
+find ./release -name '.git' -exec rm -r -f {} \;
314 release/index.html
@@ -0,0 +1,314 @@
+<!--
+ Copyright 2010 Meebo Inc.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<!doctype html>
+<html>
+<head>
+<title>XAuth</title>
+<script type="text/javascript">
+if(document.domain == 'www.xauth.org') {
+ document.location.replace(document.location.href.replace('www.xauth.org', 'xauth.org'));
+}
+/**
+ XAuth Token Manager
+
+ 2010-04-14
+ First version of xauth manager code
+ -Jian Shen, Meebo
+**/
+
+function $(id) {
+ return document.getElementById(id);
+}
+
+var XAuthManager = (function() {
+ var supported = !!(window.postMessage && window.localStorage && window.JSON);
+ var disabled = ('1' == localStorage.getItem('disabled.xauth.org'));
+
+ function setDisabled(disable) {
+ disabled = disable;
+ localStorage.setItem('disabled.xauth.org',disabled?'1':'0');
+ }
+
+ function getToken(key) {
+ if(key == 'disabled.xauth.org') {
+ return null;
+ }
+
+ var tokenStr = localStorage.getItem(key);
+ if(!tokenStr) {
+ return null;
+ }
+
+ var store = JSON.parse(tokenStr);
+ return store;
+ }
+
+ function saveToken(key, store) {
+ localStorage.setItem(key, JSON.stringify(store));
+ }
+
+ function updateStatus() {
+ var status = 'Enabled';
+ var disableButton = $('disable-button');
+ var showTokens = true;
+ if(!supported) {
+ status = '<span class="warning">Unsupported</span>';
+ disableButton.setAttribute('disabled','true');
+ showTokens = false;
+ } else if(disabled) {
+ status = '<span class="warning">Disabled</span>';
+ disableButton.innerHTML = 'Enable XAuth';
+ disableButton.removeAttribute('disabled');
+ showTokens = false;
+ } else {
+ disableButton.innerHTML = 'Disable XAuth';
+ disableButton.removeAttribute('disabled');
+ }
+ $('status').innerHTML = status;
+ $('tokens').style.display = showTokens?'block':'none';
+ }
+
+ function escapeHTML(str) {
+ if (!str || !str.length) { return str; }
+
+ var entities = {
+ '&': '&amp;',
+ '"': '&quot;',
+ '<': '&lt;',
+ '>': '&gt;'
+ };
+
+ var re = /[&"<>]/g;
+ return str.replace(re, function (substr) { return entities[substr]; });
+ }
+
+ function getStatusHTML(id, store) {
+ var status = '';
+ if(store.token) {
+ status = '<span class="view" onclick="XAuthManager.showToken(\'' + id + '\')">Active Token</span>'
+ + '<div class="token-view" id="token-' + id + '"><textarea readonly="readonly">' + escapeHTML(store.token) + '</textarea>Expiration: ' + (store.session?'End of browser session':escapeHTML(store.expire)) + '</div>';
+ } else {
+ status = 'No Token'
+ }
+ if(store.block) {
+ status = '<span class="blocked">Blocked</span>';
+ }
+ return status;
+ }
+
+
+ function getTokenRowHTML(id) {
+ var store = getToken(id);
+ if(!store) { return null; }
+
+ return ('<td>' + id + '</td><td id="status-' + id + '">' + getStatusHTML(id, store) + '</td><td>'
+ + '<button onclick="XAuthManager.deleteToken(\'' + id + '\')">Delete</button>&nbsp;'
+ + '<button id="blockbutton-' + id + '" onclick="XAuthManager.toggleBlock(\'' + id + '\')">' + (store.block?'Unblock':'Block') + '</button>'
+ + '</td>');
+ }
+
+ function toggleXAuth() {
+ setDisabled(!disabled);
+ updateStatus();
+ }
+
+ function toggleBlock(id) {
+ var store = getToken(id);
+ if(!store) { return; }
+ if(store.block) {
+ delete store.block;
+ } else {
+ store.block = 1;
+ }
+ saveToken(id, store);
+ $('blockbutton-' + id).innerHTML = (store.block?'Unblock':'Block');
+
+ $('status-' + id).innerHTML = getStatusHTML(id, store);
+ }
+
+ function deleteToken(id) {
+ localStorage.removeItem(id);
+ var row = $('row-' + id);
+ row.parentNode.removeChild(row);
+ }
+
+ function showToken(id) {
+ $('token-' + id).style.display = 'block';
+ }
+
+ function listTokens() {
+ var tableStr = '<table class="tokens"><tbody>';
+ tableStr += '<tr><th>Extender Domain</th><th class="status-column">Status</th><th class="action-column">Actions</th>';
+
+ for(var i=0; i<localStorage.length; i++) {
+ var key = localStorage.key(i);
+ var html = getTokenRowHTML(key);
+ if(html) {
+ tableStr += ('<tr id="row-' + key + '">' + html + '</tr>');
+ }
+ }
+
+ tableStr += '</tbody></table>';
+
+ document.getElementById('tokens').innerHTML = tableStr;
+ }
+
+ function init() {
+ updateStatus();
+ listTokens();
+ }
+
+ return {
+ init: init,
+ toggleXAuth: toggleXAuth,
+ toggleBlock: toggleBlock,
+ deleteToken: deleteToken,
+ showToken: showToken
+ }
+
+})();
+
+</script>
+<style>
+body {
+ padding: 0 30px;
+ margin: 0;
+ font-family: "Helvetica Neue", Helvetica, Arial;
+}
+
+.body {
+ width: 1000px;
+ margin: auto;
+}
+
+button {
+ font-size: 12px;
+}
+
+.navigation {
+ margin-right: 20px;
+ float: left;
+ line-height: 1.5em;
+ padding: 0 20px 20px;
+ background: #EEE;
+}
+
+.navigation ul {
+ padding: 0;
+ margin: 0;
+}
+
+.navigation li {
+ display: block;
+}
+
+.content {
+ float: left;
+ width: 800px;
+}
+
+.panel {
+ margin: 40px 0;
+}
+
+.view:hover {
+ text-decoration: underline;
+ color: #009;
+ cursor: pointer;
+}
+
+.blocked {
+ color: #999;
+}
+
+.warning {
+ color: #FFF;
+ background: #A00;
+ padding: 4px;
+ border-radius: 0.3em;
+}
+
+.token-view {
+ display: none;
+}
+
+.token-view textarea {
+ width: 100%;
+ height: 4em;
+}
+
+table {
+ border: 1px solid #CCC;
+ width: 100%;
+}
+
+table td, table th {
+ vertical-align: top;
+ line-height: 1.5em;
+ padding: 10px;
+ background: #EEE;
+ text-align: center;
+}
+
+th.status-column {
+ width: 300px;
+}
+
+th.action-column {
+ width: 150px;
+}
+
+.rightheader {
+ display: block;
+ float: right;
+ text-align: right;
+}
+</style>
+</head>
+<body onload="XAuthManager.init()">
+ <div class="body">
+ <div class="navigation">
+ <h2>XAuth</h2>
+ <ul>
+ <li><a href="/">Manage</a></li>
+ <li><a href="/info">Information</a></li>
+ <li><a href="/spec">Specification</a></li>
+ </ul>
+ </div>
+ <div class="content">
+ <h2>Manage Browser Settings</h2>
+ <p>See and manage XAuth Extenders for this browser.</p>
+ <div id="status-panel" class="panel">
+ <table><tbody>
+ <tr><th colspan="3">XAuth is <span id="status">Enabled</span> in this browser</th>
+ <th class='action-column'><button id="disable-button" onclick="XAuthManager.toggleXAuth()">Disable XAuth</button></th>
+ </tr>
+ </tbody></table>
+ </div>
+ <div id="tokens" class="panel"></div>
+ </div>
+ </div>
+ <script type="text/javascript">
+ var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
+ document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
+ </script>
+ <script type="text/javascript">
+ try {
+ var pageTracker = _gat._getTracker("UA-3931792-8");
+ pageTracker._trackPageview();
+ } catch(err) {}</script>
+</body>
+</html>
206 release/info/index.html
@@ -0,0 +1,206 @@
+<!--
+ Copyright 2010 Meebo Inc.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<!doctype html>
+<html>
+<head>
+<title>XAuth Info</title>
+<style>
+body {
+ padding: 0 30px;
+ margin: 0;
+ font-family: "Helvetica Neue", Helvetica, Arial;
+}
+
+.body {
+ width: 1000px;
+ margin: auto;
+}
+
+.navigation {
+ margin-right: 20px;
+ float: left;
+ line-height: 1.5em;
+ padding: 0 20px 20px;
+ background: #EEE;
+}
+
+.navigation ul {
+ padding: 0;
+ margin: 0;
+}
+
+.navigation li {
+ display: block;
+}
+
+.content {
+ float: left;
+ width: 800px;
+}
+
+ul.blogs {
+ line-height: 1.4em;
+}
+
+.rightheader {
+ display: block;
+ float: right;
+ text-align: right;
+}
+
+.method {
+ background: #F5F5F5;
+ overflow: auto;
+ margin-bottom: 20px;
+}
+
+.method .name {
+ background: #EEE;
+ padding: 10px;
+ font-size: 1.3em;
+}
+
+.method .params {
+ padding: 10px;
+}
+
+.method .sandbox {
+ float: right;
+ padding: 20px;
+ background: #DDD;
+ width: 400px;
+ font-family: Courier;
+ margin-left: 10px;
+}
+
+.method .sandbox .code {
+ background: #DDD;
+ font-family: Courier;
+ border: 1px solid #DDD;
+ width: 100%;
+}
+
+#code_extend {
+ height: 150px;
+}
+
+#code_expire {
+ height: 50px;
+}
+
+#code_retrieve {
+ height: 120px;
+}
+
+#code_copy {
+ height: 52px;
+}
+
+.method .sandbox .code:hover {
+ border-color: #000;
+ background: #EEE;
+}
+
+.method .sandbox .execute {
+ padding: 20px 0;
+}
+
+table.playground td {
+ padding: 4px 4px 4px 0;
+ vertical-align: top;
+ line-height: 1.5em;
+}
+</style>
+</head>
+
+<body>
+ <div class="body">
+ <div class="navigation">
+ <h2>XAuth</h2>
+ <ul>
+ <li><a href="/">Manage</a></li>
+ <li><a href="/info">Information</a></li>
+ <li><a href="/spec">Specification</a></li>
+ </ul>
+ </div>
+ <div class="content">
+ <div class="rightheader">
+ contact: <a href="mailto:xauth@meebo-inc.com&subject=xauth.org">xauth@meebo-inc.com</a><br>
+ <a href="http://groups.google.com/group/xauth">XAuth Discussion Group</a>
+ </div>
+ <h2>Extended Authentication (XAuth)</h2>
+
+ <div class="method">
+ <div class="name">Quick Introductions</div>
+ <div class="params">
+ <ul class="blogs">
+ <li><a target="_blank" href="http://blog.meebo.com/?p=2391">Introducing XAuth</a> - Meebo Dev Blog</li>
+ <li><a target="_blank" href="http://developer.yahoo.net/blog/archives/2010/04/xauth_oauth_and_yahoo_openid.html">XAuth, OAuth, and Yahoo! OpenID</a> - Yahoo! Developer Network</li>
+ <li><a target="_blank" href="http://googlesocialweb.blogspot.com/2010/04/simplifying-social-web-with-xauth.html">Simplifying the social web with XAuth</a> - Google Social Web</li>
+ </ul>
+ </div>
+ </div>
+ <div class="method">
+ <div class="name">What is XAuth?</div>
+ <div class="params">
+ <p>XAuth is an open platform for extending authenticated user services across the web.
+
+ <p>Participating services generate a browser token for each of their users. Publishers can then recognize when site visitors are logged in to those online services and present them with meaningful, relevant options.
+ <p>Users can choose to authenticate directly from the publisher site and use the service to share, interact with friends, or participate in the site's community. The XAuth Token can be anything, so services have the flexibility to define whatever level of access they choose.
+
+ </div>
+ </div>
+ <div class="method">
+ <div class="name">Benefits</div>
+ <div class="params">
+ <p>For site publishers, the multiple HTTP requests necessary to recognize every potential online service are slow and inefficient. XAuth provides a central domain (http://xauth.org) with a lightweight JavaScript library that can be accessed via a single HTTP request.
+
+ <p>Users are often presented with many social services when browsing a site. They likely only are interested in one or two. XAuth allows the user experience to be immediately relevant, so that they can easily access the services that are useful to them.
+
+ <p>Service providers participating in XAuth can reach their existing userbase anywhere on the web without being buried in the deluge of other social services that may be available and competing for space on the publisher site.
+
+ <p>The service providers have complete control over the features they enable for the publisher site. The XAuth Token could be a single bit denoting the existence of an authenticated user, or it could be a session ID that passes public profile info via API calls from the publisher.
+
+ <p>Users can decide which services pass data to sites through XAuth. To view and modify any currently enabled browser XAuth tokens, go to <a href="/">xauth.org/</a>
+
+ </div>
+ </div>
+
+ <div class="method">
+ <div class="name">Developing on XAuth</div>
+ <div class="params">
+ <p>Developers can view the XAuth specifications and explore XAuth calls at <a href="/spec/">xauth.org/spec/</a> </p>
+ <p>More Great Resources:</p>
+ <ul class="blogs">
+ <li><a target="_blank" href="http://googlecode.blogspot.com/2010/04/using-xauth-to-simplify-social-web.html">Using XAuth to simplify the social web</a> - Google Code Blog</li>
+ <li><a href="http://groups.google.com/group/xauth">XAuth Discussion Group</a> - Get Involved</li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <script type="text/javascript">
+ var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
+ document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
+ </script>
+ <script type="text/javascript">
+ try {
+ var pageTracker = _gat._getTracker("UA-3931792-8");
+ pageTracker._setDomainName('.xauth.org');
+ pageTracker._trackPageview();
+ } catch(err) {}</script>
+</body>
+</html>
2  release/server.html
@@ -0,0 +1,2 @@
+<!doctype html><script type="text/javascript">
+(function(){var g=window;if(g.top==g){return}if(!g.postMessage||!g.localStorage||!g.JSON){return}var d=g.localStorage;var a=null;var f=document.cookie.match(/(?:^|;)\s*session=(\d+)(?:;|$)/);if(f&&f.length){a=f[1]}if(!a){a=new Date().getTime();document.cookie=("session="+a+"; ")}var b={"xauth::extend":function(l,m){if(!m.token){i(m,"Invalid",origin);return null}m.token=String(m.token).substr(0,1024);m.expire=Number(m.expire);var k=new Date(m.expire);if(k<new Date()){i(m,"Invalid Expiration",origin);return null}if(!m.extend||!m.extend.length){i(m,"No Extend List Specified",origin);return null}var j={token:m.token,expire:m.expire,extend:m.extend};if(m.session===true){j.session=a}d.setItem(l,JSON.stringify(j));return{cmd:m.cmd,id:m.id}},"xauth::retrieve":function(t,l){if(!l.retrieve||!l.retrieve.length){i(l,"No Retrieve List Requested",origin);return null}var q={};var k=false;for(var p=0;p<l.retrieve.length;p++){var s=l.retrieve[p];var n=d.getItem(s);var r=n?JSON.parse(n):null;if(r&&!r.block){var u=(t==s);if(!u){for(var o=0;o<r.extend.length;o++){if(r.extend[o]=="*"||r.extend[o]==t){u=true;break}}}if(u){var m=new Date(r.expire);if(m<new Date()){d.removeItem(s);continue}if(r.session&&r.session!=a){d.removeItem(s);continue}q[s]={token:r.token,expire:r.expire}}}}return{cmd:l.cmd,id:l.id,tokens:q}},"xauth::expire":function(j,k){d.removeItem(j);return{cmd:k.cmd,id:k.id}}};function i(l,k,j){if(!l||(typeof l.id!="number")){return}if(g.console&&g.console.log){g.console.log(l.cmd+" Error: "+k)}}function c(j,k){if(!j||(typeof j.id!="number")){return}g.parent.postMessage(JSON.stringify(j),k)}function e(){return(d.getItem("disabled.xauth.org")=="1")}function h(j){var k=j.origin.split("://")[1].split(":")[0],l=JSON.parse(j.data);if(!l||typeof l!="object"||!l.cmd||l.id==undefined||e()){return}if(b[l.cmd]){c(b[l.cmd](k,l),j.origin)}}if(g.addEventListener){g.addEventListener("message",h,false)}else{if(g.attachEvent){g.attachEvent("onmessage",h)}}g.parent.postMessage(JSON.stringify({cmd:"xauth::ready"}),"*")})();</script>
453 release/spec/index.html
@@ -0,0 +1,453 @@
+<!--
+ Copyright 2010 Meebo Inc.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<!doctype html>
+<html>
+<head>
+<title>XAuth Specifications</title>
+<script type="text/javascript" src="http://xauth.org/xauth.js"></script>
+<script type="text/javascript">
+var libraryURL = 'http://xauth.org/xauth.js'
+
+function onbodyload() {
+ var copyme = document.getElementById('code_copy');
+ copyme.value = '<scr' + 'ipt type="text/javascript" src="' + libraryURL + '"></scr' + 'ipt>';
+
+ generateToken();
+ generateExpire();
+ generateRetrieve();
+}
+
+function generateToken() {
+ var token = (Math.floor(Math.random()*10000000000)).toString(16)
+ + (Math.floor(Math.random()*10000000000)).toString(16)
+ + (Math.floor(Math.random()*10000000000)).toString(16);
+ document.getElementById('token').value = token;
+ generateExtendCode();
+}
+
+function generateExpire(secondsToExpire) {
+ var seconds = secondsToExpire || 24*60*60; // Default to 24 hours
+ var expire = (new Date().getTime() + seconds*1000);
+ document.getElementById('expire').value = expire;
+ generateExtendCode();
+}
+
+function generateRetrieve() {
+ document.getElementById('retrieve').value = 'www.meebo.com, www.youface.com, ' + document.domain;
+ generateRetrieveCode();
+}
+
+function runCode(methodName) {
+ var code = document.getElementById('code_' + methodName).value;
+ try {
+ eval(code);
+ } catch(e) {
+ document.getElementById('results_' + methodName).innerHTML += (e.toString() + "<br/>");
+ }
+}
+
+function extendCallback(responseObj) {
+ var cmd = responseObj.cmd;
+ document.getElementById('results_extend').innerHTML += ('XAuth' + cmd.substr(5) + " succeeded! Response JSON:<br/><pre>" + JSON.stringify(responseObj, null, ' ') + "</pre>");
+}
+
+function expireCallback(responseObj) {
+ var cmd = responseObj.cmd;
+ document.getElementById('results_expire').innerHTML += ('XAuth' + cmd.substr(5) + " succeeded! Response JSON:<br/><pre>" + JSON.stringify(responseObj, null, ' ') + "</pre>");
+}
+
+function retrieveCallback(responseObj) {
+ var results = responseObj.tokens;
+ var cmd = responseObj.cmd.substr(5);
+ var tokens = '';
+ for(var id in results) {
+ tokens += '<tr><td>' + id + '</td><td>' + results[id]['token'] + '</td></tr>';
+ }
+ if(tokens == '') {
+ tokens = 'No Tokens Available to you right now';
+ } else {
+ tokens = '<table><tr><th>Domain</th><th>Token</th></tr>' + tokens + '</table>'
+ }
+
+ tokens += "<br>Response JSON:<br/><pre>" + JSON.stringify(responseObj, null, ' ') + "</pre>";
+ document.getElementById('results_retrieve').innerHTML = tokens;
+}
+
+
+function generateExtendCode() {
+ var token = document.getElementById('token').value;
+ var expire = document.getElementById('expire').value;
+ var session = document.getElementById('session').checked;
+ var extend = document.getElementById('extend').value;
+ var extendList = '["' + extend.replace(/\s+/g,'').split(',').join('", "') + '"]';
+ var code = document.getElementById('code_extend');
+ code.value = 'XAuth.extend({\n token: "' + token + '",\n'
+ + ' expire: ' + expire + ',\n'
+ + (session?' session: true,\n':'')
+ + ' extend: ' + extendList + ',\n'
+ + ' callback: extendCallback\n'
+ + '});';
+}
+
+function generateRetrieveCode() {
+ var retrieve = document.getElementById('retrieve').value;
+ var retrieveList = '["' + retrieve.replace(/\s+/g,'').split(',').join('", "') + '"]';
+ var code = document.getElementById('code_retrieve');
+ code.value = 'XAuth.retrieve({\n retrieve: ' + retrieveList + ',\n'
+ + ' callback: retrieveCallback\n'
+ + '});';
+}
+
+</script>
+
+<style>
+body {
+ padding: 0 30px;
+ margin: 0;
+ font-family: "Helvetica Neue", Helvetica, Arial;
+}
+
+.body {
+ width: 1000px;
+ margin: auto;
+}
+
+button {
+ font-size: 12px;
+}
+
+.navigation {
+ margin-right: 20px;
+ float: left;
+ line-height: 1.5em;
+ padding: 0 20px 20px;
+ background: #EEE;
+}
+
+.navigation ul {
+ padding: 0;
+ margin: 0;
+}
+
+.navigation li {
+ display: block;
+}
+
+.content {
+ float: left;
+ width: 800px;
+}
+
+.rightheader {
+ display: block;
+ float: right;
+ text-align: right;
+}
+
+#domain {
+ color: #AAA;
+}
+
+.copyme {
+ background: #EEE;
+ padding: 10px;
+ font-size: 1.3em;
+ overflow: auto;
+}
+
+#copycode {
+ width: 50%;
+ border: 0;
+ display:block;
+ font-size: 1.3em;
+ width: 380px;
+ float: right;
+}
+
+#tokens table {
+ margin: 10px;
+ color: #AAA;
+}
+
+input {
+ border: 1px solid #AAA;
+ font-size: 13px;
+}
+
+input[type=text] {
+ width: 300px;
+}
+
+.method {
+ background: #F5F5F5;
+ overflow: auto;
+ margin-bottom: 20px;
+}
+
+.method .name {
+ background: #EEE;
+ padding: 10px;
+ font-size: 1.3em;
+}
+
+.method .params {
+ padding: 10px;
+ line-height: 1.5em;
+}
+
+.method .sandbox {
+ float: right;
+ padding: 20px;
+ background: #DDD;
+ width: 380px;
+ font-family: Courier;
+ font-size: 13px;
+ margin-left: 10px;
+}
+
+.method .sandbox textarea.code {
+ background: #DDD;
+ font-family: Courier;
+ border: 1px solid #DDD;
+ width: 100%;
+ font-size: 13px;
+}
+
+#code_extend {
+ height: 130px;
+}
+
+#code_expire {
+ height: 30px;
+}
+
+#code_retrieve {
+ height: 100px;
+}
+
+#code_copy {
+ height: 35px;
+}
+
+.method .sandbox textarea.code {
+ border-color: #000;
+ background: #EEE;
+}
+
+.method .sandbox .execute {
+ padding: 10px 0;
+}
+
+.method p {
+ line-height: 1.5em;
+}
+
+table.playground td {
+ padding: 4px 4px 4px 0;
+ vertical-align: top;
+ line-height: 1.5em;
+}
+
+table.spec td {
+ padding: 4px 4px 4px 0;
+ vertical-align: top;
+ line-height: 1.5em;
+ font-size: 12px;
+}
+
+table.spec th {
+ font-size:14px;
+}
+
+table.definitions th,
+table.definitions td {
+ vertical-align: top;
+ padding: 10px;
+}
+
+</style>
+
+</head>
+
+<body onload="onbodyload()">
+ <div class="body">
+ <div class="navigation">
+ <h2>XAuth</h2>
+ <ul>
+ <li><a href="/">Manage</a></li>
+ <li><a href="/info">Information</a></li>
+ <li><a href="/spec">Specification</a></li>
+ </ul>
+ </div>
+ <div class="content">
+ <div class="rightheader">
+ contact: <a href="mailto:xauth@meebo-inc.com&subject=xauth.org">xauth@meebo-inc.com</a><br>
+ <a href="http://groups.google.com/group/xauth">XAuth Discussion Group</a>
+ </div>
+ <h2>XAuth Spec</h2>
+ <p>XAuth is an open platform for extending authenticated user services across the web.
+
+ <div class="method definitions">
+ <div class="name">Definitions</div>
+ <div class="params">
+ <table class="definitions">
+ <tbody>
+ <tr><th>Extender</th>
+ <td>the network service that wishes to enable their users to extend authenticated access to a limited set of services across other domains. The extender publishes the XAuth Token.</td></tr>
+ <tr><th>Retriever</th>
+ <td>the service that wants to access an extender's XAuth Token.</td></tr>
+ </tbody>
+ </table>
+ </div>
+ </div>
+ <div class="method">
+ <div class="name">Requirements</div>
+ <div class="params">
+ <ul>
+ <li>Extenders create a public token for use with XAuth <b>(XAuth Token)</b>
+ <li>XAuth only works in modern browsers that support specific HTML5 methods: window.postMessage and localStorage. (IE8+, Safari4+, Chrome3+, FF3+)
+ <li>Communication with XAuth domain in the browser will rely on window.postMessage to an iframe on XAuth.org
+ <li>Storage of sessions on the XAuth domain in the browser relies on local storage.
+ <li>User browser preferences restricting third party cookies may interfere and return an error code.
+ </ul>
+ </div>
+ </div>
+ <div class="method">
+ <div class="sandbox">
+ <b>Place this code in the head of your web page:</b><br>
+ <textarea class="code" id="code_copy">XAuth.extend();</textarea>
+ </div>
+ <div class="name">XAuth Embed Code</div>
+ <div class="params">
+ <p>XAuth is a very lightweight JavaScript library that an extender and a retriever will use. It exposes three JavaScript functions: extend, expire, and retrieve.</p>
+ </div>
+ </div>
+ <div class="method">
+ <div class="sandbox">
+ <b>Sample Code Generator</b>:<br><table class="playground">
+ <tbody>
+ <tr>
+ <td>token:</td>
+ <td><input type="text" id="token" onkeyup="generateExtendCode()">
+ <br><button onclick="generateToken()">Generate Random token</button></td>
+ </tr>
+ <tr>
+ <td>expire:</td>
+ <td><input type="text" id="expire" onkeyup="generateExtendCode()">
+ <br><button onclick="generateExpire()">24 Hours From Now</button><button onclick="generateExpire(10)">10 Seconds From Now</button></td>
+ </tr>
+ <tr>
+ <td>session:</td>
+ <td><input type="checkbox" id="session" name="session" onkeyup="generateExtendCode()" onclick="generateExtendCode()"><label for="session"> token expires with browser session</label></td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>extend:</td>
+ <td><input type="text" id="extend" value="www.meebo.com, www.youface.com, *" onkeyup="generateExtendCode()"><br>Array of domain strings to allow read access</td>
+ </tr>
+ </tbody>
+ </table>
+ Sample Code:<br>
+ <textarea class="code" id="code_extend">XAuth.extend();</textarea>
+ <div class="execute"><button onclick="runCode('extend')">Run Sample Code</button></div>
+ Results:
+ <div class="results" id="results_extend"></div>
+ </div>
+ <div class="name">XAuth.extend()</div>
+ <div class="params">
+ <p>Called by an auth extender. This method creates an iframe to xauth.org and then it uses window.postMessage to send this data to the iframe where it will be written to local storage.</p>
+ <table class="spec">
+ <tbody>
+ <th>Parameter</th><th>Behavior</th>
+ <tr><td height="44"><i>token</i></td>
+ <td>(required) this is the XAuth token, created specifically for use with XAuth and used by an auth retriever to request additional services from the extender. <br>This token will be stored with the canonical domain as the key.</td></tr>
+ <tr><td><i>expire</i></td>
+ <td>(required) specifies the date/time when this token should expire as a JavaScript UTC timestamp Number. <p><strong>This number is in milliseconds.</strong></td></tr>
+ <tr><td><i>session</i></td>
+ <td>(optional) specifies whether the token should also be expired after the browser session has ended. Value is specified as a JavaScript Boolean.</td></tr>
+ <tr><td><i>extend</i></td>
+ <td>(required) specifies the list of domains that may retrieve this token. XAuth will cache the domains specified in this file in local storage. Value is specified as a JavaScript Array of Strings. <p>The key will be the canonical domain
+ <p><strong>You may use a wildcard "*" domain in the Array to allow all domains to retrieve the token.</strong></td></tr>
+ <tr><td><i>callback</i></td>
+ <td>(optional) reference to a callback function</td></tr></tr>
+ </tbody>
+ </table>
+ </div>
+ </div>
+
+ <!-- Expire -->
+ <div class="method">
+ <div class="sandbox">
+ Sample Code:<br>
+ <textarea class="code" id="code_expire">XAuth.expire({callback: expireCallback});</textarea>
+ <div class="execute"><button onclick="runCode('expire')">Run Sample Code</button></div>
+ Results:
+ <div class="results" id="results_expire"></div>
+ </div>
+ <div class="name">XAuth.expire()</div>
+ <div class="params">
+ <p>Called by an auth extender that wishes to expire a user's xauth token. Call this when the user explicitly signs out from the auth extender. This will expire the token in local storage.</p>
+ <p></p>
+
+ </div>
+ </div>
+
+ <!-- Retrieve -->
+ <div class="method">
+ <div class="sandbox">
+ <b>Sample Code Generator</b>:<br>
+ <table class="playground">
+ <tbody>
+ <tr>
+ <td>retrieve:</td>
+ <td><input type="text" id="retrieve" value="www.meebo.com, www.youface.com" onkeyup="generateRetrieveCode()"><br>Array of domain strings to query</td>
+ </tr>
+ </tbody>
+ </table>
+ Sample Code:<br>
+ <textarea class="code" id="code_retrieve">XAuth.retrieve();</textarea>
+ <div class="execute"><button onclick="runCode('retrieve')">Run Sample Code</button></div>
+ Results:
+ <div class="results" id="results_retrieve"></div>
+ </div>
+ <div class="name">XAuth.retrieve()</div>
+ <div class="params">
+ <p>Called by an auth extender that wishes to retrieve XAuth tokens.</p>
+ <table class="spec">
+ <tbody>
+ <th>Parameter</th><th>Behavior</th>
+ <tr><td height="44"><i>retrieve</i></td>
+ <td>(required) specifies a list of domains for which the retriever is interested in. If any of the domains have extended to your domain, their token (if currently available and not expired) will be included in the response passed to the callback.
+ <p><strong>You may NOT use a wildcard "*" domain.</strong></td></tr>
+ <tr><td><i>callback</i></td>
+ <td>(required) specifies a callback function to receive the XAuth tokens. XAuth will call this function passing in a response object with 'tokens' specifying the available tokens and their expiration timestamps keyed by the canonical domain:
+ <br><i>{tokens: {domain: {token: token, expire: expire}, ...} }</i></td></tr>
+ </tbody>
+ </table>
+ </div>
+ </div>
+ </div>
+ </div>
+ <script type="text/javascript">
+ var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
+ document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
+ </script>
+ <script type="text/javascript">
+ try {
+ var pageTracker = _gat._getTracker("UA-3931792-8");
+ pageTracker._trackPageview();
+ } catch(err) {}</script></body>
+</html>
1  release/xauth.js
@@ -0,0 +1 @@
+var XAuth=(function(){var j=window;var q=!(j.postMessage&&j.localStorage&&j.JSON);var n="xauth.org";var e="http://"+n+"/server.html";var g=null;var a=null;var p={};var d=0;var m=[];function o(s){var u=s.origin.split("://")[1].split(":")[0];if(u!=n){return}var t=JSON.parse(s.data);if(!t){return}if(t.cmd=="xauth::ready"){a=g.contentWindow;setTimeout(f,0);return}var r=p[t.id];if(r){if(r.callback){r.callback(t)}delete p[t.id]}}function i(){if(g||a){return}var s=j.document;g=s.createElement("iframe");var r=g.style;r.position="absolute";r.left=r.top="-999px";if(j.addEventListener){j.addEventListener("message",o,false)}else{if(j.attachEvent){j.attachEvent("onmessage",o)}}s.body.appendChild(g);g.src=e}function f(){for(var r=0;r<m.length;r++){c(p[m.shift()])}}function c(r){a.postMessage(JSON.stringify(r),e)}function h(r){if(q){return}r.id=d;p[d++]=r;if(!g||!a){m.push(r.id);i()}else{c(r)}}function l(r){if(!r){r={}}var s={cmd:"xauth::retrieve",retrieve:r.retrieve||[],callback:r.callback||null};h(s)}function k(r){if(!r){r={}}var s={cmd:"xauth::extend",token:r.token||"",expire:r.expire||0,extend:r.extend||[],session:r.session||false,callback:r.callback||null};h(s)}function b(r){if(!r){r={}}var s={cmd:"xauth::expire",callback:r.callback||null};h(s)}return{extend:k,retrieve:l,expire:b,disabled:q}})();
314 src/index.html
@@ -0,0 +1,314 @@
+<!--
+ Copyright 2010 Meebo Inc.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<!doctype html>
+<html>
+<head>
+<title>XAuth</title>
+<script type="text/javascript">
+if(document.domain == 'www.xauth.org') {
+ document.location.replace(document.location.href.replace('www.xauth.org', 'xauth.org'));
+}
+/**
+ XAuth Token Manager
+
+ 2010-04-14
+ First version of xauth manager code
+ -Jian Shen, Meebo
+**/
+
+function $(id) {
+ return document.getElementById(id);
+}
+
+var XAuthManager = (function() {
+ var supported = !!(window.postMessage && window.localStorage && window.JSON);
+ var disabled = ('1' == localStorage.getItem('disabled.xauth.org'));
+
+ function setDisabled(disable) {
+ disabled = disable;
+ localStorage.setItem('disabled.xauth.org',disabled?'1':'0');
+ }
+
+ function getToken(key) {
+ if(key == 'disabled.xauth.org') {
+ return null;
+ }
+
+ var tokenStr = localStorage.getItem(key);
+ if(!tokenStr) {
+ return null;
+ }
+
+ var store = JSON.parse(tokenStr);
+ return store;
+ }
+
+ function saveToken(key, store) {
+ localStorage.setItem(key, JSON.stringify(store));
+ }
+
+ function updateStatus() {
+ var status = 'Enabled';
+ var disableButton = $('disable-button');
+ var showTokens = true;
+ if(!supported) {
+ status = '<span class="warning">Unsupported</span>';
+ disableButton.setAttribute('disabled','true');
+ showTokens = false;
+ } else if(disabled) {
+ status = '<span class="warning">Disabled</span>';
+ disableButton.innerHTML = 'Enable XAuth';
+ disableButton.removeAttribute('disabled');
+ showTokens = false;
+ } else {
+ disableButton.innerHTML = 'Disable XAuth';
+ disableButton.removeAttribute('disabled');
+ }
+ $('status').innerHTML = status;
+ $('tokens').style.display = showTokens?'block':'none';
+ }
+
+ function escapeHTML(str) {
+ if (!str || !str.length) { return str; }
+
+ var entities = {
+ '&': '&amp;',
+ '"': '&quot;',
+ '<': '&lt;',
+ '>': '&gt;'
+ };
+
+ var re = /[&"<>]/g;
+ return str.replace(re, function (substr) { return entities[substr]; });
+ }
+
+ function getStatusHTML(id, store) {
+ var status = '';
+ if(store.token) {
+ status = '<span class="view" onclick="XAuthManager.showToken(\'' + id + '\')">Active Token</span>'
+ + '<div class="token-view" id="token-' + id + '"><textarea readonly="readonly">' + escapeHTML(store.token) + '</textarea>Expiration: ' + (store.session?'End of browser session':escapeHTML(store.expire)) + '</div>';
+ } else {
+ status = 'No Token'
+ }
+ if(store.block) {
+ status = '<span class="blocked">Blocked</span>';
+ }
+ return status;
+ }
+
+
+ function getTokenRowHTML(id) {
+ var store = getToken(id);
+ if(!store) { return null; }
+
+ return ('<td>' + id + '</td><td id="status-' + id + '">' + getStatusHTML(id, store) + '</td><td>'
+ + '<button onclick="XAuthManager.deleteToken(\'' + id + '\')">Delete</button>&nbsp;'
+ + '<button id="blockbutton-' + id + '" onclick="XAuthManager.toggleBlock(\'' + id + '\')">' + (store.block?'Unblock':'Block') + '</button>'
+ + '</td>');
+ }
+
+ function toggleXAuth() {
+ setDisabled(!disabled);
+ updateStatus();
+ }
+
+ function toggleBlock(id) {
+ var store = getToken(id);
+ if(!store) { return; }
+ if(store.block) {
+ delete store.block;
+ } else {
+ store.block = 1;
+ }
+ saveToken(id, store);
+ $('blockbutton-' + id).innerHTML = (store.block?'Unblock':'Block');
+
+ $('status-' + id).innerHTML = getStatusHTML(id, store);
+ }
+
+ function deleteToken(id) {
+ localStorage.removeItem(id);
+ var row = $('row-' + id);
+ row.parentNode.removeChild(row);
+ }
+
+ function showToken(id) {
+ $('token-' + id).style.display = 'block';
+ }
+
+ function listTokens() {
+ var tableStr = '<table class="tokens"><tbody>';
+ tableStr += '<tr><th>Extender Domain</th><th class="status-column">Status</th><th class="action-column">Actions</th>';
+
+ for(var i=0; i<localStorage.length; i++) {
+ var key = localStorage.key(i);
+ var html = getTokenRowHTML(key);
+ if(html) {
+ tableStr += ('<tr id="row-' + key + '">' + html + '</tr>');
+ }
+ }
+
+ tableStr += '</tbody></table>';
+
+ document.getElementById('tokens').innerHTML = tableStr;
+ }
+
+ function init() {
+ updateStatus();
+ listTokens();
+ }
+
+ return {
+ init: init,
+ toggleXAuth: toggleXAuth,
+ toggleBlock: toggleBlock,
+ deleteToken: deleteToken,
+ showToken: showToken
+ }
+
+})();
+
+</script>
+<style>
+body {
+ padding: 0 30px;
+ margin: 0;
+ font-family: "Helvetica Neue", Helvetica, Arial;
+}
+
+.body {
+ width: 1000px;
+ margin: auto;
+}
+
+button {
+ font-size: 12px;
+}
+
+.navigation {
+ margin-right: 20px;
+ float: left;
+ line-height: 1.5em;
+ padding: 0 20px 20px;
+ background: #EEE;
+}
+
+.navigation ul {
+ padding: 0;
+ margin: 0;
+}
+
+.navigation li {
+ display: block;
+}
+
+.content {
+ float: left;
+ width: 800px;
+}
+
+.panel {
+ margin: 40px 0;
+}
+
+.view:hover {
+ text-decoration: underline;
+ color: #009;
+ cursor: pointer;
+}
+
+.blocked {
+ color: #999;
+}
+
+.warning {
+ color: #FFF;
+ background: #A00;
+ padding: 4px;
+ border-radius: 0.3em;
+}
+
+.token-view {
+ display: none;
+}
+
+.token-view textarea {
+ width: 100%;
+ height: 4em;
+}
+
+table {
+ border: 1px solid #CCC;
+ width: 100%;
+}
+
+table td, table th {
+ vertical-align: top;
+ line-height: 1.5em;
+ padding: 10px;
+ background: #EEE;
+ text-align: center;
+}
+
+th.status-column {
+ width: 300px;
+}
+
+th.action-column {
+ width: 150px;
+}
+
+.rightheader {
+ display: block;
+ float: right;
+ text-align: right;
+}
+</style>
+</head>
+<body onload="XAuthManager.init()">
+ <div class="body">
+ <div class="navigation">
+ <h2>XAuth</h2>
+ <ul>
+ <li><a href="/">Manage</a></li>
+ <li><a href="/info">Information</a></li>
+ <li><a href="/spec">Specification</a></li>
+ </ul>
+ </div>
+ <div class="content">
+ <h2>Manage Browser Settings</h2>
+ <p>See and manage XAuth Extenders for this browser.</p>
+ <div id="status-panel" class="panel">
+ <table><tbody>
+ <tr><th colspan="3">XAuth is <span id="status">Enabled</span> in this browser</th>
+ <th class='action-column'><button id="disable-button" onclick="XAuthManager.toggleXAuth()">Disable XAuth</button></th>
+ </tr>
+ </tbody></table>
+ </div>
+ <div id="tokens" class="panel"></div>
+ </div>
+ </div>
+ <script type="text/javascript">
+ var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
+ document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
+ </script>
+ <script type="text/javascript">
+ try {
+ var pageTracker = _gat._getTracker("UA-3931792-8");
+ pageTracker._trackPageview();
+ } catch(err) {}</script>
+</body>
+</html>
206 src/info/index.html
@@ -0,0 +1,206 @@
+<!--
+ Copyright 2010 Meebo Inc.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<!doctype html>
+<html>
+<head>
+<title>XAuth Info</title>
+<style>
+body {
+ padding: 0 30px;
+ margin: 0;
+ font-family: "Helvetica Neue", Helvetica, Arial;
+}
+
+.body {
+ width: 1000px;
+ margin: auto;
+}
+
+.navigation {
+ margin-right: 20px;
+ float: left;
+ line-height: 1.5em;
+ padding: 0 20px 20px;
+ background: #EEE;
+}
+
+.navigation ul {
+ padding: 0;
+ margin: 0;
+}
+
+.navigation li {
+ display: block;
+}
+
+.content {
+ float: left;
+ width: 800px;
+}
+
+ul.blogs {
+ line-height: 1.4em;
+}
+
+.rightheader {
+ display: block;
+ float: right;
+ text-align: right;
+}
+
+.method {
+ background: #F5F5F5;
+ overflow: auto;
+ margin-bottom: 20px;
+}
+
+.method .name {
+ background: #EEE;
+ padding: 10px;
+ font-size: 1.3em;
+}
+
+.method .params {
+ padding: 10px;
+}
+
+.method .sandbox {
+ float: right;
+ padding: 20px;
+ background: #DDD;
+ width: 400px;
+ font-family: Courier;
+ margin-left: 10px;
+}
+
+.method .sandbox .code {
+ background: #DDD;
+ font-family: Courier;
+ border: 1px solid #DDD;
+ width: 100%;
+}
+
+#code_extend {
+ height: 150px;
+}
+
+#code_expire {
+ height: 50px;
+}
+
+#code_retrieve {
+ height: 120px;
+}
+
+#code_copy {
+ height: 52px;
+}
+
+.method .sandbox .code:hover {
+ border-color: #000;
+ background: #EEE;
+}
+
+.method .sandbox .execute {
+ padding: 20px 0;
+}
+
+table.playground td {
+ padding: 4px 4px 4px 0;
+ vertical-align: top;
+ line-height: 1.5em;
+}
+</style>
+</head>
+
+<body>
+ <div class="body">
+ <div class="navigation">
+ <h2>XAuth</h2>
+ <ul>
+ <li><a href="/">Manage</a></li>
+ <li><a href="/info">Information</a></li>
+ <li><a href="/spec">Specification</a></li>
+ </ul>
+ </div>
+ <div class="content">
+ <div class="rightheader">
+ contact: <a href="mailto:xauth@meebo-inc.com&subject=xauth.org">xauth@meebo-inc.com</a><br>
+ <a href="http://groups.google.com/group/xauth">XAuth Discussion Group</a>
+ </div>
+ <h2>Extended Authentication (XAuth)</h2>
+
+ <div class="method">
+ <div class="name">Quick Introductions</div>
+ <div class="params">
+ <ul class="blogs">
+ <li><a target="_blank" href="http://blog.meebo.com/?p=2391">Introducing XAuth</a> - Meebo Dev Blog</li>
+ <li><a target="_blank" href="http://developer.yahoo.net/blog/archives/2010/04/xauth_oauth_and_yahoo_openid.html">XAuth, OAuth, and Yahoo! OpenID</a> - Yahoo! Developer Network</li>
+ <li><a target="_blank" href="http://googlesocialweb.blogspot.com/2010/04/simplifying-social-web-with-xauth.html">Simplifying the social web with XAuth</a> - Google Social Web</li>
+ </ul>
+ </div>
+ </div>
+ <div class="method">
+ <div class="name">What is XAuth?</div>
+ <div class="params">
+ <p>XAuth is an open platform for extending authenticated user services across the web.
+
+ <p>Participating services generate a browser token for each of their users. Publishers can then recognize when site visitors are logged in to those online services and present them with meaningful, relevant options.
+ <p>Users can choose to authenticate directly from the publisher site and use the service to share, interact with friends, or participate in the site's community. The XAuth Token can be anything, so services have the flexibility to define whatever level of access they choose.
+
+ </div>
+ </div>
+ <div class="method">
+ <div class="name">Benefits</div>
+ <div class="params">
+ <p>For site publishers, the multiple HTTP requests necessary to recognize every potential online service are slow and inefficient. XAuth provides a central domain (http://xauth.org) with a lightweight JavaScript library that can be accessed via a single HTTP request.
+
+ <p>Users are often presented with many social services when browsing a site. They likely only are interested in one or two. XAuth allows the user experience to be immediately relevant, so that they can easily access the services that are useful to them.
+
+ <p>Service providers participating in XAuth can reach their existing userbase anywhere on the web without being buried in the deluge of other social services that may be available and competing for space on the publisher site.
+
+ <p>The service providers have complete control over the features they enable for the publisher site. The XAuth Token could be a single bit denoting the existence of an authenticated user, or it could be a session ID that passes public profile info via API calls from the publisher.
+
+ <p>Users can decide which services pass data to sites through XAuth. To view and modify any currently enabled browser XAuth tokens, go to <a href="/">xauth.org/</a>
+
+ </div>
+ </div>
+
+ <div class="method">
+ <div class="name">Developing on XAuth</div>
+ <div class="params">
+ <p>Developers can view the XAuth specifications and explore XAuth calls at <a href="/spec/">xauth.org/spec/</a> </p>
+ <p>More Great Resources:</p>
+ <ul class="blogs">
+ <li><a target="_blank" href="http://googlecode.blogspot.com/2010/04/using-xauth-to-simplify-social-web.html">Using XAuth to simplify the social web</a> - Google Code Blog</li>
+ <li><a href="http://groups.google.com/group/xauth">XAuth Discussion Group</a> - Get Involved</li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <script type="text/javascript">
+ var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
+ document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
+ </script>
+ <script type="text/javascript">
+ try {
+ var pageTracker = _gat._getTracker("UA-3931792-8");
+ pageTracker._setDomainName('.xauth.org');
+ pageTracker._trackPageview();
+ } catch(err) {}</script>
+</body>
+</html>
17 src/server.html
@@ -0,0 +1,17 @@
+<!--
+ Copyright 2010 Meebo Inc.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<!doctype html>
+<script type="text/javascript" src="server.js"></script>
266 src/server.js
@@ -0,0 +1,266 @@
+/*
+ Copyright 2010 Meebo Inc.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+/**
+ History
+
+ 2010-04-27
+ Overcommenting
+ -jianshen
+
+ 2010-04-16
+ Added in checks for disabled and blocked tokens
+ -jianshen
+
+ 2010-03-26
+ First version of xauth server code
+ -Jian Shen, Meebo
+**/
+
+;(function() {
+ // Reference shortcut so minifier can save on characters
+ var win = window;
+
+ // We're the top window, don't do anything
+ if(win.top == win) {
+ return;
+ }
+
+ // unsupported browser
+ if(!win.postMessage || !win.localStorage || !win.JSON) {
+ return;
+ }
+
+ // Reference shortcut so minifier can save on characters
+ var storage = win.localStorage;
+
+ // To allow for session based XAuth tokens (tokens that expire immediately
+ // after the browser session ends), we piggy back off of traditional
+ // browser cookies. This cookie is set the first time XAuth is loaded
+ // and any session based XAuth tokens will be marked with this unique
+ // key. The next time the browser is started, a new unique key is created
+ // thereby invalidating any previous session based XAuth tokens
+ var currentSession = null;
+ var match = document.cookie.match(/(?:^|;)\s*session=(\d+)(?:;|$)/);
+ if (match && match.length) {
+ currentSession = match[1];
+ }
+ if(!currentSession) {
+ currentSession = new Date().getTime();
+ document.cookie = ('session=' + currentSession + "; ");
+ }
+
+ // Set up the API
+ var XAuthApi = {
+ /**
+ Request object will look like:
+ {
+ cmd:'xauth::extend',
+ id:1,
+ token:YOUR_TOKEN,
+ extend: [ Array of domain strings you allow ],
+ expire: JS date timestamp number,
+ session: true or false boolean indicating if this token is browser session based
+ }
+ **/
+
+ 'xauth::extend': function(originHostname, requestObj) {
+
+ // Validate and clean token
+ if(!requestObj.token) {
+ logError(requestObj, 'Invalid', origin);
+ return null;
+ }
+ requestObj.token = String(requestObj.token).substr(0,1024); // We cast to String for tokens that are 1's or 0's
+
+ // Validate date
+ requestObj.expire = Number(requestObj.expire); // Cast to numeric timestamp
+ var dateCheck = new Date(requestObj.expire);
+ if(dateCheck < new Date()) { // If you pass garbage into the date, this will be false
+ logError(requestObj, 'Invalid Expiration', origin);
+ return null;
+ }
+
+ // Validate extend list
+ if(!requestObj.extend || !requestObj.extend.length) {
+ logError(requestObj, 'No Extend List Specified', origin);
+ return null;
+ }
+
+ // Deposit box contents
+ var store = {
+ token: requestObj.token,
+ expire: requestObj.expire,
+ extend: requestObj.extend
+ }
+
+ // Check if this is requesting to be a session based store
+ if(requestObj.session === true) {
+ store.session = currentSession; // We check this on retrieve
+ }
+
+ // Save
+ storage.setItem(originHostname, JSON.stringify(store));
+
+ // Send Response Object
+ return {
+ cmd: requestObj.cmd,
+ id: requestObj.id
+ };
+ },
+
+ /**
+ Request object will look like:
+ {
+ cmd:'xauth::retrieve',
+ id:1,
+ retrieve: [ Array of domains you are interested in ]
+ }
+ **/
+ 'xauth::retrieve': function(originHostname, requestObj) {
+ if(!requestObj.retrieve || !requestObj.retrieve.length) {
+ logError(requestObj, 'No Retrieve List Requested', origin);
+ return null;
+ }
+
+ var results = {};
+ var foundResults = false;
+
+ // Iterate through the list of requested domains
+ for(var i=0; i<requestObj.retrieve.length; i++) {
+ var requestedHost = requestObj.retrieve[i];
+ var loaded = storage.getItem(requestedHost);
+ var store = loaded?JSON.parse(loaded):null;
+ // Check if it exists in storage and if it's not blocked by the user
+ if(store && !store.block) {
+ // Check if requesting host is the same as the origin domain
+ var allowed = (originHostname == requestedHost);
+
+ // Otherwise check if requesting host is in extend list
+ if(!allowed) {
+ for(var j=0; j<store.extend.length; j++) {
+ if(store.extend[j] == '*' || store.extend[j] == originHostname) {
+ allowed = true;
+ break;
+ }
+ }
+ }
+ if(allowed) {
+ // Check if token is expired
+ var dateCheck = new Date(store.expire);
+ if(dateCheck < new Date()) {
+ storage.removeItem(requestedHost); // Delete expired tokens
+ continue;
+ }
+
+ // Check if token is session based and whether or not it was set in
+ // the current browser session
+ if(store.session && store.session != currentSession) {
+ storage.removeItem(requestedHost);
+ continue;
+ }
+
+ // Token is still valid, add it to the results
+ results[requestedHost] = {'token':store.token, 'expire':store.expire};
+ }
+ }
+ }
+
+ return {
+ cmd: requestObj.cmd,
+ id: requestObj.id,
+ tokens: results
+ };
+ },
+
+ 'xauth::expire': function(originHostname, requestObj) {
+ storage.removeItem(originHostname);
+
+ return {
+ cmd: requestObj.cmd,
+ id: requestObj.id
+ };
+ }
+ }
+
+ /**
+ help with debugging issues
+ We can eventually toggle this using a debug.xauth.org store
+ **/
+ function logError(requestObj, message, origin) {
+ if(!requestObj || (typeof requestObj.id != 'number') ) {
+ return;
+ }
+ if(win.console && win.console.log) {
+ win.console.log(requestObj.cmd + ' Error: ' + message);
+ }
+ }
+
+ // Make sure response message has an id and send it on to parent window
+ // origin is the URI of the window we're postMessaging to
+ function sendResponse(responseObj, origin) {
+ if(!responseObj || (typeof responseObj.id != 'number') ) {
+ return;
+ }
+ win.parent.postMessage(JSON.stringify(responseObj), origin);
+ }
+
+ // Dynamically called since the user can open up xauth.org and disable
+ // the entire thing while another browser tab has an xauth.org iframe open
+ function checkDisabled() {
+ return (storage.getItem('disabled.xauth.org') == '1');
+ }
+
+ // Listener for window message events, receives messages from parent window
+ function onMessage(event) {
+ // event.origin will always be of the format scheme://hostname:port
+ // http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#dom-messageevent-origin
+ var originHostname = event.origin.split('://')[1].split(':')[0],
+ requestObj = JSON.parse(event.data);
+
+ /**
+ message generally looks like
+ {
+ cmd: xauth::command_name,
+ id: request_id,
+ other parameters
+ }
+ **/
+
+ if(!requestObj || typeof requestObj != 'object'
+ || !requestObj.cmd || requestObj.id == undefined
+ || checkDisabled()) {
+ // A post message we don't understand
+ return;
+ }
+
+ if(XAuthApi[requestObj.cmd]) {
+ // A command we understand, send the response on back to the posting window
+ sendResponse(XAuthApi[requestObj.cmd](originHostname, requestObj), event.origin);
+ }
+ }
+
+ // Setup postMessage event listeners
+ if (win.addEventListener) {
+ win.addEventListener('message', onMessage, false);
+ } else if(win.attachEvent) {
+ win.attachEvent('onmessage', onMessage);
+ }
+
+ // Finally, tell the parent window we're ready.
+ win.parent.postMessage(JSON.stringify({cmd: 'xauth::ready'}),"*");
+
+})();
453 src/spec/index.html
@@ -0,0 +1,453 @@
+<!--
+ Copyright 2010 Meebo Inc.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<!doctype html>
+<html>
+<head>
+<title>XAuth Specifications</title>
+<script type="text/javascript" src="http://xauth.org/xauth.js"></script>
+<script type="text/javascript">
+var libraryURL = 'http://xauth.org/xauth.js'
+
+function onbodyload() {
+ var copyme = document.getElementById('code_copy');
+ copyme.value = '<scr' + 'ipt type="text/javascript" src="' + libraryURL + '"></scr' + 'ipt>';
+
+ generateToken();
+ generateExpire();
+ generateRetrieve();
+}
+
+function generateToken() {
+ var token = (Math.floor(Math.random()*10000000000)).toString(16)
+ + (Math.floor(Math.random()*10000000000)).toString(16)
+ + (Math.floor(Math.random()*10000000000)).toString(16);
+ document.getElementById('token').value = token;
+ generateExtendCode();
+}
+
+function generateExpire(secondsToExpire) {
+ var seconds = secondsToExpire || 24*60*60; // Default to 24 hours
+ var expire = (new Date().getTime() + seconds*1000);
+ document.getElementById('expire').value = expire;
+ generateExtendCode();
+}
+
+function generateRetrieve() {
+ document.getElementById('retrieve').value = 'www.meebo.com, www.youface.com, ' + document.domain;
+ generateRetrieveCode();
+}
+
+function runCode(methodName) {
+ var code = document.getElementById('code_' + methodName).value;
+ try {
+ eval(code);
+ } catch(e) {
+ document.getElementById('results_' + methodName).innerHTML += (e.toString() + "<br/>");
+ }
+}
+
+function extendCallback(responseObj) {
+ var cmd = responseObj.cmd;
+ document.getElementById('results_extend').innerHTML += ('XAuth' + cmd.substr(5) + " succeeded! Response JSON:<br/><pre>" + JSON.stringify(responseObj, null, ' ') + "</pre>");
+}
+
+function expireCallback(responseObj) {
+ var cmd = responseObj.cmd;
+ document.getElementById('results_expire').innerHTML += ('XAuth' + cmd.substr(5) + " succeeded! Response JSON:<br/><pre>" + JSON.stringify(responseObj, null, ' ') + "</pre>");
+}
+
+function retrieveCallback(responseObj) {
+ var results = responseObj.tokens;
+ var cmd = responseObj.cmd.substr(5);
+ var tokens = '';
+ for(var id in results) {
+ tokens += '<tr><td>' + id + '</td><td>' + results[id]['token'] + '</td></tr>';
+ }
+ if(tokens == '') {
+ tokens = 'No Tokens Available to you right now';
+ } else {
+ tokens = '<table><tr><th>Domain</th><th>Token</th></tr>' + tokens + '</table>'
+ }
+
+ tokens += "<br>Response JSON:<br/><pre>" + JSON.stringify(responseObj, null, ' ') + "</pre>";
+ document.getElementById('results_retrieve').innerHTML = tokens;
+}
+
+
+function generateExtendCode() {
+ var token = document.getElementById('token').value;
+ var expire = document.getElementById('expire').value;
+ var session = document.getElementById('session').checked;
+ var extend = document.getElementById('extend').value;
+ var extendList = '["' + extend.replace(/\s+/g,'').split(',').join('", "') + '"]';
+ var code = document.getElementById('code_extend');
+ code.value = 'XAuth.extend({\n token: "' + token + '",\n'
+ + ' expire: ' + expire + ',\n'
+ + (session?' session: true,\n':'')
+ + ' extend: ' + extendList + ',\n'
+ + ' callback: extendCallback\n'
+ + '});';
+}
+
+function generateRetrieveCode() {
+ var retrieve = document.getElementById('retrieve').value;
+ var retrieveList = '["' + retrieve.replace(/\s+/g,'').split(',').join('", "') + '"]';
+ var code = document.getElementById('code_retrieve');
+ code.value = 'XAuth.retrieve({\n retrieve: ' + retrieveList + ',\n'
+ + ' callback: retrieveCallback\n'
+ + '});';
+}
+
+</script>
+
+<style>
+body {
+ padding: 0 30px;
+ margin: 0;
+ font-family: "Helvetica Neue", Helvetica, Arial;
+}
+
+.body {
+ width: 1000px;
+ margin: auto;
+}
+
+button {
+ font-size: 12px;
+}
+
+.navigation {
+ margin-right: 20px;
+ float: left;
+ line-height: 1.5em;
+ padding: 0 20px 20px;
+ background: #EEE;
+}
+
+.navigation ul {
+ padding: 0;
+ margin: 0;
+}
+
+.navigation li {
+ display: block;
+}
+
+.content {
+ float: left;
+ width: 800px;
+}
+
+.rightheader {
+ display: block;
+ float: right;
+ text-align: right;
+}
+
+#domain {
+ color: #AAA;
+}
+
+.copyme {
+ background: #EEE;
+ padding: 10px;
+ font-size: 1.3em;
+ overflow: auto;
+}
+
+#copycode {