update docs and ng api
This commit is contained in:
		
							parent
							
								
									ee631b97c7
								
							
						
					
					
						commit
						52675f84c7
					
				
							
								
								
									
										16
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								README.md
									
									
									
									
									
								
							@ -286,6 +286,18 @@ We've created an `Oauth3` service just for you:
 | 
			
		||||
<script src="assets/org.oauth3/oauth3.ng.js"></script>
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
```js
 | 
			
		||||
// Require the module as 'oauth3.org'
 | 
			
		||||
var app = angular.module('myAppName', [ 'ui.router', 'oauth3.org' ]);
 | 
			
		||||
 | 
			
		||||
// Require services and other submodules in the form {modulename}@oauth3.org
 | 
			
		||||
app.controller('authCtrl', [ '$scope', 'azp@oauth3.org', function ($scope, Oauth3) { /* ... */ } ]);
 | 
			
		||||
 | 
			
		||||
// For backwards compatibility with older angular applications that rely on string-name introspection
 | 
			
		||||
// you can also use the camel case version of the names in the format {Modulename}Oauth3
 | 
			
		||||
app.controller('authCtrl', function ($scope, AzpOauth3) { /* ... */ });
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
You can include that in addition to the standard file or,
 | 
			
		||||
if you don't want an extra request, just paste it into your `app.js`.
 | 
			
		||||
 | 
			
		||||
@ -300,8 +312,8 @@ oauth3 = OAUTH3.create(location);                   // takes a location object,
 | 
			
		||||
                                                    // to create the Client URI (your app's id)
 | 
			
		||||
                                                    // and save it to an internal state
 | 
			
		||||
 | 
			
		||||
promise = oauth3.init(location);                    // set and fetch your own site/app's configuration details
 | 
			
		||||
// promises your site's config
 | 
			
		||||
promise = oauth3.init(opts);                        // set and fetch your own site/app's configuration details
 | 
			
		||||
// promises your site's config                      // opts = { location, session, issuer, audience }
 | 
			
		||||
 | 
			
		||||
promise = oauth3.setIdentityProvider(url);          // changes the Identity Provider URI (the site you're logging into),
 | 
			
		||||
// promises the provider's config                   // gets the config for that site (from their .well-known/oauth3),
 | 
			
		||||
 | 
			
		||||
@ -1097,7 +1097,16 @@
 | 
			
		||||
    //, _resourceProviderMap: null // map between xyz.com and org.oauth3.domains
 | 
			
		||||
    , _init: function (location, opts) {
 | 
			
		||||
        var me = this;
 | 
			
		||||
        if (location) {
 | 
			
		||||
        if (!opts) {
 | 
			
		||||
          opts = location;
 | 
			
		||||
        }
 | 
			
		||||
        if (location && location.location) {
 | 
			
		||||
          location = location.location;
 | 
			
		||||
        }
 | 
			
		||||
        if (opts && opts.location) {
 | 
			
		||||
          me._clientUri = OAUTH3.clientUri(opts.location);
 | 
			
		||||
        }
 | 
			
		||||
        if (location && (location.host || location.hostname)) {
 | 
			
		||||
          me._clientUri = OAUTH3.clientUri(location);
 | 
			
		||||
        }
 | 
			
		||||
        if (opts) {
 | 
			
		||||
@ -1105,11 +1114,11 @@
 | 
			
		||||
            me._identityProviderUri = opts.providerUri;
 | 
			
		||||
            me._resourceProviderUri = opts.providerUri;
 | 
			
		||||
          }
 | 
			
		||||
          if (opts.identityProviderUri) {
 | 
			
		||||
            me._identityProviderUri = opts.identityProviderUri;
 | 
			
		||||
          if (opts.issuer || opts.identityProviderUri) {
 | 
			
		||||
            me._identityProviderUri = opts.issuer || opts.identityProviderUri;
 | 
			
		||||
          }
 | 
			
		||||
          if (opts.resourceProviderUri) {
 | 
			
		||||
            me._resourceProviderUri = opts.resourceProviderUri;
 | 
			
		||||
          if (opts.audience || opts.resourceProviderUri) {
 | 
			
		||||
            me._resourceProviderUri = opts.audience || opts.resourceProviderUri;
 | 
			
		||||
          }
 | 
			
		||||
          if (opts.session) {
 | 
			
		||||
            if (!me._identityProviderUri) {
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										56
									
								
								oauth3.ng.js
									
									
									
									
									
								
							
							
						
						
									
										56
									
								
								oauth3.ng.js
									
									
									
									
									
								
							@ -1,38 +1,44 @@
 | 
			
		||||
;(function () {
 | 
			
		||||
'use strict';
 | 
			
		||||
 | 
			
		||||
angular
 | 
			
		||||
  .module('org.oauth3', [])
 | 
			
		||||
  .service('Oauth3', [
 | 
			
		||||
var modules = {
 | 
			
		||||
  azp: [
 | 
			
		||||
    '$timeout'
 | 
			
		||||
  , '$q'
 | 
			
		||||
  , function Oauth3($timeout, $q) {
 | 
			
		||||
 | 
			
		||||
    var OAUTH3 = window.OAUTH3;
 | 
			
		||||
      var OAUTH3 = window.OAUTH3;
 | 
			
		||||
 | 
			
		||||
    // We need to make angular's $q appear to be a standard Promise/A+
 | 
			
		||||
    // fortunately, this is pretty easy
 | 
			
		||||
    function PromiseAngularQ(fn) {
 | 
			
		||||
      var d = $q.defer();
 | 
			
		||||
      // We need to make angular's $q appear to be a standard Promise/A+
 | 
			
		||||
      // fortunately, this is pretty easy
 | 
			
		||||
      function PromiseAngularQ(fn) {
 | 
			
		||||
        var d = $q.defer();
 | 
			
		||||
 | 
			
		||||
      //$timeout(function () {
 | 
			
		||||
        fn(d.resolve, d.reject);
 | 
			
		||||
      //}, 0);
 | 
			
		||||
        //$timeout(function () {
 | 
			
		||||
          fn(d.resolve, d.reject);
 | 
			
		||||
        //}, 0);
 | 
			
		||||
 | 
			
		||||
      //this.then = d.promise.then;
 | 
			
		||||
      //this.catch = d.promise.catch;
 | 
			
		||||
      return d.promise;
 | 
			
		||||
        //this.then = d.promise.then;
 | 
			
		||||
        //this.catch = d.promise.catch;
 | 
			
		||||
        return d.promise;
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      //PromiseAngularQ.create = PromiseAngularQ;
 | 
			
		||||
      PromiseAngularQ.resolve = $q.when;
 | 
			
		||||
      PromiseAngularQ.reject = $q.reject;
 | 
			
		||||
      PromiseAngularQ.all = $q.all;
 | 
			
		||||
 | 
			
		||||
      OAUTH3.PromiseA = PromiseAngularQ;
 | 
			
		||||
 | 
			
		||||
      window.ngOauth3 = OAUTH3;
 | 
			
		||||
 | 
			
		||||
      return OAUTH3;
 | 
			
		||||
    }
 | 
			
		||||
  ]
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
    //PromiseAngularQ.create = PromiseAngularQ;
 | 
			
		||||
    PromiseAngularQ.resolve = $q.when;
 | 
			
		||||
    PromiseAngularQ.reject = $q.reject;
 | 
			
		||||
    PromiseAngularQ.all = $q.all;
 | 
			
		||||
 | 
			
		||||
    OAUTH3.PromiseA = PromiseAngularQ;
 | 
			
		||||
 | 
			
		||||
    window.ngOauth3 = OAUTH3;
 | 
			
		||||
 | 
			
		||||
    return OAUTH3;
 | 
			
		||||
  }]);
 | 
			
		||||
angular
 | 
			
		||||
  .module('oauth3.org', [])
 | 
			
		||||
  .service('azp@oauth3.org', modules.azp);
 | 
			
		||||
  .service('AzpOauth3', modules.azp);
 | 
			
		||||
}());
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user