Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ccms-sdk

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ccms-sdk - npm Package Compare versions

Comparing version 4.2.0 to 4.3.0

18

es5/ccms-sdk.js

@@ -472,3 +472,3 @@ /******/ (function(modules) { // webpackBootstrap

/* 6 */
/***/ (function(module, exports) {
/***/ (function(module, exports, __webpack_require__) {

@@ -480,8 +480,11 @@ 'use strict';

});
/**
* @author qix
* @homepage https://github.com/qixman/
* @since 2016-10-21
*/
exports.CREDENTIAL_KEY_MAPPER = exports.REQUEST_WHITE_LIST = exports.USER_SESSION_AVAILABLE_TIME = exports.REQUEST_TOKEN_VALUE = exports.REQUEST_TOKEN_HEADER = exports.noop = exports.Date = undefined;
var _credentials = __webpack_require__(4);
var credential = (0, _credentials.getRequestCredential)(); /**
* @author qix
* @homepage https://github.com/qixman/
* @since 2016-10-21
*/
var Date = exports.Date = window.Date;

@@ -493,3 +496,4 @@ var noop = exports.noop = function noop() {};

};
var USER_SESSION_AVAILABLE_TIME = exports.USER_SESSION_AVAILABLE_TIME = 30 * 60 * 1000;
// export const USER_SESSION_AVAILABLE_TIME = 30 * 60 * 1000;
var USER_SESSION_AVAILABLE_TIME = exports.USER_SESSION_AVAILABLE_TIME = credential && credential['expires_in'] ? credential['expires_in'] * 1000 / 2 : 30 * 60 * 1000;
var REQUEST_WHITE_LIST = exports.REQUEST_WHITE_LIST = [];

@@ -496,0 +500,0 @@ var CREDENTIAL_KEY_MAPPER = exports.CREDENTIAL_KEY_MAPPER = {

@@ -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}}Object.defineProperty(t,"__esModule",{value:!0});var o=r(1),i=n(o),u=r(2),s=n(u);t.default=i.default.module("ccms.sdk",[s.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 o=r(1),i=n(o),u=r(3),s=n(u),a=r(9),c=n(a),l=r(4);t.default=i.default.module("ccms.utils.interceptors",[]).constant("ccmsTokenRefreshInterceptor",s.default).constant("$ccmsAuth",{getRequestCredential:l.getRequestCredential,setRequestCredential:l.setRequestCredential,setAuthFailedBehavior:u.setAuthFailedBehavior,setRefreshTokenUrl:u.setRefreshTokenUrl}).constant("apiRequestPrefixInterceptor",{origin:c.default,setApiRequestPrefix:a.setApiRequestPrefix}).name},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,s.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),s=r(6),a=!1,c=t.execAuthFailure=function(){},l=t.refreshTokenUrl="";t.default={request:function(e){var t=(0,u.getRequestCredential)(),r=s.CREDENTIAL_KEY_MAPPER.accessToken,n=s.CREDENTIAL_KEY_MAPPER.refreshToken,o=s.CREDENTIAL_KEY_MAPPER.expireTime;if(!t)return c({config:e});if(e.headers[s.REQUEST_TOKEN_HEADER]=(0,s.REQUEST_TOKEN_VALUE)(t[r]),t[n]&&s.REQUEST_WHITE_LIST.indexOf(e.url)===-1){var i=1e3*t[o],l=s.Date.now();if(s.USER_SESSION_AVAILABLE_TIME>=i-l&&i-l>=0)a=!0;else if(i-l<0)return c({config:e})}return e},response:function(e){var t=(0,u.getRequestCredential)(),o=s.CREDENTIAL_KEY_MAPPER.accessToken,i=s.CREDENTIAL_KEY_MAPPER.refreshToken,f=r(7).default,d=f.get("$http"),p=f.get("$httpParamSerializerJQLike");return a&&0===d.pendingRequests.length&&(a=!1,d.post(l,p({refresh_token:t[i],grant_type:"refresh_token"}),{headers:n({"Content-Type":"application/x-www-form-urlencoded"},s.REQUEST_TOKEN_HEADER,(0,s.REQUEST_TOKEN_VALUE)(t[o]))}).then(function(e){(0,u.setRequestCredential)(e.data)},c).catch(function(e){return console.error(e)})),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?a.default.get(f)||null:c.getItem(f)||null,l.parse(e)}function i(e){c.setItem(f,l.stringify(e)),a.default.set(f,l.stringify(e))}function u(){c.removeItem(f),a.default.remove(f)}Object.defineProperty(t,"__esModule",{value:!0}),t.getRequestCredential=o,t.setRequestCredential=i,t.removeRequestCredential=u;var s=r(5),a=n(s),c=window.localStorage,l=window.JSON,f="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 s=window.Cookies,a=window.Cookies=i();a.noConflict=function(){return window.Cookies=s,a}}}(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 s=new Date;s.setMilliseconds(s.getMilliseconds()+864e5*i.expires),i.expires=s}i.expires=i.expires?i.expires.toUTCString():"";try{u=JSON.stringify(o),/^[\{\[]/.test(u)&&(o=u)}catch(e){}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);var a="";for(var c in i)i[c]&&(a+="; "+c,i[c]!==!0&&(a+="="+i[c]));return document.cookie=t+"="+o+a}t||(u={});for(var l=document.cookie?document.cookie.split("; "):[],f=/(%[0-9A-Z]{2})+/g,d=0;d<l.length;d++){var p=l[d].split("="),E=p.slice(1).join("=");'"'===E.charAt(0)&&(E=E.slice(1,-1));try{var _=p[0].replace(f,decodeURIComponent);if(E=r.read?r.read(E,_):r(E,_)||E.replace(f,decodeURIComponent),this.json)try{E=JSON.parse(E)}catch(e){}if(t===_){u=E;break}t||(u[_]=E)}catch(e){}}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.noop=function(){},t.REQUEST_TOKEN_HEADER="Authorization",t.REQUEST_TOKEN_VALUE=function(e){return"Bearer "+e},t.USER_SESSION_AVAILABLE_TIME=18e5,t.REQUEST_WHITE_LIST=[],t.CREDENTIAL_KEY_MAPPER={accessToken:"access_token",refreshToken:"refresh_token",expireTime:"expire_time"}},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]?arguments[0]:document.querySelector("[ng-app]")||document.documentElement,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),s=r(8),a=n(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,r){Object.defineProperty(e,t,{get:function(){return r.apply(this)}})}},function(e,t){"use strict";function r(e){u=e}Object.defineProperty(t,"__esModule",{value:!0}),t.setApiRequestPrefix=r;var n=/^(?!.*\.\w*(\?.*)?$).+$/,o=function(e){return n.test(e)},i=function(e){return!/^(http|https):\/\//.test(e)},u="";t.default={request:function(e){var t=e.url;return i(t)&&o(t)&&(e.url=u+t),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}}Object.defineProperty(t,"__esModule",{value:!0});var o=r(1),i=n(o),u=r(2),s=n(u);t.default=i.default.module("ccms.sdk",[s.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 o=r(1),i=n(o),u=r(3),s=n(u),a=r(9),c=n(a),l=r(4);t.default=i.default.module("ccms.utils.interceptors",[]).constant("ccmsTokenRefreshInterceptor",s.default).constant("$ccmsAuth",{getRequestCredential:l.getRequestCredential,setRequestCredential:l.setRequestCredential,setAuthFailedBehavior:u.setAuthFailedBehavior,setRefreshTokenUrl:u.setRefreshTokenUrl}).constant("apiRequestPrefixInterceptor",{origin:c.default,setApiRequestPrefix:a.setApiRequestPrefix}).name},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,s.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),s=r(6),a=!1,c=t.execAuthFailure=function(){},l=t.refreshTokenUrl="";t.default={request:function(e){var t=(0,u.getRequestCredential)(),r=s.CREDENTIAL_KEY_MAPPER.accessToken,n=s.CREDENTIAL_KEY_MAPPER.refreshToken,o=s.CREDENTIAL_KEY_MAPPER.expireTime;if(!t)return c({config:e});if(e.headers[s.REQUEST_TOKEN_HEADER]=(0,s.REQUEST_TOKEN_VALUE)(t[r]),t[n]&&s.REQUEST_WHITE_LIST.indexOf(e.url)===-1){var i=1e3*t[o],l=s.Date.now();if(s.USER_SESSION_AVAILABLE_TIME>=i-l&&i-l>=0)a=!0;else if(i-l<0)return c({config:e})}return e},response:function(e){var t=(0,u.getRequestCredential)(),o=s.CREDENTIAL_KEY_MAPPER.accessToken,i=s.CREDENTIAL_KEY_MAPPER.refreshToken,f=r(7).default,d=f.get("$http"),E=f.get("$httpParamSerializerJQLike");return a&&0===d.pendingRequests.length&&(a=!1,d.post(l,E({refresh_token:t[i],grant_type:"refresh_token"}),{headers:n({"Content-Type":"application/x-www-form-urlencoded"},s.REQUEST_TOKEN_HEADER,(0,s.REQUEST_TOKEN_VALUE)(t[o]))}).then(function(e){(0,u.setRequestCredential)(e.data)},c).catch(function(e){return console.error(e)})),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?a.default.get(f)||null:c.getItem(f)||null,l.parse(e)}function i(e){c.setItem(f,l.stringify(e)),a.default.set(f,l.stringify(e))}function u(){c.removeItem(f),a.default.remove(f)}Object.defineProperty(t,"__esModule",{value:!0}),t.getRequestCredential=o,t.setRequestCredential=i,t.removeRequestCredential=u;var s=r(5),a=n(s),c=window.localStorage,l=window.JSON,f="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 s=window.Cookies,a=window.Cookies=i();a.noConflict=function(){return window.Cookies=s,a}}}(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 s=new Date;s.setMilliseconds(s.getMilliseconds()+864e5*i.expires),i.expires=s}i.expires=i.expires?i.expires.toUTCString():"";try{u=JSON.stringify(o),/^[\{\[]/.test(u)&&(o=u)}catch(e){}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);var a="";for(var c in i)i[c]&&(a+="; "+c,i[c]!==!0&&(a+="="+i[c]));return document.cookie=t+"="+o+a}t||(u={});for(var l=document.cookie?document.cookie.split("; "):[],f=/(%[0-9A-Z]{2})+/g,d=0;d<l.length;d++){var E=l[d].split("="),p=E.slice(1).join("=");'"'===p.charAt(0)&&(p=p.slice(1,-1));try{var _=E[0].replace(f,decodeURIComponent);if(p=r.read?r.read(p,_):r(p,_)||p.replace(f,decodeURIComponent),this.json)try{p=JSON.parse(p)}catch(e){}if(t===_){u=p;break}t||(u[_]=p)}catch(e){}}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,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CREDENTIAL_KEY_MAPPER=t.REQUEST_WHITE_LIST=t.USER_SESSION_AVAILABLE_TIME=t.REQUEST_TOKEN_VALUE=t.REQUEST_TOKEN_HEADER=t.noop=t.Date=void 0;var n=r(4),o=(0,n.getRequestCredential)();t.Date=window.Date,t.noop=function(){},t.REQUEST_TOKEN_HEADER="Authorization",t.REQUEST_TOKEN_VALUE=function(e){return"Bearer "+e},t.USER_SESSION_AVAILABLE_TIME=o&&o.expires_in?1e3*o.expires_in/2:18e5,t.REQUEST_WHITE_LIST=[],t.CREDENTIAL_KEY_MAPPER={accessToken:"access_token",refreshToken:"refresh_token",expireTime:"expire_time"}},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]?arguments[0]:document.querySelector("[ng-app]")||document.documentElement,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),s=r(8),a=n(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,r){Object.defineProperty(e,t,{get:function(){return r.apply(this)}})}},function(e,t){"use strict";function r(e){u=e}Object.defineProperty(t,"__esModule",{value:!0}),t.setApiRequestPrefix=r;var n=/^(?!.*\.\w*(\?.*)?$).+$/,o=function(e){return n.test(e)},i=function(e){return!/^(http|https):\/\//.test(e)},u="";t.default={request:function(e){var t=e.url;return i(t)&&o(t)&&(e.url=u+t),e}}}]);
//# sourceMappingURL=ccms-sdk.min.js.map

@@ -440,3 +440,3 @@ /******/ (function(modules) { // webpackBootstrap

/* 6 */
/***/ (function(module, exports) {
/***/ (function(module, exports, __webpack_require__) {

@@ -448,8 +448,11 @@ 'use strict';

});
/**
* @author qix
* @homepage https://github.com/qixman/
* @since 2016-10-21
*/
exports.CREDENTIAL_KEY_MAPPER = exports.REQUEST_WHITE_LIST = exports.USER_SESSION_AVAILABLE_TIME = exports.REQUEST_TOKEN_VALUE = exports.REQUEST_TOKEN_HEADER = exports.noop = exports.Date = undefined;
var _credentials = __webpack_require__(4);
var credential = (0, _credentials.getRequestCredential)(); /**
* @author qix
* @homepage https://github.com/qixman/
* @since 2016-10-21
*/
var Date = exports.Date = window.Date;

@@ -461,3 +464,4 @@ var noop = exports.noop = function noop() {};

};
var USER_SESSION_AVAILABLE_TIME = exports.USER_SESSION_AVAILABLE_TIME = 30 * 60 * 1000;
// export const USER_SESSION_AVAILABLE_TIME = 30 * 60 * 1000;
var USER_SESSION_AVAILABLE_TIME = exports.USER_SESSION_AVAILABLE_TIME = credential && credential['expires_in'] ? credential['expires_in'] * 1000 / 2 : 30 * 60 * 1000;
var REQUEST_WHITE_LIST = exports.REQUEST_WHITE_LIST = [];

@@ -464,0 +468,0 @@ var CREDENTIAL_KEY_MAPPER = exports.CREDENTIAL_KEY_MAPPER = {

@@ -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(10),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)(),r=a.CREDENTIAL_KEY_MAPPER.accessToken,n=a.CREDENTIAL_KEY_MAPPER.refreshToken,o=a.CREDENTIAL_KEY_MAPPER.expireTime;if(!t)return c({config:e});if(e.headers[a.REQUEST_TOKEN_HEADER]=(0,a.REQUEST_TOKEN_VALUE)(t[r]),t[n]&&a.REQUEST_WHITE_LIST.indexOf(e.url)===-1){var i=1e3*t[o],l=a.Date.now();if(a.USER_SESSION_AVAILABLE_TIME>=i-l&&i-l>=0)s=!0;else if(i-l<0)return c({config:e})}return e},response:function(e){var t=(0,u.getRequestCredential)(),o=a.CREDENTIAL_KEY_MAPPER.accessToken,i=a.CREDENTIAL_KEY_MAPPER.refreshToken,f=r(7).default,E=f.get("$http"),d=f.get("$httpParamSerializerJQLike");return s&&0===E.pendingRequests.length&&(s=!1,E.post(l,d({refresh_token:t[i],grant_type:"refresh_token"}),{headers:n({"Content-Type":"application/x-www-form-urlencoded"},a.REQUEST_TOKEN_HEADER,(0,a.REQUEST_TOKEN_VALUE)(t[o]))}).then(function(e){(0,u.setRequestCredential)(e.data)},c).catch(function(e){return console.error(e)})),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(f)||null:c.getItem(f)||null,l.parse(e)}function i(e){c.setItem(f,l.stringify(e)),s.default.set(f,l.stringify(e))}function u(){c.removeItem(f),s.default.remove(f)}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,f="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}i.expires=i.expires?i.expires.toUTCString():"";try{u=JSON.stringify(o),/^[\{\[]/.test(u)&&(o=u)}catch(e){}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);var s="";for(var c in i)i[c]&&(s+="; "+c,i[c]!==!0&&(s+="="+i[c]));return document.cookie=t+"="+o+s}t||(u={});for(var l=document.cookie?document.cookie.split("; "):[],f=/(%[0-9A-Z]{2})+/g,E=0;E<l.length;E++){var d=l[E].split("="),_=d.slice(1).join("=");'"'===_.charAt(0)&&(_=_.slice(1,-1));try{var p=d[0].replace(f,decodeURIComponent);if(_=r.read?r.read(_,p):r(_,p)||_.replace(f,decodeURIComponent),this.json)try{_=JSON.parse(_)}catch(e){}if(t===p){u=_;break}t||(u[p]=_)}catch(e){}}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.noop=function(){},t.REQUEST_TOKEN_HEADER="Authorization",t.REQUEST_TOKEN_VALUE=function(e){return"Bearer "+e},t.USER_SESSION_AVAILABLE_TIME=18e5,t.REQUEST_WHITE_LIST=[],t.CREDENTIAL_KEY_MAPPER={accessToken:"access_token",refreshToken:"refresh_token",expireTime:"expire_time"}},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]?arguments[0]:document.querySelector("[ng-app]")||document.documentElement,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)(),n=i.CREDENTIAL_KEY_MAPPER.accessToken,s=i.CREDENTIAL_KEY_MAPPER.refreshToken,c=i.CREDENTIAL_KEY_MAPPER.expireTime;if(!r)return void(0,u.execAuthFailure)(e);if(e.setRequestHeader(i.REQUEST_TOKEN_HEADER,(0,i.REQUEST_TOKEN_VALUE)(r[n])),e[i.REQUEST_TOKEN_HEADER]=(0,i.REQUEST_TOKEN_VALUE)(r[n]),r[s]&&i.REQUEST_WHITE_LIST.indexOf(t.url)===-1){var l=1e3*r[c],f=i.Date.now();i.USER_SESSION_AVAILABLE_TIME>=l-f&&l-f>=0?a=!0:l-f<0&&(0,u.execAuthFailure)(e)}},complete:function(e){var t=(0,o.getRequestCredential)(),r=i.CREDENTIAL_KEY_MAPPER.accessToken,s=i.CREDENTIAL_KEY_MAPPER.refreshToken,c=window.$;a&&c.active<=1&&(a=!1,c.ajax({url:u.refreshTokenUrl,type:"POST",data:{refresh_token:t[s],grant_type:"refresh_token"},headers:n({"Content-Type":"application/x-www-form-urlencoded"},i.REQUEST_TOKEN_HEADER,(0,i.REQUEST_TOKEN_VALUE)(t[r]))}).done(function(e){(0,o.setRequestCredential)(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(10),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=E=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(){},E=t.refreshTokenUrl="";t.default={request:function(e){var t=(0,u.getRequestCredential)(),r=a.CREDENTIAL_KEY_MAPPER.accessToken,n=a.CREDENTIAL_KEY_MAPPER.refreshToken,o=a.CREDENTIAL_KEY_MAPPER.expireTime;if(!t)return c({config:e});if(e.headers[a.REQUEST_TOKEN_HEADER]=(0,a.REQUEST_TOKEN_VALUE)(t[r]),t[n]&&a.REQUEST_WHITE_LIST.indexOf(e.url)===-1){var i=1e3*t[o],E=a.Date.now();if(a.USER_SESSION_AVAILABLE_TIME>=i-E&&i-E>=0)s=!0;else if(i-E<0)return c({config:e})}return e},response:function(e){var t=(0,u.getRequestCredential)(),o=a.CREDENTIAL_KEY_MAPPER.accessToken,i=a.CREDENTIAL_KEY_MAPPER.refreshToken,l=r(7).default,f=l.get("$http"),d=l.get("$httpParamSerializerJQLike");return s&&0===f.pendingRequests.length&&(s=!1,f.post(E,d({refresh_token:t[i],grant_type:"refresh_token"}),{headers:n({"Content-Type":"application/x-www-form-urlencoded"},a.REQUEST_TOKEN_HEADER,(0,a.REQUEST_TOKEN_VALUE)(t[o]))}).then(function(e){(0,u.setRequestCredential)(e.data)},c).catch(function(e){return console.error(e)})),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(l)||null:c.getItem(l)||null,E.parse(e)}function i(e){c.setItem(l,E.stringify(e)),s.default.set(l,E.stringify(e))}function u(){c.removeItem(l),s.default.remove(l)}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,E=window.JSON,l="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}i.expires=i.expires?i.expires.toUTCString():"";try{u=JSON.stringify(o),/^[\{\[]/.test(u)&&(o=u)}catch(e){}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);var s="";for(var c in i)i[c]&&(s+="; "+c,i[c]!==!0&&(s+="="+i[c]));return document.cookie=t+"="+o+s}t||(u={});for(var E=document.cookie?document.cookie.split("; "):[],l=/(%[0-9A-Z]{2})+/g,f=0;f<E.length;f++){var d=E[f].split("="),_=d.slice(1).join("=");'"'===_.charAt(0)&&(_=_.slice(1,-1));try{var T=d[0].replace(l,decodeURIComponent);if(_=r.read?r.read(_,T):r(_,T)||_.replace(l,decodeURIComponent),this.json)try{_=JSON.parse(_)}catch(e){}if(t===T){u=_;break}t||(u[T]=_)}catch(e){}}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,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CREDENTIAL_KEY_MAPPER=t.REQUEST_WHITE_LIST=t.USER_SESSION_AVAILABLE_TIME=t.REQUEST_TOKEN_VALUE=t.REQUEST_TOKEN_HEADER=t.noop=t.Date=void 0;var n=r(4),o=(0,n.getRequestCredential)();t.Date=window.Date,t.noop=function(){},t.REQUEST_TOKEN_HEADER="Authorization",t.REQUEST_TOKEN_VALUE=function(e){return"Bearer "+e},t.USER_SESSION_AVAILABLE_TIME=o&&o.expires_in?1e3*o.expires_in/2:18e5,t.REQUEST_WHITE_LIST=[],t.CREDENTIAL_KEY_MAPPER={accessToken:"access_token",refreshToken:"refresh_token",expireTime:"expire_time"}},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]?arguments[0]:document.querySelector("[ng-app]")||document.documentElement,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)(),n=i.CREDENTIAL_KEY_MAPPER.accessToken,s=i.CREDENTIAL_KEY_MAPPER.refreshToken,c=i.CREDENTIAL_KEY_MAPPER.expireTime;if(!r)return void(0,u.execAuthFailure)(e);if(e.setRequestHeader(i.REQUEST_TOKEN_HEADER,(0,i.REQUEST_TOKEN_VALUE)(r[n])),e[i.REQUEST_TOKEN_HEADER]=(0,i.REQUEST_TOKEN_VALUE)(r[n]),r[s]&&i.REQUEST_WHITE_LIST.indexOf(t.url)===-1){var E=1e3*r[c],l=i.Date.now();i.USER_SESSION_AVAILABLE_TIME>=E-l&&E-l>=0?a=!0:E-l<0&&(0,u.execAuthFailure)(e)}},complete:function(e){var t=(0,o.getRequestCredential)(),r=i.CREDENTIAL_KEY_MAPPER.accessToken,s=i.CREDENTIAL_KEY_MAPPER.refreshToken,c=window.$;a&&c.active<=1&&(a=!1,c.ajax({url:u.refreshTokenUrl,type:"POST",data:{refresh_token:t[s],grant_type:"refresh_token"},headers:n({"Content-Type":"application/x-www-form-urlencoded"},i.REQUEST_TOKEN_HEADER,(0,i.REQUEST_TOKEN_VALUE)(t[r]))}).done(function(e){(0,o.setRequestCredential)(e)}).fail(function(){return(0,u.execAuthFailure)(e)}))}}}]);
//# sourceMappingURL=interceptor-jq.min.js.map

@@ -6,8 +6,11 @@ 'use strict';

});
/**
* @author qix
* @homepage https://github.com/qixman/
* @since 2016-10-21
*/
exports.CREDENTIAL_KEY_MAPPER = exports.REQUEST_WHITE_LIST = exports.USER_SESSION_AVAILABLE_TIME = exports.REQUEST_TOKEN_VALUE = exports.REQUEST_TOKEN_HEADER = exports.noop = exports.Date = undefined;
var _credentials = require('../credentials');
var credential = (0, _credentials.getRequestCredential)(); /**
* @author qix
* @homepage https://github.com/qixman/
* @since 2016-10-21
*/
var Date = exports.Date = window.Date;

@@ -19,3 +22,4 @@ var noop = exports.noop = function noop() {};

};
var USER_SESSION_AVAILABLE_TIME = exports.USER_SESSION_AVAILABLE_TIME = 30 * 60 * 1000;
// export const USER_SESSION_AVAILABLE_TIME = 30 * 60 * 1000;
var USER_SESSION_AVAILABLE_TIME = exports.USER_SESSION_AVAILABLE_TIME = credential && credential['expires_in'] ? credential['expires_in'] * 1000 / 2 : 30 * 60 * 1000;
var REQUEST_WHITE_LIST = exports.REQUEST_WHITE_LIST = [];

@@ -22,0 +26,0 @@ var CREDENTIAL_KEY_MAPPER = exports.CREDENTIAL_KEY_MAPPER = {

{
"name": "ccms-sdk",
"version": "4.2.0",
"version": "4.3.0",
"description": "ccms fe sdk written by es2015+",

@@ -5,0 +5,0 @@ "main": "./index.js",

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc