Comparing version 2.0.3 to 2.0.4
@@ -159,3 +159,3 @@ /******/ (function(modules) { // webpackBootstrap | ||
execAuthFailure = function execAuthFailure() { | ||
execAuthFailure = function execAuthFailure(rejection) { | ||
@@ -168,5 +168,8 @@ try { | ||
var ex = new TypeError('credential was expired or had been removed, pls set it before the get action!'); | ||
var ex = new TypeError('Unauthorized! Credential was expired or had been removed, pls set it before the get action!'); | ||
console.error(ex); | ||
return _injector2.default.get('$q').reject(ex); | ||
rejection.status = rejection.status || 401; | ||
rejection.statusText = rejection.statusText || 'Unauthorized!'; | ||
return _injector2.default.get('$q').reject(rejection); | ||
}; | ||
@@ -187,3 +190,3 @@ } | ||
if (!credential) { | ||
return execAuthFailure(); | ||
return execAuthFailure({ config: config }); | ||
} | ||
@@ -206,3 +209,3 @@ | ||
// token失效 | ||
return execAuthFailure(); | ||
return execAuthFailure({ config: config }); | ||
} | ||
@@ -209,0 +212,0 @@ } |
@@ -1,2 +0,2 @@ | ||
!function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(1),u=r(o),i=n(2),a=r(i);t["default"]=u["default"].module("ccms.sdk",[a["default"]]).name},function(e,t){e.exports=angular},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(1),u=r(o),i=n(3),a=r(i),s=n(8),c=r(s),l=n(6);t["default"]=u["default"].module("ccms.utils.interceptors",[]).constant("ccmsTokenRefreshInterceptor",a["default"]).constant("$ccmsAuth",{getRequestCredential:l.getRequestCredential,setRequestCredential:l.setRequestCredential,setAuthFailedBehavior:i.setAuthFailedBehavior,setRefreshTokenUrl:i.setRefreshTokenUrl}).constant("apiRequestPrefixInterceptor",{origin:c["default"],setApiRequestPrefix:s.setApiRequestPrefix}).name},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function u(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:h;h=function(){try{e()}finally{(0,c.removeRequestCredential)()}var t=new TypeError("credential was expired or had been removed, pls set it before the get action!");return console.error(t),s["default"].get("$q").reject(t)}}function i(e){m=e,p.push(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.setAuthFailedBehavior=u,t.setRefreshTokenUrl=i;var a=n(4),s=r(a),c=n(6),l=window.Date,f="X-TOKEN",d=18e5,p=[],v=!1,h=function(){},m="";t["default"]={request:function(e){var t=(0,c.getRequestCredential)();if(!t)return h();if(e.headers[f]=t.id,t.refreshToken&&p.indexOf(e.url)===-1){var n=l.parse(t.expireTime),r=l.now();if(d>=n-r&&n-r>=0)v=!0;else if(n-r<0)return h()}return e},response:function(e){var t=(0,c.getRequestCredential)(),n=s["default"].get("$http");return v&&0===n.pendingRequests.length&&(v=!1,n.put(m,t.refreshToken,{headers:o({},f,t.id)}).then(function(e){(0,c.setRequestCredential)(e.data)},h)),e}}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(){var e=arguments.length<=0||void 0===arguments[0]?document.querySelector("[ng-app]")||document.documentElement:arguments[0],t=i["default"].element(e).injector();if(t)return t;for(var n=e.childNodes,r=0;r<n.length;r++){var u=o(n[r]);if(u)return u}return null}Object.defineProperty(t,"__esModule",{value:!0}),t.getInjector=o;var u=n(1),i=r(u),a=n(5),s=r(a),c=null;t["default"]=c,(0,s["default"])(t,"default",function(){return c||(c=o())})},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=function(e,t,n){Object.defineProperty(e,t,{get:function(){return n.apply(this)}})}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(){return l.parse(c.getItem(f)||s["default"].get(f)||null)}function u(e){c.setItem(f,l.stringify(e))}function i(){c.removeItem(f),s["default"].remove(f)}Object.defineProperty(t,"__esModule",{value:!0}),t.getRequestCredential=o,t.setRequestCredential=u,t.removeRequestCredential=i;var a=n(7),s=r(a),c=window.localStorage,l=window.JSON,f="ccmsRequestCredential"},function(e,t,n){var r,o;!function(u){var i=!1;if(r=u,o="function"==typeof r?r.call(t,n,t,e):r,!(void 0!==o&&(e.exports=o)),i=!0,e.exports=u(),i=!0,!i){var a=window.Cookies,s=window.Cookies=u();s.noConflict=function(){return window.Cookies=a,s}}}(function(){function e(){for(var e=0,t={};e<arguments.length;e++){var n=arguments[e];for(var r in n)t[r]=n[r]}return t}function t(n){function r(t,o,u){var i;if("undefined"!=typeof document){if(arguments.length>1){if(u=e({path:"/"},r.defaults,u),"number"==typeof u.expires){var a=new Date;a.setMilliseconds(a.getMilliseconds()+864e5*u.expires),u.expires=a}try{i=JSON.stringify(o),/^[\{\[]/.test(i)&&(o=i)}catch(s){}return o=n.write?n.write(o,t):encodeURIComponent(String(o)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),t=encodeURIComponent(String(t)),t=t.replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent),t=t.replace(/[\(\)]/g,escape),document.cookie=[t,"=",o,u.expires?"; expires="+u.expires.toUTCString():"",u.path?"; path="+u.path:"",u.domain?"; domain="+u.domain:"",u.secure?"; secure":""].join("")}t||(i={});for(var c=document.cookie?document.cookie.split("; "):[],l=/(%[0-9A-Z]{2})+/g,f=0;f<c.length;f++){var d=c[f].split("="),p=d.slice(1).join("=");'"'===p.charAt(0)&&(p=p.slice(1,-1));try{var v=d[0].replace(l,decodeURIComponent);if(p=n.read?n.read(p,v):n(p,v)||p.replace(l,decodeURIComponent),this.json)try{p=JSON.parse(p)}catch(s){}if(t===v){i=p;break}t||(i[v]=p)}catch(s){}}return i}}return r.set=r,r.get=function(e){return r.call(r,e)},r.getJSON=function(){return r.apply({json:!0},[].slice.call(arguments))},r.defaults={},r.remove=function(t,n){r(t,"",e(n,{expires:-1}))},r.withConverter=t,r}return t(function(){})})},function(e,t){"use strict";function n(e){i=e}Object.defineProperty(t,"__esModule",{value:!0}),t.setApiRequestPrefix=n;var r=/^(?!.*\.\w*(\?.*)?$).+$/,o=function(e){return r.test(e)},u=function(e){return!/^(http|https):\/\//.test(e)},i="";t["default"]={request:function(e){var t=e.url;return u(t)&&o(t)&&(e.url=i+t),e}}}]); | ||
!function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(1),u=r(o),i=n(2),s=r(i);t["default"]=u["default"].module("ccms.sdk",[s["default"]]).name},function(e,t){e.exports=angular},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(1),u=r(o),i=n(3),s=r(i),a=n(8),c=r(a),l=n(6);t["default"]=u["default"].module("ccms.utils.interceptors",[]).constant("ccmsTokenRefreshInterceptor",s["default"]).constant("$ccmsAuth",{getRequestCredential:l.getRequestCredential,setRequestCredential:l.setRequestCredential,setAuthFailedBehavior:i.setAuthFailedBehavior,setRefreshTokenUrl:i.setRefreshTokenUrl}).constant("apiRequestPrefixInterceptor",{origin:c["default"],setApiRequestPrefix:a.setApiRequestPrefix}).name},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function u(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:h;h=function(t){try{e()}finally{(0,c.removeRequestCredential)()}var n=new TypeError("Unauthorized! Credential was expired or had been removed, pls set it before the get action!");return console.error(n),t.status=t.status||401,t.statusText=t.statusText||"Unauthorized!",a["default"].get("$q").reject(t)}}function i(e){m=e,p.push(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.setAuthFailedBehavior=u,t.setRefreshTokenUrl=i;var s=n(4),a=r(s),c=n(6),l=window.Date,f="X-TOKEN",d=18e5,p=[],v=!1,h=function(){},m="";t["default"]={request:function(e){var t=(0,c.getRequestCredential)();if(!t)return h({config:e});if(e.headers[f]=t.id,t.refreshToken&&p.indexOf(e.url)===-1){var n=l.parse(t.expireTime),r=l.now();if(d>=n-r&&n-r>=0)v=!0;else if(n-r<0)return h({config:e})}return e},response:function(e){var t=(0,c.getRequestCredential)(),n=a["default"].get("$http");return v&&0===n.pendingRequests.length&&(v=!1,n.put(m,t.refreshToken,{headers:o({},f,t.id)}).then(function(e){(0,c.setRequestCredential)(e.data)},h)),e}}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(){var e=arguments.length<=0||void 0===arguments[0]?document.querySelector("[ng-app]")||document.documentElement:arguments[0],t=i["default"].element(e).injector();if(t)return t;for(var n=e.childNodes,r=0;r<n.length;r++){var u=o(n[r]);if(u)return u}return null}Object.defineProperty(t,"__esModule",{value:!0}),t.getInjector=o;var u=n(1),i=r(u),s=n(5),a=r(s),c=null;t["default"]=c,(0,a["default"])(t,"default",function(){return c||(c=o())})},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=function(e,t,n){Object.defineProperty(e,t,{get:function(){return n.apply(this)}})}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(){return l.parse(c.getItem(f)||a["default"].get(f)||null)}function u(e){c.setItem(f,l.stringify(e))}function i(){c.removeItem(f),a["default"].remove(f)}Object.defineProperty(t,"__esModule",{value:!0}),t.getRequestCredential=o,t.setRequestCredential=u,t.removeRequestCredential=i;var s=n(7),a=r(s),c=window.localStorage,l=window.JSON,f="ccmsRequestCredential"},function(e,t,n){var r,o;!function(u){var i=!1;if(r=u,o="function"==typeof r?r.call(t,n,t,e):r,!(void 0!==o&&(e.exports=o)),i=!0,e.exports=u(),i=!0,!i){var s=window.Cookies,a=window.Cookies=u();a.noConflict=function(){return window.Cookies=s,a}}}(function(){function e(){for(var e=0,t={};e<arguments.length;e++){var n=arguments[e];for(var r in n)t[r]=n[r]}return t}function t(n){function r(t,o,u){var i;if("undefined"!=typeof document){if(arguments.length>1){if(u=e({path:"/"},r.defaults,u),"number"==typeof u.expires){var s=new Date;s.setMilliseconds(s.getMilliseconds()+864e5*u.expires),u.expires=s}try{i=JSON.stringify(o),/^[\{\[]/.test(i)&&(o=i)}catch(a){}return o=n.write?n.write(o,t):encodeURIComponent(String(o)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),t=encodeURIComponent(String(t)),t=t.replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent),t=t.replace(/[\(\)]/g,escape),document.cookie=[t,"=",o,u.expires?"; expires="+u.expires.toUTCString():"",u.path?"; path="+u.path:"",u.domain?"; domain="+u.domain:"",u.secure?"; secure":""].join("")}t||(i={});for(var c=document.cookie?document.cookie.split("; "):[],l=/(%[0-9A-Z]{2})+/g,f=0;f<c.length;f++){var d=c[f].split("="),p=d.slice(1).join("=");'"'===p.charAt(0)&&(p=p.slice(1,-1));try{var v=d[0].replace(l,decodeURIComponent);if(p=n.read?n.read(p,v):n(p,v)||p.replace(l,decodeURIComponent),this.json)try{p=JSON.parse(p)}catch(a){}if(t===v){i=p;break}t||(i[v]=p)}catch(a){}}return i}}return r.set=r,r.get=function(e){return r.call(r,e)},r.getJSON=function(){return r.apply({json:!0},[].slice.call(arguments))},r.defaults={},r.remove=function(t,n){r(t,"",e(n,{expires:-1}))},r.withConverter=t,r}return t(function(){})})},function(e,t){"use strict";function n(e){i=e}Object.defineProperty(t,"__esModule",{value:!0}),t.setApiRequestPrefix=n;var r=/^(?!.*\.\w*(\?.*)?$).+$/,o=function(e){return r.test(e)},u=function(e){return!/^(http|https):\/\//.test(e)},i="";t["default"]={request:function(e){var t=e.url;return u(t)&&o(t)&&(e.url=i+t),e}}}]); | ||
//# sourceMappingURL=ccms-sdk.min.js.map |
@@ -36,3 +36,3 @@ 'use strict'; | ||
execAuthFailure = function execAuthFailure() { | ||
execAuthFailure = function execAuthFailure(rejection) { | ||
@@ -45,5 +45,8 @@ try { | ||
var ex = new TypeError('credential was expired or had been removed, pls set it before the get action!'); | ||
var ex = new TypeError('Unauthorized! Credential was expired or had been removed, pls set it before the get action!'); | ||
console.error(ex); | ||
return _injector2.default.get('$q').reject(ex); | ||
rejection.status = rejection.status || 401; | ||
rejection.statusText = rejection.statusText || 'Unauthorized!'; | ||
return _injector2.default.get('$q').reject(rejection); | ||
}; | ||
@@ -64,3 +67,3 @@ } | ||
if (!credential) { | ||
return execAuthFailure(); | ||
return execAuthFailure({ config: config }); | ||
} | ||
@@ -83,3 +86,3 @@ | ||
// token失效 | ||
return execAuthFailure(); | ||
return execAuthFailure({ config: config }); | ||
} | ||
@@ -86,0 +89,0 @@ } |
{ | ||
"name": "ccms-sdk", | ||
"version": "2.0.3", | ||
"version": "2.0.4", | ||
"description": "ccms fe sdk written by es2015+", | ||
@@ -18,3 +18,2 @@ "scripts": { | ||
"devDependencies": { | ||
"angular-es-utils": "^1.3.2", | ||
"angular-mocks": "^1.5.3", | ||
@@ -39,3 +38,2 @@ "babel-cli": "^6.7.7", | ||
"istanbul-instrumenter-loader": "^0.2.0", | ||
"js-cookie": "^2.1.3", | ||
"json-loader": "^0.5.4", | ||
@@ -54,4 +52,6 @@ "karma": "^0.13.22", | ||
"dependencies": { | ||
"angular": "^1.5.3" | ||
"angular": "^1.5.3", | ||
"angular-es-utils": "^1.3.2", | ||
"js-cookie": "^2.1.3" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
56588
30
595
3
+ Addedangular-es-utils@^1.3.2
+ Addedjs-cookie@^2.1.3
+ Addedangular-es-utils@1.3.4(transitive)
+ Addedangular-mocks@1.8.3(transitive)
+ Addedangular-resource@1.8.3(transitive)
+ Addedjs-cookie@2.2.1(transitive)