bugfixes for real (not mock)
This commit is contained in:
		
							parent
							
								
									5066e16ea7
								
							
						
					
					
						commit
						c4b44a249a
					
				| @ -801,10 +801,13 @@ | |||||||
|           }; |           }; | ||||||
|           xhr.open(preq.method || 'GET', preq.url, true); |           xhr.open(preq.method || 'GET', preq.url, true); | ||||||
|           var headers = preq.headers || {}; |           var headers = preq.headers || {}; | ||||||
|  |           if (preq.data) { | ||||||
|  |             headers['Content-Type'] = 'application/json'; // TODO XXX TODO utf8
 | ||||||
|  |           } | ||||||
|           Object.keys(headers).forEach(function (key) { |           Object.keys(headers).forEach(function (key) { | ||||||
|             xhr.setRequestHeader(key, headers[key]); |             xhr.setRequestHeader(key, headers[key]); | ||||||
|           }); |           }); | ||||||
|           xhr.send(); |           xhr.send(JSON.stringify(preq.data)); | ||||||
|         }); |         }); | ||||||
|       } |       } | ||||||
|     , frameRequest: function (url, state, opts) { |     , frameRequest: function (url, state, opts) { | ||||||
|  | |||||||
| @ -126,13 +126,14 @@ OAUTH3.urls.resourceOwnerPassword = function (directive, opts) { | |||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   var scope = opts.scope || directive.authn_scope; |   var scope = opts.scope || directive.authn_scope; | ||||||
|   var clientId = opts.appId || opts.clientId || opts.client_id; |   var clientAgreeTos = 'oauth3.org/tos/draft'; // opts.clientAgreeTos || opts.client_agree_tos;
 | ||||||
|   var clientAgreeTos = opts.clientAgreeTos || opts.client_agree_tos; |   var clientUri = opts.client_uri; | ||||||
|   var clientUri = opts.clientUri || opts.client_uri || opts.clientUrl || opts.client_url; |  | ||||||
|   var args = directive[type]; |   var args = directive[type]; | ||||||
|   var otpCode = opts.otp || opts.otpCode || opts.otp_code || opts.otpToken || opts.otp_token || undefined; |   var otpCode = opts.otp || opts.otpCode || opts.otp_code || opts.otpToken || opts.otp_token || undefined; | ||||||
|   var params = { |   var params = { | ||||||
|     "grant_type": grantType |     "client_id": opts.client_id || opts.client_uri | ||||||
|  |   , "client_uri": opts.client_uri | ||||||
|  |   , "grant_type": grantType | ||||||
|   , "username": opts.username |   , "username": opts.username | ||||||
|   , "password": opts.password || otpCode || undefined |   , "password": opts.password || otpCode || undefined | ||||||
|   , "totp": opts.totp || opts.totpToken || opts.totp_token || undefined |   , "totp": opts.totp || opts.totpToken || opts.totp_token || undefined | ||||||
| @ -153,11 +154,7 @@ OAUTH3.urls.resourceOwnerPassword = function (directive, opts) { | |||||||
|     params.totp = opts.totp; |     params.totp = opts.totp; | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   if (clientId) { |  | ||||||
|     params.clientId = clientId; |  | ||||||
|   } |  | ||||||
|   if (clientUri) { |   if (clientUri) { | ||||||
|     params.clientUri = clientUri; |  | ||||||
|     params.clientAgreeTos = clientAgreeTos; |     params.clientAgreeTos = clientAgreeTos; | ||||||
|     if (!clientAgreeTos) { |     if (!clientAgreeTos) { | ||||||
|       throw new Error('Developer Error: missing clientAgreeTos uri'); |       throw new Error('Developer Error: missing clientAgreeTos uri'); | ||||||
| @ -175,7 +172,7 @@ OAUTH3.urls.resourceOwnerPassword = function (directive, opts) { | |||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   return { |   return { | ||||||
|     url: uri |     url: OAUTH3.url.resolve(directive.issuer, uri) | ||||||
|   , method: args.method |   , method: args.method | ||||||
|   , data: body |   , data: body | ||||||
|   }; |   }; | ||||||
| @ -248,8 +245,9 @@ OAUTH3.authn.loginMeta = function (directive, opts) { | |||||||
|   }); |   }); | ||||||
| }; | }; | ||||||
| OAUTH3.authn.otp = function (directive, opts) { | OAUTH3.authn.otp = function (directive, opts) { | ||||||
|   return OAUTH3.request({ |   console.log('OTP directive', directive); | ||||||
|     method: directive.credential_otp.url.method || 'POST' |   var preq = { | ||||||
|  |     method: directive.credential_otp.method || 'POST' | ||||||
|   , url: OAUTH3.url.resolve(directive.issuer, directive.credential_otp.url) |   , url: OAUTH3.url.resolve(directive.issuer, directive.credential_otp.url) | ||||||
|   , data: { |   , data: { | ||||||
|       // TODO replace with signed hosted file
 |       // TODO replace with signed hosted file
 | ||||||
| @ -259,7 +257,9 @@ OAUTH3.authn.otp = function (directive, opts) { | |||||||
|     , request_otp: true |     , request_otp: true | ||||||
|     , username: opts.email |     , username: opts.email | ||||||
|     } |     } | ||||||
|   }); |   }; | ||||||
|  |   console.log('OTP preq', preq); | ||||||
|  |   return OAUTH3.request(preq); | ||||||
| }; | }; | ||||||
| OAUTH3.authn.resourceOwnerPassword = function (directive, opts) { | OAUTH3.authn.resourceOwnerPassword = function (directive, opts) { | ||||||
|   console.log('ginger bread man'); |   console.log('ginger bread man'); | ||||||
| @ -276,7 +276,7 @@ OAUTH3.authn.resourceOwnerPassword = function (directive, opts) { | |||||||
|       if (data.error) { |       if (data.error) { | ||||||
|         return OAUTH3.PromiseA.reject(OAUTH3.error.parse(providerUri, data.error)); |         return OAUTH3.PromiseA.reject(OAUTH3.error.parse(providerUri, data.error)); | ||||||
|       } |       } | ||||||
|       return OAUTH3.hooks.refreshSession( |       return OAUTH3.hooks.session.refresh( | ||||||
|         opts.session || { provider_uri: providerUri, client_uri: opts.client_uri || opts.clientUri } |         opts.session || { provider_uri: providerUri, client_uri: opts.client_uri || opts.clientUri } | ||||||
|       , data |       , data | ||||||
|       ); |       ); | ||||||
| @ -515,6 +515,27 @@ OAUTH3.requests.accounts.create = function (directive, session, account) { | |||||||
|   , data: data |   , data: data | ||||||
|   }); |   }); | ||||||
| }; | }; | ||||||
|  | OAUTH3.hooks.grants = { | ||||||
|  |   // Provider Only
 | ||||||
|  |   set: function (clientUri, newGrants) { | ||||||
|  |     clientUri = OAUTH3.uri.normalize(clientUri); | ||||||
|  |     console.warn('[oauth3.hooks.setGrants] PLEASE IMPLEMENT -- Your Fault'); | ||||||
|  |     console.warn(newGrants); | ||||||
|  |     if (!this._cache) { this._cache = {}; } | ||||||
|  |     console.log('clientUri, newGrants'); | ||||||
|  |     console.log(clientUri, newGrants); | ||||||
|  |     this._cache[clientUri] = newGrants; | ||||||
|  |     return newGrants; | ||||||
|  |   } | ||||||
|  | , get: function (clientUri) { | ||||||
|  |     clientUri = OAUTH3.uri.normalize(clientUri); | ||||||
|  |     console.warn('[oauth3.hooks.getGrants] PLEASE IMPLEMENT -- Your Fault'); | ||||||
|  |     if (!this._cache) { this._cache = {}; } | ||||||
|  |     console.log('clientUri, existingGrants'); | ||||||
|  |     console.log(clientUri, this._cache[clientUri]); | ||||||
|  |     return this._cache[clientUri]; | ||||||
|  |   } | ||||||
|  | }; | ||||||
| 
 | 
 | ||||||
| OAUTH3._browser.isIframe = function isIframe () { | OAUTH3._browser.isIframe = function isIframe () { | ||||||
|   try { |   try { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user