New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

angular-eha.couchdb-auth

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular-eha.couchdb-auth - npm Package Compare versions

Comparing version 0.5.1 to 0.5.2

3

dist/couchdb-auth.js

@@ -250,2 +250,5 @@ ;(function() {

.catch(function(err) {
if (err === 'unauthorized') {
throw err;
}
ehaCouchDbAuthService.trigger('unauthenticated');

@@ -252,0 +255,0 @@ return $q.reject('unauthenticated');

2

dist/couchdb-auth.min.js

@@ -1,1 +0,1 @@

!function(){"use strict";function a(a,b,c,d,e,f){function g(){var c=a.url+"/"+a.sessionEndpoint;return d.when(b.oneUrl("session",c).get()).then(function(a){return a.userCtx?a:void d.reject("Session not found")})}function h(e){return d.when(b.all(a.sessionEndpoint).customPOST({name:e.username,password:e.password})).then(function(a){return a.plain()}).then(s).then(function(a){return g().then(function(b){return angular.extend(b.plain(),a)})}).then(s).then(function(a){return a&&a.ok?(u.$broadcast("authenticationStateChange"),c.debug("couchdb:login:success",a),q(a)):(c.debug("couchdb:login:failure:unknown"),d.reject(new Error))})["catch"](function(a){return 401===a.status?(c.debug("couchdb:login:failure:invalid-credentials",a),d.reject(new Error("Invalid Credentials"))):(c.debug("couchdb:login:failure:unknown",a),d.reject(new Error(a)))})}function i(){return t=null,e.removeItem("user")}function j(a){return e.setItem("user",a)}function k(){return e.getItem("user")}function l(){return i().then(function(){return u.$broadcast("authenticationStateChange"),!0})}function m(a){return a.token&&a.password?d.when(b.all("reset-password").customPOST({token:a.token,password:a.password})):a.email&&a.callbackUrl?d.when(b.all("reset-password").customPOST({email:a.email,callbackUrl:a.callbackUrl})):d.reject("You must provide both email and callbackUrl properties in the payload")}function n(){return d.reject("NOT_IMPLEMENTED")}function o(){return d.reject("NOT_IMPLEMENTED")}function p(){return d.reject("NOT_IMPLEMENTED")}function q(b){return b.hasRole=function(a){var b=this;if(angular.isArray(a)){var c=a.filter(function(a){return b.roles.indexOf(a)>-1});return!!c.length}return angular.isString(a)?this.roles.indexOf(a)>-1:void 0},b.isAdmin=function(){return this.hasRole(a.adminRoles)},b}function r(){return t?d.when(q(t)):k().then(function(a){return a?(t=a,q(a)):d.reject("User not found")}).then(function(a){return g().then(function(){return a})})["catch"](function(a){return c.debug(a),d.reject(a)})}function s(a){return a?(t=a,j(a)):void d.reject("No user found")}var t,u=f.$new(!0);return{signIn:h,signOut:l,resetPassword:m,accounts:{add:n,update:o,remove:p},getSession:g,getCurrentUser:r,on:u.$on.bind(u),trigger:u.$broadcast.bind(u),isAuthenticated:function(){return t?g():d.reject()}}}var b=angular.module("eha.couchdb-auth.auth.service",["restangular","LocalForageModule"]);b.provider("ehaCouchDbAuthService",["$localForageProvider","ehaCouchDbAuthHttpInterceptorProvider","$httpProvider",function(b,c,d){function e(a){return a.charAt(0).toUpperCase()+a.slice(1)}function f(a){var b=[a];return a.indexOf("-")>-1?b=a.split("-"):a.indexOf("_")>-1&&(b=a.split("_")),b=b.map(e),b.join("")}function g(a,b,c){return a.getCurrentUser().then(function(d){return d&&!d.hasRole(c)?(a.trigger("unauthorized"),b.reject("unauthorized")):d})["catch"](function(){return a.trigger("unauthenticated"),b.reject("unauthenticated")})}var h={localStorageNamespace:"eha",localStorageStoreName:"auth",adminRoles:["_admin"],sessionEndpoint:"_session"};this.config=function(a){h=angular.extend(h,a),b.config({name:h.localStorageNamespace,storeName:h.localStorageStoreName}),a.interceptor&&(c.config({url:a.url,hosts:a.interceptor.hosts}),d.interceptors.push("ehaCouchDbAuthHttpInterceptor")),a.userRoles&&a.userRoles.forEach(function(a){var b="require"+f(a)+"User";this[b]=function(b,c){return g(b,c,[a])}}.bind(this))},this.requireAdminUser=function(a,b){return g(a,b,h.adminRoles)},this.requireAuthenticatedUser=function(a,b){return a.getCurrentUser().then(function(a){return a})["catch"](function(){return a.trigger("unauthenticated"),b.reject("unauthenticated")})},this.$get=["Restangular","$log","$q","$localForage","$rootScope",function(b,c,d,e,f){var g=b.withConfig(function(a){a.setBaseUrl(h.url),h.defaultHttpFields&&a.setDefaultHttpFields(h.defaultHttpFields)});return new a(h,g,c,d,e,f)}]}]),"undefined"!=typeof module&&module.exports&&(module.exports=b)}(),function(){"use strict";function a(a,b){function c(b){var c=a.hosts.filter(function(a){return b.indexOf(a)>-1});return!!c.length}var d=b.get("$q"),e=b.get("$log");return{request:function(a){if(c(a.url)){var f=b.get("ehaCouchDbAuthService");return f.getCurrentUser().then(function(b){return b&&b.bearerToken&&(a.headers.Authorization="Bearer "+b.bearerToken),a})["catch"](function(b){return e.debug(b),a})}return d.when(a)},responseError:function(a){if(401===a.status&&c(a.config.url)){var e=b.get("ehaCouchDbAuthService");e.trigger("unauthenticated")}return d.reject(a)}}}var b=angular.module("eha.couchdb-auth.http-interceptor",[]);b.provider("ehaCouchDbAuthHttpInterceptor",function(){var b={};this.config=function(a){b=a},this.$get=["$injector",function(c){return new a(b,c)}]}),"undefined"!=typeof module&&module.exports&&(module.exports=b)}(),angular.module("eha.couchdb-auth.show-for-role.directive",[]).directive("ehaShowForRole",["ehaCouchDbAuthService","$animate","$parse","$q","$log",function(a,b,c,d,e){var f="ng-hide",g="ng-hide-animate";return{restrict:"A",link:function(h,i,j){function k(c){a.getCurrentUser().then(function(a){return a&&a.hasRole(c)?(b.removeClass(i,f,{tempClasses:g}),!0):d.reject("Role not found")})["catch"](function(a){e.debug(a),b.addClass(i,f,{tempClasses:g})})}i.addClass("ng-hide");var l,m=c(j.ehaShowForRole)(h);if(angular.isArray(m))l=m;else{if(!angular.isString(m))throw Error("You must pass a string or an array of strings");l=[m]}k(l),a.on("authenticationStateChange",function(){k(l)})}}}]),angular.module("eha.couchdb-auth.show-authenticated.directive",[]).directive("ehaShowAuthenticated",["ehaCouchDbAuthService","$animate",function(a,b){var c="ng-hide",d="ng-hide-animate";return{restrict:"A",link:function(e,f){function g(){a.isAuthenticated().then(function(){b.removeClass(f,c,{tempClasses:d})})["catch"](function(){b.addClass(f,c,{tempClasses:d})})}f.addClass("ng-hide"),g(),a.on("authenticationStateChange",g)}}}]),function(){"use strict";var a=angular.module("eha.couchdb-auth",["eha.couchdb-auth.http-interceptor","eha.couchdb-auth.auth.service","eha.couchdb-auth.show-for-role.directive","eha.couchdb-auth.show-authenticated.directive"]);"undefined"!=typeof module&&module.exports&&(module.exports=a)}();
!function(){"use strict";function a(a,b,c,d,e,f){function g(){var c=a.url+"/"+a.sessionEndpoint;return d.when(b.oneUrl("session",c).get()).then(function(a){return a.userCtx?a:void d.reject("Session not found")})}function h(e){return d.when(b.all(a.sessionEndpoint).customPOST({name:e.username,password:e.password})).then(function(a){return a.plain()}).then(s).then(function(a){return g().then(function(b){return angular.extend(b.plain(),a)})}).then(s).then(function(a){return a&&a.ok?(u.$broadcast("authenticationStateChange"),c.debug("couchdb:login:success",a),q(a)):(c.debug("couchdb:login:failure:unknown"),d.reject(new Error))})["catch"](function(a){return 401===a.status?(c.debug("couchdb:login:failure:invalid-credentials",a),d.reject(new Error("Invalid Credentials"))):(c.debug("couchdb:login:failure:unknown",a),d.reject(new Error(a)))})}function i(){return t=null,e.removeItem("user")}function j(a){return e.setItem("user",a)}function k(){return e.getItem("user")}function l(){return i().then(function(){return u.$broadcast("authenticationStateChange"),!0})}function m(a){return a.token&&a.password?d.when(b.all("reset-password").customPOST({token:a.token,password:a.password})):a.email&&a.callbackUrl?d.when(b.all("reset-password").customPOST({email:a.email,callbackUrl:a.callbackUrl})):d.reject("You must provide both email and callbackUrl properties in the payload")}function n(){return d.reject("NOT_IMPLEMENTED")}function o(){return d.reject("NOT_IMPLEMENTED")}function p(){return d.reject("NOT_IMPLEMENTED")}function q(b){return b.hasRole=function(a){var b=this;if(angular.isArray(a)){var c=a.filter(function(a){return b.roles.indexOf(a)>-1});return!!c.length}return angular.isString(a)?this.roles.indexOf(a)>-1:void 0},b.isAdmin=function(){return this.hasRole(a.adminRoles)},b}function r(){return t?d.when(q(t)):k().then(function(a){return a?(t=a,q(a)):d.reject("User not found")}).then(function(a){return g().then(function(){return a})})["catch"](function(a){return c.debug(a),d.reject(a)})}function s(a){return a?(t=a,j(a)):void d.reject("No user found")}var t,u=f.$new(!0);return{signIn:h,signOut:l,resetPassword:m,accounts:{add:n,update:o,remove:p},getSession:g,getCurrentUser:r,on:u.$on.bind(u),trigger:u.$broadcast.bind(u),isAuthenticated:function(){return t?g():d.reject()}}}var b=angular.module("eha.couchdb-auth.auth.service",["restangular","LocalForageModule"]);b.provider("ehaCouchDbAuthService",["$localForageProvider","ehaCouchDbAuthHttpInterceptorProvider","$httpProvider",function(b,c,d){function e(a){return a.charAt(0).toUpperCase()+a.slice(1)}function f(a){var b=[a];return a.indexOf("-")>-1?b=a.split("-"):a.indexOf("_")>-1&&(b=a.split("_")),b=b.map(e),b.join("")}function g(a,b,c){return a.getCurrentUser().then(function(d){return d&&!d.hasRole(c)?(a.trigger("unauthorized"),b.reject("unauthorized")):d})["catch"](function(c){if("unauthorized"===c)throw c;return a.trigger("unauthenticated"),b.reject("unauthenticated")})}var h={localStorageNamespace:"eha",localStorageStoreName:"auth",adminRoles:["_admin"],sessionEndpoint:"_session"};this.config=function(a){h=angular.extend(h,a),b.config({name:h.localStorageNamespace,storeName:h.localStorageStoreName}),a.interceptor&&(c.config({url:a.url,hosts:a.interceptor.hosts}),d.interceptors.push("ehaCouchDbAuthHttpInterceptor")),a.userRoles&&a.userRoles.forEach(function(a){var b="require"+f(a)+"User";this[b]=function(b,c){return g(b,c,[a])}}.bind(this))},this.requireAdminUser=function(a,b){return g(a,b,h.adminRoles)},this.requireAuthenticatedUser=function(a,b){return a.getCurrentUser().then(function(a){return a})["catch"](function(){return a.trigger("unauthenticated"),b.reject("unauthenticated")})},this.$get=["Restangular","$log","$q","$localForage","$rootScope",function(b,c,d,e,f){var g=b.withConfig(function(a){a.setBaseUrl(h.url),h.defaultHttpFields&&a.setDefaultHttpFields(h.defaultHttpFields)});return new a(h,g,c,d,e,f)}]}]),"undefined"!=typeof module&&module.exports&&(module.exports=b)}(),function(){"use strict";function a(a,b){function c(b){var c=a.hosts.filter(function(a){return b.indexOf(a)>-1});return!!c.length}var d=b.get("$q"),e=b.get("$log");return{request:function(a){if(c(a.url)){var f=b.get("ehaCouchDbAuthService");return f.getCurrentUser().then(function(b){return b&&b.bearerToken&&(a.headers.Authorization="Bearer "+b.bearerToken),a})["catch"](function(b){return e.debug(b),a})}return d.when(a)},responseError:function(a){if(401===a.status&&c(a.config.url)){var e=b.get("ehaCouchDbAuthService");e.trigger("unauthenticated")}return d.reject(a)}}}var b=angular.module("eha.couchdb-auth.http-interceptor",[]);b.provider("ehaCouchDbAuthHttpInterceptor",function(){var b={};this.config=function(a){b=a},this.$get=["$injector",function(c){return new a(b,c)}]}),"undefined"!=typeof module&&module.exports&&(module.exports=b)}(),angular.module("eha.couchdb-auth.show-for-role.directive",[]).directive("ehaShowForRole",["ehaCouchDbAuthService","$animate","$parse","$q","$log",function(a,b,c,d,e){var f="ng-hide",g="ng-hide-animate";return{restrict:"A",link:function(h,i,j){function k(c){a.getCurrentUser().then(function(a){return a&&a.hasRole(c)?(b.removeClass(i,f,{tempClasses:g}),!0):d.reject("Role not found")})["catch"](function(a){e.debug(a),b.addClass(i,f,{tempClasses:g})})}i.addClass("ng-hide");var l,m=c(j.ehaShowForRole)(h);if(angular.isArray(m))l=m;else{if(!angular.isString(m))throw Error("You must pass a string or an array of strings");l=[m]}k(l),a.on("authenticationStateChange",function(){k(l)})}}}]),angular.module("eha.couchdb-auth.show-authenticated.directive",[]).directive("ehaShowAuthenticated",["ehaCouchDbAuthService","$animate",function(a,b){var c="ng-hide",d="ng-hide-animate";return{restrict:"A",link:function(e,f){function g(){a.isAuthenticated().then(function(){b.removeClass(f,c,{tempClasses:d})})["catch"](function(){b.addClass(f,c,{tempClasses:d})})}f.addClass("ng-hide"),g(),a.on("authenticationStateChange",g)}}}]),function(){"use strict";var a=angular.module("eha.couchdb-auth",["eha.couchdb-auth.http-interceptor","eha.couchdb-auth.auth.service","eha.couchdb-auth.show-for-role.directive","eha.couchdb-auth.show-authenticated.directive"]);"undefined"!=typeof module&&module.exports&&(module.exports=a)}();

@@ -8,7 +8,7 @@ {

"scripts": {
"commit-build": "git commit -i dist -m 'chore: rebuild'",
"build": "grunt build",
"postinstall": "bower install",
"test": "grunt test",
"semantic-release": "semantic-release pre && npm publish && semantic-release post"
"publish-dist": "npm run build && publish-dist --author-name 'ehealthafrica-ci' --author-email 'ehealthafrica-ci@ehealthafrica.org'",
"semantic-release": "semantic-release pre && npm run publish-dist && npm publish && semantic-release post"
},

@@ -35,3 +35,2 @@ "repository": {

"chai-as-promised": "^4.2.0",
"ghooks": "^0.3.2",
"grunt": "^0.4.5",

@@ -62,2 +61,3 @@ "grunt-cli": "^0.1.13",

"optimist": "^0.6.1",
"publish-dist": "1.0.2",
"semantic-release": "^4.3.5",

@@ -69,8 +69,3 @@ "sinon": "^1.12.2"

},
"config": {
"ghooks": {
"pre-push": "npm run build && npm run commit-build"
}
},
"version": "0.5.1"
"version": "0.5.2"
}

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