@4c/graphql-subscription-server
Advanced tools
Comparing version 0.1.1 to 0.2.0
@@ -18,4 +18,18 @@ function _asyncIterator(iterable) { if (typeof Symbol === "function") { if (Symbol.asyncIterator) { var method = iterable[Symbol.asyncIterator]; if (method != null) return method.call(iterable); } if (Symbol.iterator) { return iterable[Symbol.iterator](); } } throw new TypeError("Object is not async iterable"); } | ||
constructor(config) { | ||
this.isAuthorized = data => !!(this.config.credentialsManager.isAuthenticated() && this.config.hasPermission(data, this.getCredentials())); | ||
this.isAuthorized = data => { | ||
const isAuthenticated = this.config.credentialsManager.isAuthenticated(); | ||
const credentials = this.getCredentials(); | ||
const isAuthorized = !!(isAuthenticated && this.config.hasPermission(data, credentials)); | ||
if (!isAuthorized) { | ||
this.log('info', 'unauthorized', { | ||
payload: data, | ||
isAuthenticated, | ||
credentials | ||
}); | ||
} | ||
return isAuthorized; | ||
}; | ||
this.handleAuthenticate = async (authorization, cb) => { | ||
@@ -123,5 +137,5 @@ try { | ||
const payload = _value; | ||
this.log('debug', 'processing subscription update', { | ||
id, | ||
payload | ||
this.log('info', 'emit', { | ||
payload, | ||
credentials: this.getCredentials() | ||
}); | ||
@@ -128,0 +142,0 @@ this.config.socket.emit('subscription update', { |
@@ -29,4 +29,18 @@ "use strict"; | ||
constructor(config) { | ||
this.isAuthorized = data => !!(this.config.credentialsManager.isAuthenticated() && this.config.hasPermission(data, this.getCredentials())); | ||
this.isAuthorized = data => { | ||
const isAuthenticated = this.config.credentialsManager.isAuthenticated(); | ||
const credentials = this.getCredentials(); | ||
const isAuthorized = !!(isAuthenticated && this.config.hasPermission(data, credentials)); | ||
if (!isAuthorized) { | ||
this.log('info', 'unauthorized', { | ||
payload: data, | ||
isAuthenticated, | ||
credentials | ||
}); | ||
} | ||
return isAuthorized; | ||
}; | ||
this.handleAuthenticate = async (authorization, cb) => { | ||
@@ -134,5 +148,5 @@ try { | ||
const payload = _value; | ||
this.log('debug', 'processing subscription update', { | ||
id, | ||
payload | ||
this.log('info', 'emit', { | ||
payload, | ||
credentials: this.getCredentials() | ||
}); | ||
@@ -139,0 +153,0 @@ this.config.socket.emit('subscription update', { |
{ | ||
"name": "@4c/graphql-subscription-server", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"author": "4Catalyzer", | ||
@@ -46,4 +46,10 @@ "license": "MIT", | ||
}, | ||
"release": { | ||
"extends": [ | ||
"@4c/semantic-release-config" | ||
] | ||
}, | ||
"devDependencies": { | ||
"@4c/babel-preset-4catalyzer": "^1.3.0", | ||
"@4c/semantic-release-config": "^1.0.1", | ||
"@babel/cli": "^7.0.0-beta.43", | ||
@@ -73,3 +79,4 @@ "@babel/core": "^7.0.0-beta.40", | ||
"prettier": "^1.11.1", | ||
"redis-mock": "^0.21.0" | ||
"redis-mock": "^0.21.0", | ||
"semantic-release": "^15.1.7" | ||
}, | ||
@@ -83,3 +90,7 @@ "peerDependencies": { | ||
"socket.io": "^2.1.0" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/4Catalyzer/graphql-subscription-server.git" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
75571
40
989
0
28