@slack/client
Advanced tools
Comparing version 4.1.0 to 4.2.0
@@ -20,3 +20,3 @@ "use strict"; | ||
// NOTE: no support for TLS config | ||
let payload = this.defaults; | ||
let payload = Object.assign({}, this.defaults); | ||
if (typeof message === 'string') { | ||
@@ -23,0 +23,0 @@ payload.text = message; |
@@ -47,2 +47,10 @@ import { RTMClient } from './'; | ||
private logger; | ||
/** | ||
* Flag that indicates whether this object is still monitoring. | ||
*/ | ||
isMonitoring?: Boolean; | ||
/** | ||
* Flag that indicates whether recommend_reconnect event has been emitted and stop() has not been called. | ||
*/ | ||
recommendReconnect?: Boolean; | ||
constructor({clientPingTimeout, serverPongTimeout, logger, logLevel}?: KeepAliveOptions); | ||
@@ -49,0 +57,0 @@ /** |
@@ -40,2 +40,3 @@ "use strict"; | ||
this.client = client; | ||
this.isMonitoring = true; | ||
this.client.on('outgoing_message', this.setPingTimer, this); | ||
@@ -52,2 +53,3 @@ this.setPingTimer(); | ||
this.lastPing = this.client = undefined; | ||
this.recommendReconnect = this.isMonitoring = false; | ||
} | ||
@@ -108,7 +110,8 @@ /** | ||
} | ||
// signal that this pong is done being handled | ||
this.client.off('slack_event', attemptAcknowledgePong); | ||
// no pong received to acknowledge the last ping within the serverPongTimeout | ||
this.logger.debug('pong timer expired, recommend reconnect'); | ||
this.recommendReconnect = true; | ||
this.emit('recommend_reconnect'); | ||
// signal that this pong is done being handled | ||
this.client.off('slack_event', attemptAcknowledgePong); | ||
}, this.serverPongTimeout); | ||
@@ -115,0 +118,0 @@ this.client.on('slack_event', attemptAcknowledgePong, this); |
@@ -74,2 +74,4 @@ /// <reference types="node" /> | ||
}[]; | ||
callback_id?: string; | ||
mrkdwn_in?: ('pretext' | 'text' | 'fields')[]; | ||
} | ||
@@ -113,3 +115,3 @@ export interface LinkUnfurls { | ||
name: string; | ||
validate: boolean; | ||
validate?: boolean; | ||
}; | ||
@@ -597,2 +599,7 @@ export declare type ChannelsKickArguments = TokenOverridable & { | ||
}; | ||
export declare type UsersConversationsArguments = TokenOverridable & CursorPaginationEnabled & { | ||
exclude_archived?: boolean; | ||
types?: string; | ||
user?: string; | ||
}; | ||
export declare type UsersDeletePhotoArguments = TokenOverridable; | ||
@@ -599,0 +606,0 @@ export declare type UsersGetPresenceArguments = TokenOverridable & { |
@@ -99,2 +99,18 @@ "use strict"; | ||
.state('handshaking') // a state in which to wait until the 'server hello' event | ||
.on('websocket close') | ||
.transitionTo('reconnecting').withCondition(() => this.autoReconnect) | ||
.withAction((_from, _to, context) => { | ||
this.logger.debug(`reconnecting after unexpected close ${context.eventPayload.reason} | ||
${context.eventPayload.code} with isMonitoring set to ${this.keepAlive.isMonitoring} | ||
and recommendReconnect set to ${this.keepAlive.recommendReconnect}`); | ||
}) | ||
.transitionTo('disconnected') | ||
.withAction((_from, _to, context) => { | ||
this.logger.debug(`disconnected after unexpected close ${context.eventPayload.reason} | ||
${context.eventPayload.code} with isMonitoring set to ${this.keepAlive.isMonitoring} | ||
and recommendReconnect set to ${this.keepAlive.recommendReconnect}`); | ||
// this transition circumvents the 'disconnecting' state (since the websocket is already closed), | ||
// so we need to execute its onExit behavior here. | ||
this.teardownWebsocket(); | ||
}) | ||
.global() | ||
@@ -101,0 +117,0 @@ .onStateEnter((state) => { |
@@ -321,2 +321,3 @@ import EventEmitter = require('eventemitter3'); | ||
readonly users: { | ||
conversations: Method<methods.UsersConversationsArguments>; | ||
deletePhoto: Method<methods.TokenOverridable>; | ||
@@ -323,0 +324,0 @@ getPresence: Method<methods.UsersGetPresenceArguments>; |
@@ -295,2 +295,3 @@ "use strict"; | ||
this.users = { | ||
conversations: (this.apiCall.bind(this, 'users.conversations')), | ||
deletePhoto: (this.apiCall.bind(this, 'users.deletePhoto')), | ||
@@ -297,0 +298,0 @@ getPresence: (this.apiCall.bind(this, 'users.getPresence')), |
{ | ||
"name": "@slack/client", | ||
"version": "4.1.0", | ||
"version": "4.2.0", | ||
"description": "Slack Developer Kit - official clients for the Web API, RTM API, and Incoming Webhooks", | ||
@@ -5,0 +5,0 @@ "author": "Slack Technologies, Inc.", |
@@ -74,3 +74,23 @@ require('mocha'); | ||
}); | ||
describe('lifecycle', function () { | ||
beforeEach(function () { | ||
this.scope = nock('https://hooks.slack.com') | ||
.post(/services/) | ||
.reply(500); | ||
}); | ||
it('should not overwrite the default parameters after a call', function (done) { | ||
const defaultParams = { channel: 'default' }; | ||
const expectedParams = Object.assign({}, defaultParams); | ||
const webhook = new IncomingWebhook(url, defaultParams); | ||
webhook.send({ channel: 'different' }, () => { | ||
assert.deepEqual(webhook.defaults, expectedParams); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
@@ -40,3 +40,3 @@ import got = require('got'); // tslint:disable-line:no-require-imports | ||
// NOTE: no support for TLS config | ||
let payload: IncomingWebhookSendArguments = this.defaults; | ||
let payload: IncomingWebhookSendArguments = Object.assign({}, this.defaults); | ||
@@ -43,0 +43,0 @@ if (typeof message === 'string') { |
@@ -60,2 +60,12 @@ import { RTMClient, ErrorCode } from './'; | ||
/** | ||
* Flag that indicates whether this object is still monitoring. | ||
*/ | ||
public isMonitoring?: Boolean; | ||
/** | ||
* Flag that indicates whether recommend_reconnect event has been emitted and stop() has not been called. | ||
*/ | ||
public recommendReconnect?: Boolean; | ||
constructor({ | ||
@@ -101,2 +111,3 @@ clientPingTimeout = 6000, | ||
this.client = client; | ||
this.isMonitoring = true; | ||
this.client.on('outgoing_message', this.setPingTimer, this); | ||
@@ -114,2 +125,3 @@ this.setPingTimer(); | ||
this.lastPing = this.client = undefined; | ||
this.recommendReconnect = this.isMonitoring = false; | ||
} | ||
@@ -180,9 +192,9 @@ | ||
} | ||
// signal that this pong is done being handled | ||
this.client.off('slack_event', attemptAcknowledgePong); | ||
// no pong received to acknowledge the last ping within the serverPongTimeout | ||
this.logger.debug('pong timer expired, recommend reconnect'); | ||
this.recommendReconnect = true; | ||
this.emit('recommend_reconnect'); | ||
// signal that this pong is done being handled | ||
this.client.off('slack_event', attemptAcknowledgePong); | ||
}, this.serverPongTimeout); | ||
@@ -189,0 +201,0 @@ |
@@ -94,2 +94,4 @@ import { Stream } from 'stream'; | ||
}[]; | ||
callback_id?: string; | ||
mrkdwn_in?: ('pretext' | 'text' | 'fields')[]; | ||
} | ||
@@ -158,3 +160,3 @@ | ||
name: string; | ||
validate: boolean; | ||
validate?: boolean; | ||
}; | ||
@@ -729,2 +731,7 @@ export type ChannelsKickArguments = TokenOverridable & { | ||
*/ | ||
export type UsersConversationsArguments = TokenOverridable & CursorPaginationEnabled & { | ||
exclude_archived?: boolean; | ||
types?: string; // comma-separated list of conversation types | ||
user?: string; | ||
}; | ||
export type UsersDeletePhotoArguments = TokenOverridable; | ||
@@ -731,0 +738,0 @@ export type UsersGetPresenceArguments = TokenOverridable & { |
@@ -148,2 +148,18 @@ import { Agent } from 'http'; | ||
.state('handshaking') // a state in which to wait until the 'server hello' event | ||
.on('websocket close') | ||
.transitionTo('reconnecting').withCondition(() => this.autoReconnect) | ||
.withAction((_from, _to, context) => { | ||
this.logger.debug(`reconnecting after unexpected close ${context.eventPayload.reason} | ||
${context.eventPayload.code} with isMonitoring set to ${this.keepAlive.isMonitoring} | ||
and recommendReconnect set to ${this.keepAlive.recommendReconnect}`); | ||
}) | ||
.transitionTo('disconnected') | ||
.withAction((_from, _to, context) => { | ||
this.logger.debug(`disconnected after unexpected close ${context.eventPayload.reason} | ||
${context.eventPayload.code} with isMonitoring set to ${this.keepAlive.isMonitoring} | ||
and recommendReconnect set to ${this.keepAlive.recommendReconnect}`); | ||
// this transition circumvents the 'disconnecting' state (since the websocket is already closed), | ||
// so we need to execute its onExit behavior here. | ||
this.teardownWebsocket(); | ||
}) | ||
.global() | ||
@@ -150,0 +166,0 @@ .onStateEnter((state) => { |
@@ -488,2 +488,3 @@ import { basename } from 'path'; | ||
public readonly users = { | ||
conversations: (this.apiCall.bind(this, 'users.conversations')) as Method<methods.UsersConversationsArguments>, | ||
deletePhoto: (this.apiCall.bind(this, 'users.deletePhoto')) as Method<methods.UsersDeletePhotoArguments>, | ||
@@ -490,0 +491,0 @@ getPresence: (this.apiCall.bind(this, 'users.getPresence')) as Method<methods.UsersGetPresenceArguments>, |
@@ -11,2 +11,4 @@ /** | ||
* @extends EventEmitter | ||
* @property {Boolean} [isMonitoring] Flag that indicates whether this object is still monitoring. | ||
* @property {Boolean} [recommendReconnect] Flag that indicates whether recommend_reconnect event has been emitted and stop() has not been called. | ||
*/ | ||
@@ -13,0 +15,0 @@ export class KeepAlive { |
@@ -60,2 +60,4 @@ /** | ||
* @property {Array<module:@slack/client/dist/methods.__type>} [actions] | ||
* @property {string} [callback_id] | ||
* @property {Array<"pretext" | "text" | "fields">} [mrkdwn_in] | ||
*/ | ||
@@ -62,0 +64,0 @@ export class MessageAttachment { |
@@ -1,2 +0,2 @@ | ||
/** | ||
/** | ||
* @module @slack/client | ||
@@ -153,3 +153,3 @@ */ | ||
* will buffer until the client is in a state where they can be sent. | ||
* | ||
* | ||
* If the awaitReply parameter is set to true, then the returned Promise is resolved with the platform's | ||
@@ -159,3 +159,3 @@ * acknowledgement response. Not all message types will result in an acknowledgement response, so use this carefully. | ||
* reconnects before recieving the acknowledgement response. | ||
* | ||
* | ||
* If the awaitReply parameter is set to false, then the returned Promise is resolved as soon as the message is sent | ||
@@ -359,3 +359,3 @@ * from the websocket. | ||
* A client for Slack's Web API | ||
* | ||
* | ||
* This client provides an alias for each {@link https://api.slack.com/methods|Web API method}. Each method is | ||
@@ -362,0 +362,0 @@ * a convenience wrapper for calling the {@link WebClient#apiCall} method using the method name as the first parameter. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 3 instances in 1 package
Uses eval
Supply chain riskPackage uses eval() which is a dangerous function. This prevents the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 3 instances in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license
Found 2 instances in 1 package
0
100
1
8
3
459875
149
7325