test oauth3 support via pixel
This commit is contained in:
		
							parent
							
								
									4da61d835e
								
							
						
					
					
						commit
						f6017e7e49
					
				| @ -901,6 +901,7 @@ | |||||||
|         // TODO allow node to open a desktop browser window
 |         // TODO allow node to open a desktop browser window
 | ||||||
|         opts._windowType = opts.windowType; |         opts._windowType = opts.windowType; | ||||||
|         opts.windowType = opts.windowType || 'background'; |         opts.windowType = opts.windowType || 'background'; | ||||||
|  |         return OAUTH3._browser.testPixel(providerUri).then(function () { | ||||||
|           return OAUTH3._browser.frameRequest( |           return OAUTH3._browser.frameRequest( | ||||||
|             OAUTH3.url.resolve(providerUri, discReq.url) |             OAUTH3.url.resolve(providerUri, discReq.url) | ||||||
|           , discReq.state |           , discReq.state | ||||||
| @ -923,6 +924,7 @@ | |||||||
|             // caller will call OAUTH3.hooks.directives.set(providerUri, directives);
 |             // caller will call OAUTH3.hooks.directives.set(providerUri, directives);
 | ||||||
|             return directives; |             return directives; | ||||||
|           }); |           }); | ||||||
|  |         }); | ||||||
|       } |       } | ||||||
|     , request: function (preq, _sys) { |     , request: function (preq, _sys) { | ||||||
|         return new OAUTH3.PromiseA(function (resolve, reject) { |         return new OAUTH3.PromiseA(function (resolve, reject) { | ||||||
| @ -1020,6 +1022,28 @@ | |||||||
|           } |           } | ||||||
|         }); |         }); | ||||||
|       } |       } | ||||||
|  |     , testPixel: function (targetUri) { | ||||||
|  |         var url = OAUTH3.url.resolve(OAUTH3.url.normalize(targetUri), '.well-known/oauth3/clear.gif'); | ||||||
|  |         return new OAUTH3.PromiseA(function (resolve, reject) { | ||||||
|  |           var img = document.createElement('img'); | ||||||
|  |           img.addEventListener('load', function () { | ||||||
|  |             resolve(); | ||||||
|  |           }); | ||||||
|  |           img.addEventListener('error', function () { | ||||||
|  |             var err = new Error("not an oauth3 issuer"); | ||||||
|  |             err.code = 'E_NOT_SUPPORTED'; | ||||||
|  |             reject(err); | ||||||
|  |           }); | ||||||
|  |           // works with CSP
 | ||||||
|  |           img.style.position = 'absolute'; | ||||||
|  |           img.style.left = '-2px'; | ||||||
|  |           img.style.bottom = '-2px'; | ||||||
|  |           img.className = 'js-oauth3-discover'; | ||||||
|  |           img.src = url; | ||||||
|  |           document.body.appendChild(img); | ||||||
|  |           console.log('img', img); | ||||||
|  |         }); | ||||||
|  |       } | ||||||
|     , frameRequest: function (url, state, opts) { |     , frameRequest: function (url, state, opts) { | ||||||
|         opts = opts || {}; |         opts = opts || {}; | ||||||
|         var previousFrame = OAUTH3._browser._frames[state]; |         var previousFrame = OAUTH3._browser._frames[state]; | ||||||
| @ -1266,6 +1290,23 @@ | |||||||
|   OAUTH3.utils = { |   OAUTH3.utils = { | ||||||
|     clientUri: OAUTH3.clientUri |     clientUri: OAUTH3.clientUri | ||||||
|   , query: OAUTH3.query |   , query: OAUTH3.query | ||||||
|  |   , parseSubject: function (sub) { | ||||||
|  |       var parts = sub.split('@'); | ||||||
|  |       var issuer; | ||||||
|  |       var subject; | ||||||
|  | 
 | ||||||
|  |       if (/@/.test(sub)) { | ||||||
|  |         // The username may have a single @, the provider may not
 | ||||||
|  |         // user@thing.com@whatever.com -> user@thing.com, whatever.com
 | ||||||
|  |         issuer = parts.pop(); | ||||||
|  |         subject = parts.join(''); | ||||||
|  |       } else { | ||||||
|  |         //subject = '';
 | ||||||
|  |         issuer = parts.join(''); | ||||||
|  |       } | ||||||
|  | 
 | ||||||
|  |       return { subject: subject, issuer: issuer }; | ||||||
|  |     } | ||||||
|   , scope: OAUTH3.scope |   , scope: OAUTH3.scope | ||||||
|   , uri: OAUTH3.uri |   , uri: OAUTH3.uri | ||||||
|   , url: OAUTH3.url |   , url: OAUTH3.url | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user