-
Notifications
You must be signed in to change notification settings - Fork 0
/
oauth1.min.js
8 lines (8 loc) · 1.65 KB
/
oauth1.min.js
1
2
3
4
5
6
7
8
/**
* angular-hu-oauth1 v1.1.0
* https://github.com/angular-hu/angular-hu
* (c) 2015 Telefónica I+D - http://www.tid.es
* @license MIT
*/
!function(e){function t(t,r,n){function o(r){return e.isString(r)?t.get(r):r}function a(){for(var e="",t=0;m>t;++t){var r=n.Math.floor(n.Math.random()*h.length);e+=h.substring(r,r+1)}return e}function u(e,t){return e.error=t,e}function i(){var e=(new Date).getTime();return n.Math.floor(e/1e3)}function c(t,r){e.forEach(t,function(e,t){r(t,""+e)})}var h="0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz",s="HMAC-SHA1",m=11,g={MissingKeySecret:"MissingKeySecret"};return function(t){function h(t){if(!t.oauth1)return t;var a=o(m.getTimestamp),u=o(m.nonce);if(null==t.oauth1.consumerKey||null==t.oauth1.consumerSecret){var i=o(m.createError)(t,new Error(g.MissingKeySecret));return r.reject(i)}return r.when().then(a).then(function(r){t.params=t.params||{},delete t.params.oauth_signature,e.extend(t.params,{oauth_consumer_key:t.oauth1.consumerKey.toString(),oauth_nonce:u(),oauth_timestamp:r,oauth_signature_method:m.oauth_signature_method,oauth_version:"1.0"});var o={};return m.serializer(t.params,function(e,t){o[e]=t}),t.params.oauth_signature=n.oauthSignature.generate(t.method,t.url,o,t.oauth1.consumerSecret.toString(),""+(t.oauth1.tokenSecret||""),{encodeSignature:!1}),t})["catch"](function(e){var n=o(m.createError)(t,e);return r.reject(n)})}var m={oauth_signature_method:s,createError:u,getTimestamp:i,serializer:c,nonce:a};return e.extend(m,t||{}),{request:h}}}e.module("httpu.oauth1",[]).factory("huOAuth1InterceptorFactory",t),t.$inject=["$injector","$q","$window"]}(window.angular);
//# sourceMappingURL=oauth1.min.js.map