@c8y/ng1-modules 1016.187.0 → 1016.189.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use strict";function _slicedToArray(t,e){return _arrayWithHoles(t)||_iterableToArrayLimit(t,e)||_unsupportedIterableToArray(t,e)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(t,e){if(t){if("string"==typeof t)return _arrayLikeToArray(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(t,e):void 0}}function _arrayLikeToArray(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function _iterableToArrayLimit(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,a=[],i=!0,u=!1;try{for(n=n.call(t);!(i=(r=n.next()).done)&&(a.push(r.value),!e||a.length!==e);i=!0);}catch(t){u=!0,o=t}finally{try{i||null==n.return||n.return()}finally{if(u)throw o}}return a}}function _arrayWithHoles(t){if(Array.isArray(t))return t}!function(){function t(a,e,n,i,o,u,r,s){var c,l,p,f,h,d,g,y,v,m,k="_tcy8",w="_ocy8",T="TFAToken",A="Basic",S=i.defer(),I=i.defer(),b=/\.html$/,F=/\.json$/,$=document.createElement("a"),L={hasAuth:!1},P=s.appKey,C=A,E=A;function O(t){var e=t;t.startsWith(A)&&(e=t.replace(A,"").trim());var n=r(e).match(/(([^/]*)\/)?([^/:]+):(.+)/);return{tenant:n[2],user:n[3],password:n[4]}}function U(t,e,n){var r="".concat((n?"".concat(n,"/"):"")+t,":").concat(e);return u(r)}function j(t){return t.headers||(t.headers={}),_.defaults(t.headers,Z.headers()),t}function z(){return h.post(d.url("user/logout"),{},{silentError:!0}).then(function(t){return B(),t.data},function(){return B()})}function B(){G(),_.isFunction(s.logout)&&s.logout()}function R(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:A,n={token:e,type:function(t){return t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()}(t)},r=d.url("user/currentUser?auth");if(p=n.token,E=n.type,window.c8y_testing)return i.when(K(n));s.tokenType=t;var o={url:r,silentError:!0,skipInterceptor:!0,headers:{Authorization:n.token?"".concat(n.type," ").concat(n.token):void 0,tfatoken:f,UseXBasic:!0,Accept:"application/vnd.com.nsn.cumulocity.user+json;"}};return h(o).then(d.getResData).then(function(t){return e?function(t,e){var n=O(t.token);return t.token=U(function(t,e){var n=_slicedToArray(t.user.match(/^(.+\$)?(.+)?$/),3),r=n[1],o=n[2];return"".concat(r||"").concat(o?e.id:"")}(n,e),n.password,function(t){return t.self.match(/\/user\/([\w-]+)\//)[1]}(e)),t}(n,t):W()}).then(K)}function K(t){var e=t.token,n=t.type;s.token=e,c=s.token,C=n,M(s.appKey);var r=!(P||s.isLocal)?g.currentAppCached().then(function(t){s.appConfig=_.defaults(s.appConfig||{},t),M(t.key)}):i.when();return function(){o.sessionStorage&&o.sessionStorage.setItem(k,c);o.localStorage.getItem(k)&&o.localStorage.setItem(k,c)}(),r.then(W)}function W(){S.resolve(),t({hasAuth:!0})}function t(t){_.isEqual(t,L)||(L=t,e.$emit("authStateChange",L))}function q(){f=void 0,delete s.TFAToken,V()}function x(t){s.TFAToken=t,H(f=s.TFAToken,!1,T),function(t,e){return n.get("c8ySettings").getSystemOptionValue({category:t,key:e},!1)}("two-factor-authentication","logout-on-browser-termination").then(function(t){H(f,!t,T)})}function G(){q(),delete s.token,S.promise.$$state.status&&(S=i.defer()),t({hasAuth:!1}),D()}function H(t,e,n){o["".concat(e?"local":"session","Storage")].setItem(n,t)}function X(t){return o.localStorage.getItem(t)||o.sessionStorage.getItem(t)||void 0}function M(t){s.appKey=t,P=s.appKey}function D(){o.localStorage.removeItem(k),o.sessionStorage.removeItem(k),o.localStorage.removeItem(w),o.sessionStorage.removeItem(w)}function V(){o.localStorage.removeItem(T),o.sessionStorage.removeItem(T)}function J(){var t=s.token||X(k),e=s.TFAToken||X(T),n=s.tokenType||X(w);return M(s.appKey),e&&x(e),R(t,n).catch(D)}function N(t){l=t}function Q(t){var e=t.headers("tfatoken");return e&&x(e),R(p,E)}function Y(t){var e=_.map(t,function(n){var t={};return t[n.prop]=!1,h({url:d.url("tenant/".concat(n.path)),silentError:!0}).then(function(t){var e={};return e[n.prop]=n.checkFn(t),e}).catch(function(){return t})});return i.all(e).then(function(t){return _.reduce(t,function(t,e){return _.assign(t,e)},{})})}I.resolve(),N(s.passResetToken||function(){if(a.search)return a.search();return{}}().token);var Z={decodeToken:O,encodeToken:U,logout:z,updatePassword:function(t){if(c){var e=O(c),n=U(e.user,t,e.tenant);return m&&m.updateBasicAuth({user:e.user,password:t,tenant:e.tenant}),K({token:n,type:s.tokenType||A})}return i.resolve()},request:function(t){var e,n=t.url,r=function(t){var e=s.baseUrl||"/";if(!t)return!0;$.href=t||"";var n=$.host;return 1<e.length&&-1<t.indexOf(e)||!n||n===function(){var t=a.host(),e=a.port();return 80!==e&&443!==e?[t,e].join(":"):t}()}(n);if(!r||b.test(n)||F.test(n)||t.skipInterceptor)return t;e=r&&!function(t){return!(!t.headers||!t.headers.Authorization)}(t)&&function(t){return!c||!t.noAppKey}(t)?Z.initializing.done?S.promise:i.all([Z.initializing,S.promise]):I.promise;var o=r?_.partial(j,t):function(){return t};return c&&window.c8y_testing?o():e.then(o)},responseError:function(t){_.isFunction(t.headers)&&t.headers("tfatokenexpired")&&L.hasAuth&&z();var e=Boolean(s.token);return 401!==t.status||e||function(){var t=d.url("user/currentUser");return h.get(t,{headers:d.contentHeaders("user",!0),silentError:!0}).then(function(){return!0},function(t){return 401!==t.status})}().then(function(t){t||z()}),i.reject(t)},setAuthToken:R,clearTokens:G,setTFAToken:x,clearTFAToken:q,saveAuthToken:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:A;H(c,t,k),H(e,t,w)},checkSavedTokens:J,setAppKey:M,headers:function(){var t={Authorization:c?"".concat(C," ").concat(c):void 0,tfatoken:f,UseXBasic:!0};return t["X-Cumulocity-Application-Key"]=P,t},resetPasword:function(t){var e={method:"POST",url:d.url("user/passwordReset"),params:{tenantId:t.tenant},data:{email:t.email},silentError:!0};return h(e)},changePasswordWithResetToken:function(t){var e={method:"PUT",url:d.url("user/passwordReset"),params:{tenantId:t.tenant},data:{email:t.email,token:l,newPassword:t.newPassword,passwordStrength:(t.passwordStrength||"").toUpperCase()},silentError:!0};return h(e).then(function(t){return l=void 0,a.url(a.path()),t})},setRecoverPassToken:N,verifyTFACode:function(t){V();var e={url:d.url("user/pin"),data:{pin:t},method:"POST",silentError:!0,headers:{Authorization:"".concat(E||A," ").concat(p),"Content-Type":"application/vnd.com.nsn.cumulocity.user+json;"}};return h(e).then(Q)},getPassword:function(){return c&&O(c).password},getUserFromToken:function(){return O(c).user},getTenantFromToken:function(){return O(c).tenant},mustEnforcePasswordStrength:function(t){return Y([{path:"system/options/password/enforce.strength",prop:"systemLevel",checkFn:function(t){return"true"===(t.data||{}).value}},{path:"security-options/password/strength.validity",prop:"tenantLevel",checkFn:function(t){return"true"===(t.data||{}).value}}]).then(function(t){return t.systemLevel||t.tenantLevel})},getPasswordMinGreenLength:function(t){return Y([{path:"system/options/password/green.min-length",prop:"minGreenLength",checkFn:function(t){return _.parseInt((t.data||{}).value)}}]).then(function(t){return t.minGreenLength})},onSetToken:K,authReady:W,isSupportUser:function(){var t=O(p);return(t?t.user:"").includes("$")},getLoginOptions:function(){return y},whenAuthorized:function(){return S.promise}};return Z.initializing=i.resolve().then(function(){h=n.get("$http"),d=n.get("c8yBase"),g=n.get("c8yApplication"),n.has("c8yAuthBridgeService")&&(m=n.get("c8yAuthBridgeService"))}).then(window.preventInit?function(){}:function(){if(window.c8y_testing)return i.when();var t=[{type:(v=n.get("c8yLoginOptions",[h,d])).loginOptions.BASIC.value}];return v.list({skipInterceptor:!0,silentError:!0,params:{tenantId:d.getParamFromUrl("tenantId",window.location.search)}}).then(function(t){y=t.data.loginOptions},function(){y=t})}).then(function(){return window.c8y_testing?(K({token:s.token,type:s.tokenType||A}),{testing:!0}):s.oauthCode?function(t){D();var e={silentError:!1,url:d.url("tenant/oauth"+"?grant_type=authorization_code".concat(_.get(d.appOption("oauth"),"uriAddition",""))+"&code=".concat(t)),method:"POST",skipInterceptor:!0};return h(e).then(W)}(s.oauthCode):l?(a.search("token",l),G(),{recoverPassword:!0}):s.noSavedTokens?{noSavedTokens:!0}:J()}).finally(function(){Z.initializing.done=!0}),window.c8y_testing&&(o.localStorage||(o.localStorage=window.localStorage),o.sessionStorage||(o.sessionStorage=window.sessionStorage)),Z}t.$inject=["$location","$rootScope","$injector","$q","$window","utoa","atou","info"],angular.module("c8y.core").factory("c8yAuth",t).config(["$httpProvider",function(t){t.interceptors.push("c8yAuth")}])}();
1
+ "use strict";function _slicedToArray(t,e){return _arrayWithHoles(t)||_iterableToArrayLimit(t,e)||_unsupportedIterableToArray(t,e)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(t,e){if(t){if("string"==typeof t)return _arrayLikeToArray(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(t,e):void 0}}function _arrayLikeToArray(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function _iterableToArrayLimit(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,a=[],i=!0,u=!1;try{for(n=n.call(t);!(i=(r=n.next()).done)&&(a.push(r.value),!e||a.length!==e);i=!0);}catch(t){u=!0,o=t}finally{try{i||null==n.return||n.return()}finally{if(u)throw o}}return a}}function _arrayWithHoles(t){if(Array.isArray(t))return t}!function(){function t(a,e,n,i,o,u,r,s){var c,l,p,f,h,d,g,y,v,m,k="_tcy8",w="_ocy8",T="TFAToken",A="Basic",S=i.defer(),I=i.defer(),b=/\.html$/,F=/\.json$/,$=document.createElement("a"),L={hasAuth:!1},P=s.appKey,C=A,E=A,O=!1;function U(t){var e=t;t.startsWith(A)&&(e=t.replace(A,"").trim());var n=r(e).match(/(([^/]*)\/)?([^/:]+):(.+)/);return{tenant:n[2],user:n[3],password:n[4]}}function j(t,e,n){var r="".concat((n?"".concat(n,"/"):"")+t,":").concat(e);return u(r)}function z(t){return t.headers||(t.headers={}),_.defaults(t.headers,tt.headers()),t}function B(){return h.post(d.url("user/logout"),{},{silentError:!0}).then(function(t){return R(),t.data},function(){return R()})}function R(){H(),_.isFunction(s.logout)&&s.logout()}function K(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:A,n={token:e,type:function(t){return t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()}(t)},r=d.url("user/currentUser?auth");if(p=n.token,E=n.type,window.c8y_testing)return i.when(W(n));s.tokenType=t;var o={url:r,silentError:!0,skipInterceptor:!0,headers:{Authorization:n.token?"".concat(n.type," ").concat(n.token):void 0,tfatoken:f,UseXBasic:!0,Accept:"application/vnd.com.nsn.cumulocity.user+json;"}};return h(o).then(d.getResData).then(function(t){return e?function(t,e){var n=U(t.token);return t.token=j(function(t,e){var n=_slicedToArray(t.user.match(/^(.+\$)?(.+)?$/),3),r=n[1],o=n[2];return"".concat(r||"").concat(o?e.id:"")}(n,e),n.password,function(t){return t.self.match(/\/user\/([\w-]+)\//)[1]}(e)),t}(n,t):q()}).then(W)}function W(t){var e=t.token,n=t.type;s.token=e,c=s.token,C=n,D(s.appKey);var r=!(P||s.isLocal)?g.currentAppCached().then(function(t){s.appConfig=_.defaults(s.appConfig||{},t),D(t.key)}):i.when();return function(){o.sessionStorage&&o.sessionStorage.setItem(k,c);o.localStorage.getItem(k)&&o.localStorage.setItem(k,c)}(),r.then(q)}function q(){S.resolve(),t({hasAuth:!0})}function t(t){_.isEqual(t,L)||(L=t,e.$emit("authStateChange",L))}function x(){f=void 0,delete s.TFAToken,J()}function G(t){s.TFAToken=t,X(f=s.TFAToken,!1,T),function(t,e){return n.get("c8ySettings").getSystemOptionValue({category:t,key:e},!1)}("two-factor-authentication","logout-on-browser-termination").then(function(t){X(f,!t,T)})}function H(){x(),delete s.token,S.promise.$$state.status&&(S=i.defer()),t({hasAuth:!1}),V()}function X(t,e,n){o["".concat(e?"local":"session","Storage")].setItem(n,t)}function M(t){return o.localStorage.getItem(t)||o.sessionStorage.getItem(t)||void 0}function D(t){s.appKey=t,P=s.appKey}function V(){o.localStorage.removeItem(k),o.sessionStorage.removeItem(k),o.localStorage.removeItem(w),o.sessionStorage.removeItem(w)}function J(){o.localStorage.removeItem(T),o.sessionStorage.removeItem(T)}function N(){var t=s.token||M(k),e=s.TFAToken||M(T),n=s.tokenType||M(w);return D(s.appKey),e&&G(e),K(t,n).catch(V)}function Q(t){l=t}function Y(t){var e=t.headers("tfatoken");return e&&G(e),K(p,E)}function Z(t){var e=_.map(t,function(n){var t={};return t[n.prop]=!1,h({url:d.url("tenant/".concat(n.path)),silentError:!0}).then(function(t){var e={};return e[n.prop]=n.checkFn(t),e}).catch(function(){return t})});return i.all(e).then(function(t){return _.reduce(t,function(t,e){return _.assign(t,e)},{})})}I.resolve(),Q(s.passResetToken||function(){if(a.search)return a.search();return{}}().token);var tt={decodeToken:U,encodeToken:j,logout:B,updatePassword:function(t){if(c){var e=U(c),n=j(e.user,t,e.tenant);return m&&m.updateBasicAuth({user:e.user,password:t,tenant:e.tenant}),W({token:n,type:s.tokenType||A})}return i.resolve()},request:function(t){var e,n=t.url,r=function(t){var e=s.baseUrl||"/";if(!t)return!0;$.href=t||"";var n=$.host;return 1<e.length&&-1<t.indexOf(e)||!n||n===function(){var t=a.host(),e=a.port();return 80!==e&&443!==e?[t,e].join(":"):t}()}(n);if(!r||b.test(n)||F.test(n)||t.skipInterceptor)return t;e=r&&!function(t){return!(!t.headers||!t.headers.Authorization)}(t)&&function(t){return!c||!t.noAppKey}(t)?tt.initializing.done?S.promise:i.all([tt.initializing,S.promise]):I.promise;var o=r?_.partial(z,t):function(){return t};return c&&window.c8y_testing?o():e.then(o)},responseError:function(t){_.isFunction(t.headers)&&t.headers("tfatokenexpired")&&L.hasAuth&&B();var e=Boolean(s.token);return 401!==t.status||e||O||function(){var t=d.url("user/currentUser");return h.get(t,{headers:d.contentHeaders("user",!0),silentError:!0}).then(function(){return!0},function(t){return 401!==t.status})}().then(function(t){t||(O=!0,B())}),i.reject(t)},setAuthToken:K,clearTokens:H,setTFAToken:G,clearTFAToken:x,saveAuthToken:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:A;X(c,t,k),X(e,t,w)},checkSavedTokens:N,setAppKey:D,headers:function(){var t={Authorization:c?"".concat(C," ").concat(c):void 0,tfatoken:f,UseXBasic:!0};return t["X-Cumulocity-Application-Key"]=P,t},resetPasword:function(t){var e={method:"POST",url:d.url("user/passwordReset"),params:{tenantId:t.tenant},data:{email:t.email},silentError:!0};return h(e)},changePasswordWithResetToken:function(t){var e={method:"PUT",url:d.url("user/passwordReset"),params:{tenantId:t.tenant},data:{email:t.email,token:l,newPassword:t.newPassword,passwordStrength:(t.passwordStrength||"").toUpperCase()},silentError:!0};return h(e).then(function(t){return l=void 0,a.url(a.path()),t})},setRecoverPassToken:Q,verifyTFACode:function(t){J();var e={url:d.url("user/pin"),data:{pin:t},method:"POST",silentError:!0,headers:{Authorization:"".concat(E||A," ").concat(p),"Content-Type":"application/vnd.com.nsn.cumulocity.user+json;"}};return h(e).then(Y)},getPassword:function(){return c&&U(c).password},getUserFromToken:function(){return U(c).user},getTenantFromToken:function(){return U(c).tenant},mustEnforcePasswordStrength:function(t){return Z([{path:"system/options/password/enforce.strength",prop:"systemLevel",checkFn:function(t){return"true"===(t.data||{}).value}},{path:"security-options/password/strength.validity",prop:"tenantLevel",checkFn:function(t){return"true"===(t.data||{}).value}}]).then(function(t){return t.systemLevel||t.tenantLevel})},getPasswordMinGreenLength:function(t){return Z([{path:"system/options/password/green.min-length",prop:"minGreenLength",checkFn:function(t){return _.parseInt((t.data||{}).value)}}]).then(function(t){return t.minGreenLength})},onSetToken:W,authReady:q,isSupportUser:function(){var t=U(p);return(t?t.user:"").includes("$")},getLoginOptions:function(){return y},whenAuthorized:function(){return S.promise}};return tt.initializing=i.resolve().then(function(){h=n.get("$http"),d=n.get("c8yBase"),g=n.get("c8yApplication"),n.has("c8yAuthBridgeService")&&(m=n.get("c8yAuthBridgeService"))}).then(window.preventInit?function(){}:function(){if(window.c8y_testing)return i.when();var t=[{type:(v=n.get("c8yLoginOptions",[h,d])).loginOptions.BASIC.value}];return v.list({skipInterceptor:!0,silentError:!0,params:{tenantId:d.getParamFromUrl("tenantId",window.location.search)}}).then(function(t){y=t.data.loginOptions},function(){y=t})}).then(function(){return window.c8y_testing?(W({token:s.token,type:s.tokenType||A}),{testing:!0}):s.oauthCode?function(t){V();var e={silentError:!1,url:d.url("tenant/oauth"+"?grant_type=authorization_code".concat(_.get(d.appOption("oauth"),"uriAddition",""))+"&code=".concat(t)),method:"POST",skipInterceptor:!0};return h(e).then(q)}(s.oauthCode):l?(a.search("token",l),H(),{recoverPassword:!0}):s.noSavedTokens?{noSavedTokens:!0}:N()}).finally(function(){tt.initializing.done=!0}),window.c8y_testing&&(o.localStorage||(o.localStorage=window.localStorage),o.sessionStorage||(o.sessionStorage=window.sessionStorage)),tt}t.$inject=["$location","$rootScope","$injector","$q","$window","utoa","atou","info"],angular.module("c8y.core").factory("c8yAuth",t).config(["$httpProvider",function(t){t.interceptors.push("c8yAuth")}])}();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@c8y/ng1-modules",
3
- "version": "1016.187.0",
3
+ "version": "1016.189.0",
4
4
  "license": "Apache-2.0",
5
5
  "author": "Cumulocity",
6
6
  "description": "AngularJS modules for Cumulocity IoT applications.",