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

@slack/oauth

Package Overview
Dependencies
Maintainers
13
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@slack/oauth - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

2

dist/index.d.ts

@@ -80,3 +80,3 @@ /// <reference types="node" />

id: string;
name: string;
name?: string;
};

@@ -83,0 +83,0 @@ bot?: {

@@ -195,3 +195,3 @@ "use strict";

state = parsedUrl.query.state;
if (state === undefined || code === undefined) {
if (state === undefined || state === '' || code === undefined) {
throw new errors_1.MissingStateError('redirect url is missing state or code query parameters');

@@ -240,3 +240,9 @@ }

_a.label = 4;
case 4: return [3 /*break*/, 8];
case 4:
if (resp.enterprise_id !== null) {
installation.enterprise = {
id: resp.enterprise_id,
};
}
return [3 /*break*/, 8];
case 5: return [4 /*yield*/, client.oauth.v2.access({

@@ -271,2 +277,8 @@ code: code,

};
if (resp.enterprise !== null) {
installation.enterprise = {
id: resp.enterprise.id,
name: resp.enterprise.name,
};
}
_a.label = 8;

@@ -375,15 +387,16 @@ case 8:

function callbackSuccess(installation, _options, _req, res) {
if (installation.team.id !== undefined && installation.appId !== undefined) {
// redirect back to slack
// Open in native app
var redirectUrl = "slack://app?team=" + installation.team.id + "&id=" + installation.appId;
res.writeHead(302, { Location: redirectUrl });
res.end();
var redirectUrl;
if (installation.team !== null && installation.team.id !== undefined && installation.appId !== undefined) {
// redirect back to Slack native app
// Changes to the workspace app was installed to, to the app home
redirectUrl = "slack://app?team=" + installation.team.id + "&id=" + installation.appId;
}
else {
// Send a generic success page
// TODO: make this page pretty?
res.writeHead(200, { 'Content-Type': 'text/html' });
res.end('<html><body><h1>Success! Please close this tab and go back to Slack</h1></body></html>');
// redirect back to Slack native app
// does not change the workspace the slack client was last in
redirectUrl = 'slack://open';
}
var htmlResponse = "<html>\n <meta http-equiv=\"refresh\" content=\"0; URL=" + redirectUrl + "\">\n <body>\n <h1>Success! Redirecting to the Slack App...</h1>\n <button onClick=\"window.location = '" + redirectUrl + "'\">Click here to redirect</button>\n </body></html>";
res.writeHead(200, { 'Content-Type': 'text/html' });
res.end(htmlResponse);
}

@@ -390,0 +403,0 @@ // Default function to call when OAuth flow is unsuccessful

{
"name": "@slack/oauth",
"version": "1.0.0",
"version": "1.1.0",
"description": "Official library for interacting with Slack's Oauth endpoints",

@@ -34,3 +34,3 @@ "author": "Slack Technologies, Inc.",

"lint": "tslint --project .",
"test": "nyc mocha --config .mocharc.json src/*.spec.js test/integration/*.js",
"test": "nyc mocha --config .mocharc.json src/*.spec.js",
"coverage": "codecov -F oauthhelper --root=$PWD"

@@ -37,0 +37,0 @@ },

@@ -102,3 +102,3 @@ # Slack OAuth

After the user approves the request to install your app (and grants access to the required permissions), Slack will redirect the user to your specified **redirect url**. You can either set the redirect url in the app’s **OAuth and Permissions** page or pass a `redirectUri` when calling `installProvider.generateInstallUrl`. Your HTTP server should handle requests to the redirect URL by calling the `installProvider.handleCallback()` method. The first two arguments (`req`, `res`) to `installProvider.handleCallback` are required. By default, if the installation is successful the user will be redirected back to your App Home in Slack (or shown a generic success page for classic Slack apps). If the installation is not successful the user will be shown an error page.
After the user approves the request to install your app (and grants access to the required permissions), Slack will redirect the user to your specified **redirect url**. You can either set the redirect url in the app’s **OAuth and Permissions** page or pass a `redirectUri` when calling `installProvider.generateInstallUrl`. Your HTTP server should handle requests to the redirect URL by calling the `installProvider.handleCallback()` method. The first two arguments (`req`, `res`) to `installProvider.handleCallback` are required. By default, if the installation is successful the user will be redirected back to your App Home in Slack (or redirected back to the last open workspace in your slack app for classic Slack apps). If the installation is not successful the user will be shown an error page.

@@ -144,7 +144,11 @@ ```javascript

// Do custom success logic here
res.send('successful!');
// tip: you can add javascript and css in the htmlResponse using the <script> and <style> tags
const htmlResponse = `<html><body>Success!</body></html>`
res.writeHead(200, { 'Content-Type': 'text/html' });
res.end(htmlResponse);
},
failure: (error, installOptions , req, res) => {
// Do custom failure logic here
res.send('failure');
res.writeHead(500, { 'Content-Type': 'text/html' });
res.end('<html><body><h1>Oops, Something Went Wrong! Please Try Again or Contact the App Owner</h1></body></html>');
}

@@ -199,3 +203,3 @@ }

// installQuery = {teamId: 'string', enterpriseId: 'string', userId: string, conversationId: 'string'};
const result = installer.authorize({teamId:'my-Team-ID'});
const result = installer.installationStore.fetchInstallation({teamId:'my-team-ID', enterpriseId:'my-enterprise-ID'});
/*

@@ -202,0 +206,0 @@ result = {

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