@aoberoi/passport-slack
Advanced tools
Comparing version 2.0.0-beta.6 to 2.0.0-beta.7
@@ -6,4 +6,5 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const https_1 = require("https"); | ||
const querystring_1 = require("querystring"); | ||
const passport_oauth2_1 = __importDefault(require("passport-oauth2")); // tslint:disable-line:import-name | ||
const needle_1 = __importDefault(require("needle")); | ||
const object_entries_1 = __importDefault(require("object.entries")); | ||
@@ -65,16 +66,37 @@ /** | ||
userProfile(accessToken, done) { | ||
needle_1.default('get', this.slack.profileURL, { token: accessToken }) | ||
.then(({ body }) => { | ||
if (!body.ok) { | ||
// Check for an error related to the X-Slack-User header missing | ||
if (body.error === 'user_not_specified') { | ||
done(null, undefined); | ||
let handled = false; | ||
const handle = (error, profile) => { | ||
if (!handled) { | ||
handled = true; | ||
done(error, profile); | ||
} | ||
}; | ||
const req = https_1.get(`${this.slack.profileURL}?${querystring_1.stringify({ token: accessToken })}`, (res) => { | ||
let body = ''; | ||
if (res.statusCode !== 200) { | ||
handle(new Error(res.statusMessage)); | ||
} | ||
res.setEncoding('utf8'); | ||
res.on('data', chunk => body += chunk); | ||
res.on('end', () => { | ||
try { | ||
body = JSON.parse(body); | ||
} | ||
else { | ||
throw new Error(body.error); | ||
catch (error) { | ||
handle(error); | ||
} | ||
} | ||
done(null, body); | ||
}) | ||
.catch(done); | ||
if (!body.ok) { | ||
// Check for an error related to the X-Slack-User header missing | ||
if (body.error === 'user_not_specified') { | ||
handle(null, undefined); | ||
} | ||
else { | ||
handle(new Error(body.error)); | ||
} | ||
} | ||
handle(null, body); | ||
}); | ||
res.on('error', handle); | ||
}); | ||
req.on('error', handle); | ||
} | ||
@@ -81,0 +103,0 @@ /** |
{ | ||
"name": "@aoberoi/passport-slack", | ||
"version": "2.0.0-beta.6", | ||
"version": "2.0.0-beta.7", | ||
"description": "Slack authentication strategy for Passport", | ||
@@ -24,5 +24,3 @@ "main": "dist/strategy.js", | ||
"@types/express": "^4.16.0", | ||
"@types/needle": "^2.0.2", | ||
"@types/passport-oauth2": "^1.4.5", | ||
"needle": "^2.2.3", | ||
"object.entries": "^1.0.4", | ||
@@ -29,0 +27,0 @@ "passport-oauth2": "^1.4.0" |
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
Network access
Supply chain riskThis module accesses the network.
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
30635
4
393
1
- Removed@types/needle@^2.0.2
- Removedneedle@^2.2.3
- Removed@types/needle@2.5.3(transitive)
- Removeddebug@3.2.7(transitive)
- Removediconv-lite@0.4.24(transitive)
- Removedms@2.1.3(transitive)
- Removedneedle@2.9.1(transitive)
- Removedsafer-buffer@2.1.2(transitive)
- Removedsax@1.4.1(transitive)