Comparing version 2.1.1 to 2.1.2
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
@@ -27,12 +27,21 @@ exports.getRequestCredential = getRequestCredential; | ||
function getRequestCredential() { | ||
return JSON.parse(localStorage.getItem(REQUEST_TOKEN_STORAGE_KEY) || _jsCookie2.default.get(REQUEST_TOKEN_STORAGE_KEY) || null); | ||
var credential = null; | ||
// get credential from cookie when inside an iframe | ||
if (window.self !== window.top) { | ||
credential = _jsCookie2.default.get(REQUEST_TOKEN_STORAGE_KEY) || null; | ||
} else { | ||
credential = localStorage.getItem(REQUEST_TOKEN_STORAGE_KEY) || null; | ||
} | ||
return JSON.parse(credential); | ||
} | ||
function setRequestCredential(credential) { | ||
localStorage.setItem(REQUEST_TOKEN_STORAGE_KEY, JSON.stringify(credential)); | ||
localStorage.setItem(REQUEST_TOKEN_STORAGE_KEY, JSON.stringify(credential)); | ||
} | ||
function removeRequestCredential() { | ||
localStorage.removeItem(REQUEST_TOKEN_STORAGE_KEY); | ||
_jsCookie2.default.remove(REQUEST_TOKEN_STORAGE_KEY); | ||
localStorage.removeItem(REQUEST_TOKEN_STORAGE_KEY); | ||
_jsCookie2.default.remove(REQUEST_TOKEN_STORAGE_KEY); | ||
} |
@@ -254,3 +254,3 @@ /******/ (function(modules) { // webpackBootstrap | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
@@ -278,12 +278,21 @@ exports.getRequestCredential = getRequestCredential; | ||
function getRequestCredential() { | ||
return JSON.parse(localStorage.getItem(REQUEST_TOKEN_STORAGE_KEY) || _jsCookie2.default.get(REQUEST_TOKEN_STORAGE_KEY) || null); | ||
var credential = null; | ||
// get credential from cookie when inside an iframe | ||
if (window.self !== window.top) { | ||
credential = _jsCookie2.default.get(REQUEST_TOKEN_STORAGE_KEY) || null; | ||
} else { | ||
credential = localStorage.getItem(REQUEST_TOKEN_STORAGE_KEY) || null; | ||
} | ||
return JSON.parse(credential); | ||
} | ||
function setRequestCredential(credential) { | ||
localStorage.setItem(REQUEST_TOKEN_STORAGE_KEY, JSON.stringify(credential)); | ||
localStorage.setItem(REQUEST_TOKEN_STORAGE_KEY, JSON.stringify(credential)); | ||
} | ||
function removeRequestCredential() { | ||
localStorage.removeItem(REQUEST_TOKEN_STORAGE_KEY); | ||
_jsCookie2.default.remove(REQUEST_TOKEN_STORAGE_KEY); | ||
localStorage.removeItem(REQUEST_TOKEN_STORAGE_KEY); | ||
_jsCookie2.default.remove(REQUEST_TOKEN_STORAGE_KEY); | ||
} | ||
@@ -290,0 +299,0 @@ |
@@ -1,2 +0,2 @@ | ||
!function(e){function t(n){if(r[n])return r[n].exports;var i=r[n]={exports:{},id:n,loaded:!1};return e[n].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0});var i=r(1),u=n(i),o=r(2),a=n(o);t["default"]=u["default"].module("ccms.sdk",[a["default"]]).name},function(e,t){e.exports=angular},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0});var i=r(1),u=n(i),o=r(3),a=n(o),s=r(9),c=n(s),l=r(10),d=n(l),f=r(4);t["default"]=u["default"].module("ccms.utils.interceptors",[]).constant("ccmsTokenRefreshInterceptor",a["default"]).constant("$ccmsAuth",{getRequestCredential:f.getRequestCredential,setRequestCredential:f.setRequestCredential,setAuthFailedBehavior:o.setAuthFailedBehavior,setRefreshTokenUrl:o.setRefreshTokenUrl}).constant("apiRequestPrefixInterceptor",{origin:d["default"],setApiRequestPrefix:l.setApiRequestPrefix}).name,window.ccmsSdk||(window.ccmsSdk={}),Object.assign(window.ccmsSdk,{tokenRefreshInterceptor:c["default"],$ccmsAuth:{setAuthFailedBehavior:s.setAuthFailedBehavior,setRefreshTokenUrl:s.setRefreshTokenUrl,getRequestCredential:f.getRequestCredential,setRequestCredential:f.setRequestCredential}})},function(e,t,r){"use strict";function n(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function i(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:c;t.execAuthFailure=c=function(t){try{e()}finally{(0,o.removeRequestCredential)()}var n=new TypeError("Unauthorized! Credential was expired or had been removed, pls set it before the get action!");if(console.error(n),"function"!=typeof t.abort){t.status=t.status||401,t.statusText=t.statusText||"Unauthorized!";var i=r(7)["default"];return i.get("$q").reject(t)}t.abort(n)}}function u(e){t.refreshTokenUrl=l=e,a.REQUEST_WHITE_LIST.push(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.refreshTokenUrl=t.execAuthFailure=void 0,t.setAuthFailedBehavior=i,t.setRefreshTokenUrl=u;var o=r(4),a=r(6),s=!1,c=t.execAuthFailure=function(){},l=t.refreshTokenUrl="";t["default"]={request:function(e){var t=(0,o.getRequestCredential)();if(!t)return c({config:e});if(e.headers[a.REQUEST_TOKEN_HEADER]=t.id,t.refreshToken&&a.REQUEST_WHITE_LIST.indexOf(e.url)===-1){var r=a.Date.parse(t.expireTime),n=a.Date.now();if(a.USER_SESSION_AVAILABLE_TIME>=r-n&&r-n>=0)s=!0;else if(r-n<0)return c({config:e})}return e},response:function(e){var t=(0,o.getRequestCredential)(),i=r(7)["default"],u=i.get("$http");return s&&0===u.pendingRequests.length&&(s=!1,u.put(l,t.refreshToken,{headers:n({},a.REQUEST_TOKEN_HEADER,t.id)}).then(function(e){(0,o.setRequestCredential)(e.data)},c)),e}}},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}function i(){return l.parse(c.getItem(d)||s["default"].get(d)||null)}function u(e){c.setItem(d,l.stringify(e))}function o(){c.removeItem(d),s["default"].remove(d)}Object.defineProperty(t,"__esModule",{value:!0}),t.getRequestCredential=i,t.setRequestCredential=u,t.removeRequestCredential=o;var a=r(5),s=n(a),c=window.localStorage,l=window.JSON,d="ccmsRequestCredential"},function(e,t,r){var n,i;!function(u){var o=!1;if(n=u,i="function"==typeof n?n.call(t,r,t,e):n,!(void 0!==i&&(e.exports=i)),o=!0,e.exports=u(),o=!0,!o){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 r=arguments[e];for(var n in r)t[n]=r[n]}return t}function t(r){function n(t,i,u){var o;if("undefined"!=typeof document){if(arguments.length>1){if(u=e({path:"/"},n.defaults,u),"number"==typeof u.expires){var a=new Date;a.setMilliseconds(a.getMilliseconds()+864e5*u.expires),u.expires=a}try{o=JSON.stringify(i),/^[\{\[]/.test(o)&&(i=o)}catch(s){}return i=r.write?r.write(i,t):encodeURIComponent(String(i)).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,"=",i,u.expires?"; expires="+u.expires.toUTCString():"",u.path?"; path="+u.path:"",u.domain?"; domain="+u.domain:"",u.secure?"; secure":""].join("")}t||(o={});for(var c=document.cookie?document.cookie.split("; "):[],l=/(%[0-9A-Z]{2})+/g,d=0;d<c.length;d++){var f=c[d].split("="),p=f.slice(1).join("=");'"'===p.charAt(0)&&(p=p.slice(1,-1));try{var h=f[0].replace(l,decodeURIComponent);if(p=r.read?r.read(p,h):r(p,h)||p.replace(l,decodeURIComponent),this.json)try{p=JSON.parse(p)}catch(s){}if(t===h){o=p;break}t||(o[h]=p)}catch(s){}}return o}}return n.set=n,n.get=function(e){return n.call(n,e)},n.getJSON=function(){return n.apply({json:!0},[].slice.call(arguments))},n.defaults={},n.remove=function(t,r){n(t,"",e(r,{expires:-1}))},n.withConverter=t,n}return t(function(){})})},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.Date=window.Date,t.REQUEST_TOKEN_HEADER="X-TOKEN",t.USER_SESSION_AVAILABLE_TIME=18e5,t.REQUEST_WHITE_LIST=[]},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}function i(){var e=arguments.length<=0||void 0===arguments[0]?document.querySelector("[ng-app]")||document.documentElement:arguments[0],t=o["default"].element(e).injector();if(t)return t;for(var r=e.childNodes,n=0;n<r.length;n++){var u=i(r[n]);if(u)return u}return null}Object.defineProperty(t,"__esModule",{value:!0}),t.getInjector=i;var u=r(1),o=n(u),a=r(8),s=n(a),c=null;t["default"]=c,(0,s["default"])(t,"default",function(){return c||(c=i())})},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=function(e,t,r){Object.defineProperty(e,t,{get:function(){return r.apply(this)}})}},function(e,t,r){"use strict";function n(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}Object.defineProperty(t,"__esModule",{value:!0});var i=r(4),u=r(6),o=r(3),a=!1;t["default"]={beforeSend:function(e,t){var r=(0,i.getRequestCredential)();if(!r)return void(0,o.execAuthFailure)(e);if(e.setRequestHeader(u.REQUEST_TOKEN_HEADER,r.id),e[u.REQUEST_TOKEN_HEADER]=r.id,r.refreshToken&&u.REQUEST_WHITE_LIST.indexOf(t.url)===-1){var n=u.Date.parse(r.expireTime),s=u.Date.now();u.USER_SESSION_AVAILABLE_TIME>=n-s&&n-s>=0?a=!0:n-s<0&&(0,o.execAuthFailure)(e)}},complete:function(e){var t=(0,i.getRequestCredential)(),r=window.$;a&&r.active<=1&&(a=!1,e[u.REQUEST_TOKEN_HEADER]=t.id,r.ajax({url:o.refreshTokenUrl,method:"PUT",data:t.refreshToken,headers:n({},u.REQUEST_TOKEN_HEADER,t.id)}).done(function(e){(0,i.setRequestCredential)(JSON.parse(e))}).fail(function(){return(0,o.execAuthFailure)(e)}))}}},function(e,t){"use strict";function r(e){o=e}Object.defineProperty(t,"__esModule",{value:!0}),t.setApiRequestPrefix=r;var n=/^(?!.*\.\w*(\?.*)?$).+$/,i=function(e){return n.test(e)},u=function(e){return!/^(http|https):\/\//.test(e)},o="";t["default"]={request:function(e){var t=e.url;return u(t)&&i(t)&&(e.url=o+t),e}}}]); | ||
!function(e){function t(n){if(r[n])return r[n].exports;var i=r[n]={exports:{},id:n,loaded:!1};return e[n].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0});var i=r(1),u=n(i),o=r(2),a=n(o);t["default"]=u["default"].module("ccms.sdk",[a["default"]]).name},function(e,t){e.exports=angular},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0});var i=r(1),u=n(i),o=r(3),a=n(o),s=r(9),l=n(s),c=r(10),d=n(c),f=r(4);t["default"]=u["default"].module("ccms.utils.interceptors",[]).constant("ccmsTokenRefreshInterceptor",a["default"]).constant("$ccmsAuth",{getRequestCredential:f.getRequestCredential,setRequestCredential:f.setRequestCredential,setAuthFailedBehavior:o.setAuthFailedBehavior,setRefreshTokenUrl:o.setRefreshTokenUrl}).constant("apiRequestPrefixInterceptor",{origin:d["default"],setApiRequestPrefix:c.setApiRequestPrefix}).name,window.ccmsSdk||(window.ccmsSdk={}),Object.assign(window.ccmsSdk,{tokenRefreshInterceptor:l["default"],$ccmsAuth:{setAuthFailedBehavior:s.setAuthFailedBehavior,setRefreshTokenUrl:s.setRefreshTokenUrl,getRequestCredential:f.getRequestCredential,setRequestCredential:f.setRequestCredential}})},function(e,t,r){"use strict";function n(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function i(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:l;t.execAuthFailure=l=function(t){try{e()}finally{(0,o.removeRequestCredential)()}var n=new TypeError("Unauthorized! Credential was expired or had been removed, pls set it before the get action!");if(console.error(n),"function"!=typeof t.abort){t.status=t.status||401,t.statusText=t.statusText||"Unauthorized!";var i=r(7)["default"];return i.get("$q").reject(t)}t.abort(n)}}function u(e){t.refreshTokenUrl=c=e,a.REQUEST_WHITE_LIST.push(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.refreshTokenUrl=t.execAuthFailure=void 0,t.setAuthFailedBehavior=i,t.setRefreshTokenUrl=u;var o=r(4),a=r(6),s=!1,l=t.execAuthFailure=function(){},c=t.refreshTokenUrl="";t["default"]={request:function(e){var t=(0,o.getRequestCredential)();if(!t)return l({config:e});if(e.headers[a.REQUEST_TOKEN_HEADER]=t.id,t.refreshToken&&a.REQUEST_WHITE_LIST.indexOf(e.url)===-1){var r=a.Date.parse(t.expireTime),n=a.Date.now();if(a.USER_SESSION_AVAILABLE_TIME>=r-n&&r-n>=0)s=!0;else if(r-n<0)return l({config:e})}return e},response:function(e){var t=(0,o.getRequestCredential)(),i=r(7)["default"],u=i.get("$http");return s&&0===u.pendingRequests.length&&(s=!1,u.put(c,t.refreshToken,{headers:n({},a.REQUEST_TOKEN_HEADER,t.id)}).then(function(e){(0,o.setRequestCredential)(e.data)},l)),e}}},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}function i(){var e=null;return e=window.self!==window.top?s["default"].get(d)||null:l.getItem(d)||null,c.parse(e)}function u(e){l.setItem(d,c.stringify(e))}function o(){l.removeItem(d),s["default"].remove(d)}Object.defineProperty(t,"__esModule",{value:!0}),t.getRequestCredential=i,t.setRequestCredential=u,t.removeRequestCredential=o;var a=r(5),s=n(a),l=window.localStorage,c=window.JSON,d="ccmsRequestCredential"},function(e,t,r){var n,i;!function(u){var o=!1;if(n=u,i="function"==typeof n?n.call(t,r,t,e):n,!(void 0!==i&&(e.exports=i)),o=!0,e.exports=u(),o=!0,!o){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 r=arguments[e];for(var n in r)t[n]=r[n]}return t}function t(r){function n(t,i,u){var o;if("undefined"!=typeof document){if(arguments.length>1){if(u=e({path:"/"},n.defaults,u),"number"==typeof u.expires){var a=new Date;a.setMilliseconds(a.getMilliseconds()+864e5*u.expires),u.expires=a}try{o=JSON.stringify(i),/^[\{\[]/.test(o)&&(i=o)}catch(s){}return i=r.write?r.write(i,t):encodeURIComponent(String(i)).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,"=",i,u.expires?"; expires="+u.expires.toUTCString():"",u.path?"; path="+u.path:"",u.domain?"; domain="+u.domain:"",u.secure?"; secure":""].join("")}t||(o={});for(var l=document.cookie?document.cookie.split("; "):[],c=/(%[0-9A-Z]{2})+/g,d=0;d<l.length;d++){var f=l[d].split("="),p=f.slice(1).join("=");'"'===p.charAt(0)&&(p=p.slice(1,-1));try{var h=f[0].replace(c,decodeURIComponent);if(p=r.read?r.read(p,h):r(p,h)||p.replace(c,decodeURIComponent),this.json)try{p=JSON.parse(p)}catch(s){}if(t===h){o=p;break}t||(o[h]=p)}catch(s){}}return o}}return n.set=n,n.get=function(e){return n.call(n,e)},n.getJSON=function(){return n.apply({json:!0},[].slice.call(arguments))},n.defaults={},n.remove=function(t,r){n(t,"",e(r,{expires:-1}))},n.withConverter=t,n}return t(function(){})})},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.Date=window.Date,t.REQUEST_TOKEN_HEADER="X-TOKEN",t.USER_SESSION_AVAILABLE_TIME=18e5,t.REQUEST_WHITE_LIST=[]},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}function i(){var e=arguments.length<=0||void 0===arguments[0]?document.querySelector("[ng-app]")||document.documentElement:arguments[0],t=o["default"].element(e).injector();if(t)return t;for(var r=e.childNodes,n=0;n<r.length;n++){var u=i(r[n]);if(u)return u}return null}Object.defineProperty(t,"__esModule",{value:!0}),t.getInjector=i;var u=r(1),o=n(u),a=r(8),s=n(a),l=null;t["default"]=l,(0,s["default"])(t,"default",function(){return l||(l=i())})},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=function(e,t,r){Object.defineProperty(e,t,{get:function(){return r.apply(this)}})}},function(e,t,r){"use strict";function n(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}Object.defineProperty(t,"__esModule",{value:!0});var i=r(4),u=r(6),o=r(3),a=!1;t["default"]={beforeSend:function(e,t){var r=(0,i.getRequestCredential)();if(!r)return void(0,o.execAuthFailure)(e);if(e.setRequestHeader(u.REQUEST_TOKEN_HEADER,r.id),e[u.REQUEST_TOKEN_HEADER]=r.id,r.refreshToken&&u.REQUEST_WHITE_LIST.indexOf(t.url)===-1){var n=u.Date.parse(r.expireTime),s=u.Date.now();u.USER_SESSION_AVAILABLE_TIME>=n-s&&n-s>=0?a=!0:n-s<0&&(0,o.execAuthFailure)(e)}},complete:function(e){var t=(0,i.getRequestCredential)(),r=window.$;a&&r.active<=1&&(a=!1,e[u.REQUEST_TOKEN_HEADER]=t.id,r.ajax({url:o.refreshTokenUrl,method:"PUT",data:t.refreshToken,headers:n({},u.REQUEST_TOKEN_HEADER,t.id)}).done(function(e){(0,i.setRequestCredential)(JSON.parse(e))}).fail(function(){return(0,o.execAuthFailure)(e)}))}}},function(e,t){"use strict";function r(e){o=e}Object.defineProperty(t,"__esModule",{value:!0}),t.setApiRequestPrefix=r;var n=/^(?!.*\.\w*(\?.*)?$).+$/,i=function(e){return n.test(e)},u=function(e){return!/^(http|https):\/\//.test(e)},o="";t["default"]={request:function(e){var t=e.url;return u(t)&&i(t)&&(e.url=o+t),e}}}]); | ||
//# sourceMappingURL=ccms-sdk.min.js.map |
@@ -206,3 +206,3 @@ /******/ (function(modules) { // webpackBootstrap | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
@@ -230,12 +230,21 @@ exports.getRequestCredential = getRequestCredential; | ||
function getRequestCredential() { | ||
return JSON.parse(localStorage.getItem(REQUEST_TOKEN_STORAGE_KEY) || _jsCookie2.default.get(REQUEST_TOKEN_STORAGE_KEY) || null); | ||
var credential = null; | ||
// get credential from cookie when inside an iframe | ||
if (window.self !== window.top) { | ||
credential = _jsCookie2.default.get(REQUEST_TOKEN_STORAGE_KEY) || null; | ||
} else { | ||
credential = localStorage.getItem(REQUEST_TOKEN_STORAGE_KEY) || null; | ||
} | ||
return JSON.parse(credential); | ||
} | ||
function setRequestCredential(credential) { | ||
localStorage.setItem(REQUEST_TOKEN_STORAGE_KEY, JSON.stringify(credential)); | ||
localStorage.setItem(REQUEST_TOKEN_STORAGE_KEY, JSON.stringify(credential)); | ||
} | ||
function removeRequestCredential() { | ||
localStorage.removeItem(REQUEST_TOKEN_STORAGE_KEY); | ||
_jsCookie2.default.remove(REQUEST_TOKEN_STORAGE_KEY); | ||
localStorage.removeItem(REQUEST_TOKEN_STORAGE_KEY); | ||
_jsCookie2.default.remove(REQUEST_TOKEN_STORAGE_KEY); | ||
} | ||
@@ -242,0 +251,0 @@ |
@@ -1,2 +0,2 @@ | ||
!function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={exports:{},id:n,loaded:!1};return e[n].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}var o=r(9),i=n(o),u=r(3),a=r(4);window.ccmsSdk||(window.ccmsSdk={}),Object.assign(window.ccmsSdk,{tokenRefreshInterceptor:i["default"],$ccmsAuth:{setAuthFailedBehavior:u.setAuthFailedBehavior,setRefreshTokenUrl:u.setRefreshTokenUrl,getRequestCredential:a.getRequestCredential,setRequestCredential:a.setRequestCredential}})},function(e,t){e.exports=angular},,function(e,t,r){"use strict";function n(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function o(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:c;t.execAuthFailure=c=function(t){try{e()}finally{(0,u.removeRequestCredential)()}var n=new TypeError("Unauthorized! Credential was expired or had been removed, pls set it before the get action!");if(console.error(n),"function"!=typeof t.abort){t.status=t.status||401,t.statusText=t.statusText||"Unauthorized!";var o=r(7)["default"];return o.get("$q").reject(t)}t.abort(n)}}function i(e){t.refreshTokenUrl=l=e,a.REQUEST_WHITE_LIST.push(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.refreshTokenUrl=t.execAuthFailure=void 0,t.setAuthFailedBehavior=o,t.setRefreshTokenUrl=i;var u=r(4),a=r(6),s=!1,c=t.execAuthFailure=function(){},l=t.refreshTokenUrl="";t["default"]={request:function(e){var t=(0,u.getRequestCredential)();if(!t)return c({config:e});if(e.headers[a.REQUEST_TOKEN_HEADER]=t.id,t.refreshToken&&a.REQUEST_WHITE_LIST.indexOf(e.url)===-1){var r=a.Date.parse(t.expireTime),n=a.Date.now();if(a.USER_SESSION_AVAILABLE_TIME>=r-n&&r-n>=0)s=!0;else if(r-n<0)return c({config:e})}return e},response:function(e){var t=(0,u.getRequestCredential)(),o=r(7)["default"],i=o.get("$http");return s&&0===i.pendingRequests.length&&(s=!1,i.put(l,t.refreshToken,{headers:n({},a.REQUEST_TOKEN_HEADER,t.id)}).then(function(e){(0,u.setRequestCredential)(e.data)},c)),e}}},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}function o(){return l.parse(c.getItem(d)||s["default"].get(d)||null)}function i(e){c.setItem(d,l.stringify(e))}function u(){c.removeItem(d),s["default"].remove(d)}Object.defineProperty(t,"__esModule",{value:!0}),t.getRequestCredential=o,t.setRequestCredential=i,t.removeRequestCredential=u;var a=r(5),s=n(a),c=window.localStorage,l=window.JSON,d="ccmsRequestCredential"},function(e,t,r){var n,o;!function(i){var u=!1;if(n=i,o="function"==typeof n?n.call(t,r,t,e):n,!(void 0!==o&&(e.exports=o)),u=!0,e.exports=i(),u=!0,!u){var a=window.Cookies,s=window.Cookies=i();s.noConflict=function(){return window.Cookies=a,s}}}(function(){function e(){for(var e=0,t={};e<arguments.length;e++){var r=arguments[e];for(var n in r)t[n]=r[n]}return t}function t(r){function n(t,o,i){var u;if("undefined"!=typeof document){if(arguments.length>1){if(i=e({path:"/"},n.defaults,i),"number"==typeof i.expires){var a=new Date;a.setMilliseconds(a.getMilliseconds()+864e5*i.expires),i.expires=a}try{u=JSON.stringify(o),/^[\{\[]/.test(u)&&(o=u)}catch(s){}return o=r.write?r.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,i.expires?"; expires="+i.expires.toUTCString():"",i.path?"; path="+i.path:"",i.domain?"; domain="+i.domain:"",i.secure?"; secure":""].join("")}t||(u={});for(var c=document.cookie?document.cookie.split("; "):[],l=/(%[0-9A-Z]{2})+/g,d=0;d<c.length;d++){var f=c[d].split("="),p=f.slice(1).join("=");'"'===p.charAt(0)&&(p=p.slice(1,-1));try{var E=f[0].replace(l,decodeURIComponent);if(p=r.read?r.read(p,E):r(p,E)||p.replace(l,decodeURIComponent),this.json)try{p=JSON.parse(p)}catch(s){}if(t===E){u=p;break}t||(u[E]=p)}catch(s){}}return u}}return n.set=n,n.get=function(e){return n.call(n,e)},n.getJSON=function(){return n.apply({json:!0},[].slice.call(arguments))},n.defaults={},n.remove=function(t,r){n(t,"",e(r,{expires:-1}))},n.withConverter=t,n}return t(function(){})})},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.Date=window.Date,t.REQUEST_TOKEN_HEADER="X-TOKEN",t.USER_SESSION_AVAILABLE_TIME=18e5,t.REQUEST_WHITE_LIST=[]},function(e,t,r){"use strict";function n(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=u["default"].element(e).injector();if(t)return t;for(var r=e.childNodes,n=0;n<r.length;n++){var i=o(r[n]);if(i)return i}return null}Object.defineProperty(t,"__esModule",{value:!0}),t.getInjector=o;var i=r(1),u=n(i),a=r(8),s=n(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,r){Object.defineProperty(e,t,{get:function(){return r.apply(this)}})}},function(e,t,r){"use strict";function n(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}Object.defineProperty(t,"__esModule",{value:!0});var o=r(4),i=r(6),u=r(3),a=!1;t["default"]={beforeSend:function(e,t){var r=(0,o.getRequestCredential)();if(!r)return void(0,u.execAuthFailure)(e);if(e.setRequestHeader(i.REQUEST_TOKEN_HEADER,r.id),e[i.REQUEST_TOKEN_HEADER]=r.id,r.refreshToken&&i.REQUEST_WHITE_LIST.indexOf(t.url)===-1){var n=i.Date.parse(r.expireTime),s=i.Date.now();i.USER_SESSION_AVAILABLE_TIME>=n-s&&n-s>=0?a=!0:n-s<0&&(0,u.execAuthFailure)(e)}},complete:function(e){var t=(0,o.getRequestCredential)(),r=window.$;a&&r.active<=1&&(a=!1,e[i.REQUEST_TOKEN_HEADER]=t.id,r.ajax({url:u.refreshTokenUrl,method:"PUT",data:t.refreshToken,headers:n({},i.REQUEST_TOKEN_HEADER,t.id)}).done(function(e){(0,o.setRequestCredential)(JSON.parse(e))}).fail(function(){return(0,u.execAuthFailure)(e)}))}}}]); | ||
!function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={exports:{},id:n,loaded:!1};return e[n].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}var o=r(9),i=n(o),u=r(3),a=r(4);window.ccmsSdk||(window.ccmsSdk={}),Object.assign(window.ccmsSdk,{tokenRefreshInterceptor:i["default"],$ccmsAuth:{setAuthFailedBehavior:u.setAuthFailedBehavior,setRefreshTokenUrl:u.setRefreshTokenUrl,getRequestCredential:a.getRequestCredential,setRequestCredential:a.setRequestCredential}})},function(e,t){e.exports=angular},,function(e,t,r){"use strict";function n(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function o(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:c;t.execAuthFailure=c=function(t){try{e()}finally{(0,u.removeRequestCredential)()}var n=new TypeError("Unauthorized! Credential was expired or had been removed, pls set it before the get action!");if(console.error(n),"function"!=typeof t.abort){t.status=t.status||401,t.statusText=t.statusText||"Unauthorized!";var o=r(7)["default"];return o.get("$q").reject(t)}t.abort(n)}}function i(e){t.refreshTokenUrl=l=e,a.REQUEST_WHITE_LIST.push(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.refreshTokenUrl=t.execAuthFailure=void 0,t.setAuthFailedBehavior=o,t.setRefreshTokenUrl=i;var u=r(4),a=r(6),s=!1,c=t.execAuthFailure=function(){},l=t.refreshTokenUrl="";t["default"]={request:function(e){var t=(0,u.getRequestCredential)();if(!t)return c({config:e});if(e.headers[a.REQUEST_TOKEN_HEADER]=t.id,t.refreshToken&&a.REQUEST_WHITE_LIST.indexOf(e.url)===-1){var r=a.Date.parse(t.expireTime),n=a.Date.now();if(a.USER_SESSION_AVAILABLE_TIME>=r-n&&r-n>=0)s=!0;else if(r-n<0)return c({config:e})}return e},response:function(e){var t=(0,u.getRequestCredential)(),o=r(7)["default"],i=o.get("$http");return s&&0===i.pendingRequests.length&&(s=!1,i.put(l,t.refreshToken,{headers:n({},a.REQUEST_TOKEN_HEADER,t.id)}).then(function(e){(0,u.setRequestCredential)(e.data)},c)),e}}},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}function o(){var e=null;return e=window.self!==window.top?s["default"].get(d)||null:c.getItem(d)||null,l.parse(e)}function i(e){c.setItem(d,l.stringify(e))}function u(){c.removeItem(d),s["default"].remove(d)}Object.defineProperty(t,"__esModule",{value:!0}),t.getRequestCredential=o,t.setRequestCredential=i,t.removeRequestCredential=u;var a=r(5),s=n(a),c=window.localStorage,l=window.JSON,d="ccmsRequestCredential"},function(e,t,r){var n,o;!function(i){var u=!1;if(n=i,o="function"==typeof n?n.call(t,r,t,e):n,!(void 0!==o&&(e.exports=o)),u=!0,e.exports=i(),u=!0,!u){var a=window.Cookies,s=window.Cookies=i();s.noConflict=function(){return window.Cookies=a,s}}}(function(){function e(){for(var e=0,t={};e<arguments.length;e++){var r=arguments[e];for(var n in r)t[n]=r[n]}return t}function t(r){function n(t,o,i){var u;if("undefined"!=typeof document){if(arguments.length>1){if(i=e({path:"/"},n.defaults,i),"number"==typeof i.expires){var a=new Date;a.setMilliseconds(a.getMilliseconds()+864e5*i.expires),i.expires=a}try{u=JSON.stringify(o),/^[\{\[]/.test(u)&&(o=u)}catch(s){}return o=r.write?r.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,i.expires?"; expires="+i.expires.toUTCString():"",i.path?"; path="+i.path:"",i.domain?"; domain="+i.domain:"",i.secure?"; secure":""].join("")}t||(u={});for(var c=document.cookie?document.cookie.split("; "):[],l=/(%[0-9A-Z]{2})+/g,d=0;d<c.length;d++){var f=c[d].split("="),p=f.slice(1).join("=");'"'===p.charAt(0)&&(p=p.slice(1,-1));try{var E=f[0].replace(l,decodeURIComponent);if(p=r.read?r.read(p,E):r(p,E)||p.replace(l,decodeURIComponent),this.json)try{p=JSON.parse(p)}catch(s){}if(t===E){u=p;break}t||(u[E]=p)}catch(s){}}return u}}return n.set=n,n.get=function(e){return n.call(n,e)},n.getJSON=function(){return n.apply({json:!0},[].slice.call(arguments))},n.defaults={},n.remove=function(t,r){n(t,"",e(r,{expires:-1}))},n.withConverter=t,n}return t(function(){})})},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.Date=window.Date,t.REQUEST_TOKEN_HEADER="X-TOKEN",t.USER_SESSION_AVAILABLE_TIME=18e5,t.REQUEST_WHITE_LIST=[]},function(e,t,r){"use strict";function n(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=u["default"].element(e).injector();if(t)return t;for(var r=e.childNodes,n=0;n<r.length;n++){var i=o(r[n]);if(i)return i}return null}Object.defineProperty(t,"__esModule",{value:!0}),t.getInjector=o;var i=r(1),u=n(i),a=r(8),s=n(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,r){Object.defineProperty(e,t,{get:function(){return r.apply(this)}})}},function(e,t,r){"use strict";function n(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}Object.defineProperty(t,"__esModule",{value:!0});var o=r(4),i=r(6),u=r(3),a=!1;t["default"]={beforeSend:function(e,t){var r=(0,o.getRequestCredential)();if(!r)return void(0,u.execAuthFailure)(e);if(e.setRequestHeader(i.REQUEST_TOKEN_HEADER,r.id),e[i.REQUEST_TOKEN_HEADER]=r.id,r.refreshToken&&i.REQUEST_WHITE_LIST.indexOf(t.url)===-1){var n=i.Date.parse(r.expireTime),s=i.Date.now();i.USER_SESSION_AVAILABLE_TIME>=n-s&&n-s>=0?a=!0:n-s<0&&(0,u.execAuthFailure)(e)}},complete:function(e){var t=(0,o.getRequestCredential)(),r=window.$;a&&r.active<=1&&(a=!1,e[i.REQUEST_TOKEN_HEADER]=t.id,r.ajax({url:u.refreshTokenUrl,method:"PUT",data:t.refreshToken,headers:n({},i.REQUEST_TOKEN_HEADER,t.id)}).done(function(e){(0,o.setRequestCredential)(JSON.parse(e))}).fail(function(){return(0,u.execAuthFailure)(e)}))}}}]); | ||
//# sourceMappingURL=interceptor-jq.min.js.map |
{ | ||
"name": "ccms-sdk", | ||
"version": "2.1.1", | ||
"version": "2.1.2", | ||
"description": "ccms fe sdk written by es2015+", | ||
"main": "./index.js", | ||
"scripts": { | ||
"build": "rm -fr lib && NODE_ENV=production babel src --out-dir lib --ignore **/__tests__,shell.js & webpack --config webpack-build.config.js && cp -R es5 lib && cp package.json lib/package.json", | ||
"build": "rm -fr lib && NODE_ENV=production babel src --out-dir lib --ignore **/__tests__,shell.js,shell-jq.js & webpack --config webpack-build.config.js && cp -R es5 lib && cp package.json lib/package.json", | ||
"codecheck": "NODE_EVN=test eslint src", | ||
@@ -9,0 +9,0 @@ "prepush": "npm test", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
129775
14
1272