@slack/socket-mode
Advanced tools
Comparing version 1.0.2 to 1.1.0
import { EventEmitter } from 'eventemitter3'; | ||
import WebSocket from 'ws'; | ||
import { WebAPICallResult, WebClientOptions } from '@slack/web-api'; | ||
import { AppsConnectionsOpenResponse, WebClientOptions } from '@slack/web-api'; | ||
import { LogLevel, Logger } from './logger'; | ||
@@ -73,3 +73,3 @@ /** | ||
*/ | ||
start(): Promise<WebAPICallResult>; | ||
start(): Promise<AppsConnectionsOpenResponse>; | ||
/** | ||
@@ -76,0 +76,0 @@ * End a Socket Mode session. After this method is called no messages will be sent or received unless you call |
@@ -21,3 +21,3 @@ "use strict"; | ||
class SocketModeClient extends eventemitter3_1.EventEmitter { | ||
constructor({ logger = undefined, logLevel = logger_1.LogLevel.INFO, autoReconnectEnabled = true, clientPingTimeout = 30000, appToken = undefined, clientOptions = {}, } = {}) { | ||
constructor({ logger = undefined, logLevel = undefined, autoReconnectEnabled = true, clientPingTimeout = 30000, appToken = undefined, clientOptions = {}, } = {}) { | ||
super(); | ||
@@ -112,3 +112,3 @@ /** | ||
if (this.badConnection) { | ||
// arrived here because `server ping timeout` ocurred and a new connection was created | ||
// arrived here because `server ping timeout` occurred and a new connection was created | ||
// tear down old connection | ||
@@ -264,3 +264,3 @@ this.teardownWebsocket(); | ||
if (appToken === undefined) { | ||
throw new Error('Must provide an App Level Token when initalizing a Socket Mode Client'); | ||
throw new Error('Must provide an App Level Token when initializing a Socket Mode Client'); | ||
} | ||
@@ -276,6 +276,6 @@ this.clientPingTimeout = clientPingTimeout; | ||
else { | ||
this.logger = logger_1.getLogger(SocketModeClient.loggerName, logLevel, logger); | ||
this.logger = logger_1.getLogger(SocketModeClient.loggerName, logLevel !== null && logLevel !== void 0 ? logLevel : logger_1.LogLevel.INFO, logger); | ||
} | ||
this.clientOptions = clientOptions; | ||
this.webClient = new web_api_1.WebClient('', Object.assign({ logLevel: this.logger.getLevel(), headers: { Authorization: `Bearer ${appToken}` } }, clientOptions)); | ||
this.webClient = new web_api_1.WebClient('', Object.assign({ logger, logLevel: this.logger.getLevel(), headers: { Authorization: `Bearer ${appToken}` } }, clientOptions)); | ||
this.autoReconnectEnabled = autoReconnectEnabled; | ||
@@ -282,0 +282,0 @@ this.stateMachine = finity_1.default.start(this.stateMachineConfig); |
{ | ||
"name": "@slack/socket-mode", | ||
"version": "1.0.2", | ||
"version": "1.1.0", | ||
"description": "Official library for using the Slack Platform's Socket Mode API", | ||
@@ -48,3 +48,3 @@ "author": "Slack Technologies, Inc.", | ||
"@slack/logger": "^3.0.0", | ||
"@slack/web-api": "^6.0.0", | ||
"@slack/web-api": "^6.2.3", | ||
"@types/node": ">=12.0.0", | ||
@@ -51,0 +51,0 @@ "@types/p-queue": "^2.3.2", |
# Slack Socket Mode | ||
[](https://github.com/slackapi/node-slack-sdk/actions?query=workflow%3A%22CI+Build%22) | ||
<!-- TODO: per-flag badge https://docs.codecov.io/docs/flags#section-flag-badges-and-graphs --> | ||
[](https://codecov.io/gh/slackapi/node-slack-sdk) | ||
<!-- TODO: npm versions with scoped packages: https://github.com/rvagg/nodei.co/issues/24 --> | ||
## Installation | ||
@@ -52,3 +47,3 @@ | ||
const socketModeClient = new SocketModeClient(appToken); | ||
const socketModeClient = new SocketModeClient({appToken}); | ||
@@ -76,3 +71,3 @@ (async () => { | ||
const socketModeClient = new SocketModeClient(appToken); | ||
const socketModeClient = new SocketModeClient({appToken}); | ||
@@ -132,2 +127,6 @@ // Attach listeners to events by type. See: https://api.slack.com/events/message | ||
}); | ||
(async () => { | ||
await socketModeClient.start(); | ||
})(); | ||
``` | ||
@@ -206,3 +205,4 @@ --- | ||
const socketModeClient = new SocketModeClient(appToken, { | ||
const socketModeClient = new SocketModeClient({ | ||
appToken, | ||
// Creating a logger as a literal object. It's more likely that you'd create a class. | ||
@@ -209,0 +209,0 @@ logger: { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
67871
Updated@slack/web-api@^6.2.3