Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
c3b962b
chore: drop Node.js 18 support for web-api and webhook
WilliamBergamin May 1, 2026
5033bcd
chore: sync package-lock.json after dropping Node.js 18 support
WilliamBergamin May 1, 2026
ea9eefa
improve naming
WilliamBergamin May 1, 2026
cdcf067
fix: move from axios to fetch
WilliamBergamin May 1, 2026
ae5cc24
update from v8
WilliamBergamin May 4, 2026
13183aa
make rtm use older version of packages
WilliamBergamin May 4, 2026
b0063a0
use undici in socket-mode
WilliamBergamin May 4, 2026
896baad
Merge branch 'v8' into mirgate-from-axios-to-fetch
WilliamBergamin May 5, 2026
9482c57
improve behavior based on review
WilliamBergamin May 5, 2026
57a72fc
imporve based on review
WilliamBergamin May 5, 2026
5ecd0c1
improve based on prototyping
WilliamBergamin May 5, 2026
0be3856
improve based on review and prototyping
WilliamBergamin May 5, 2026
c4f96b5
Update SlackWebSocket.ts
WilliamBergamin May 5, 2026
db2e290
simplify changes
WilliamBergamin May 5, 2026
1256822
Merge branch 'v8' into mirgate-from-axios-to-fetch
WilliamBergamin May 5, 2026
a4162b2
Update package.json
WilliamBergamin May 5, 2026
6836ffe
Merge branch 'v8' into mirgate-from-axios-to-fetch
WilliamBergamin May 6, 2026
6fa7843
improve based on review
WilliamBergamin May 6, 2026
a910040
Merge branch 'v8' into mirgate-from-axios-to-fetch
WilliamBergamin May 6, 2026
27d87bf
clean up the unit tests
WilliamBergamin May 6, 2026
6af858d
make things work
WilliamBergamin May 6, 2026
52ed3d8
restore preveously deleted comments
WilliamBergamin May 6, 2026
79b798e
update the type from the package
WilliamBergamin May 6, 2026
0d17317
Merge branch 'v8' into mirgate-from-axios-to-fetch
WilliamBergamin May 7, 2026
811a029
Update package-lock.json
WilliamBergamin May 7, 2026
fa22c7e
Merge branch 'v8' into mirgate-from-axios-to-fetch
WilliamBergamin May 7, 2026
5ecb21d
fix accept header being set by axios previously
WilliamBergamin May 7, 2026
504875c
Merge branch 'v8' into mirgate-from-axios-to-fetch
WilliamBergamin May 7, 2026
c5a944d
fix issue where axios was added back in
WilliamBergamin May 7, 2026
2f57822
we aren't returning the correct response from start
WilliamBergamin May 7, 2026
234a516
make undici a peer dependency
WilliamBergamin May 8, 2026
e3bf6ed
improve devxp of fetch typing
WilliamBergamin May 8, 2026
6d9ad8e
Improve abstraction between our lib and undici types
WilliamBergamin May 11, 2026
6d26252
Improve typing of socketmode dispatcher configuration
WilliamBergamin May 11, 2026
b585c95
improve type casting behaviors
WilliamBergamin May 11, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
140 changes: 114 additions & 26 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/oauth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
},
"dependencies": {
"@slack/logger": "^4.0.1",
"@slack/web-api": "^7.15.0",
"@slack/web-api": "^8.0.0-rc.1",
"@types/jsonwebtoken": "^9",
"@types/node": ">=20",
"jsonwebtoken": "^9"
Expand Down
8 changes: 4 additions & 4 deletions packages/socket-mode/examples/proxy.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
const { SocketModeClient, LogLevel } = require('@slack/socket-mode');
const HttpsProxyAgent = require('https-proxy-agent');
const clientOptions = { agent: new HttpsProxyAgent('http://localhost:9001') };
const { ProxyAgent } = require('undici');
const dispatcher = new ProxyAgent('http://localhost:9001');

const socketModeClient = new SocketModeClient({
appToken: process.env.SLACK_APP_TOKEN,
logLevel: LogLevel.DEBUG,
clientOptions,
dispatcher,
});

// const { WebClient } = require('@slack/web-api');
// const webClient = new WebClient(process.env.SLACK_BOT_TOKEN, {
// logLevel: LogLevel.DEBUG,
// clientOptions,
// fetch: (url, options) => fetch(url, { ...options, dispatcher })
// });

socketModeClient.on('slack_event', async ({ ack, body }) => {
Expand Down
18 changes: 13 additions & 5 deletions packages/socket-mode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,30 @@
"test": "npm run test:unit && npm run test:integration",
"test:coverage": "npm run build && node --experimental-test-coverage --test-reporter=spec --test-reporter-destination=stdout --test-reporter=lcov --test-reporter-destination=lcov.info --test-reporter=junit --test-reporter-destination=test-results.xml --import tsx --test src/*.test.ts",
"test:integration": "npm run build && node --import tsx --test test/integration.test.js",
"test:types": "tsd",
"test:unit": "npm run build && bash -c 'node --test-reporter=spec --test-reporter-destination=stdout --test-reporter=junit --test-reporter-destination=test-results.xml --import tsx --test src/*.test.ts'",
"watch": "npx nodemon --watch 'src' --ext 'ts' --exec npm test"
},
"dependencies": {
"@slack/logger": "^4.0.1",
"@slack/web-api": "^7.15.0",
"@slack/web-api": "^8.0.0-rc.1",
"@types/node": ">=20",
"@types/ws": "^8",
"eventemitter3": "^5",
"ws": "^8"
"eventemitter3": "^5"
},
"peerDependencies": {
"undici": "^7.0.0"
},
"devDependencies": {
"@types/proxyquire": "^1.3.31",
"@types/sinon": "^21",
"nodemon": "^3.1.0",
"proxyquire": "^2.1.3",
"sinon": "^21"
"sinon": "^21",
"tsd": "^0.33.0",
"undici": "^7.25.0",
"ws": "^8"
},
"tsd": {
"directory": "test/types"
}
}
32 changes: 21 additions & 11 deletions packages/socket-mode/src/SlackWebSocket.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,34 @@ import { ConsoleLogger } from '@slack/logger';
import EventEmitter from 'eventemitter3';
import proxyquire from 'proxyquire';
import sinon from 'sinon';
import { CloseEvent, ErrorEvent, MessageEvent } from 'undici';

proxyquire.noPreserveCache();

import logModule from './logger';

// A slightly spruced up event emitter aiming at mocking out the `ws` library's `WebSocket` class
class WSMock extends EventEmitter {
// biome-ignore lint/suspicious/noExplicitAny: event listeners can accept any args
addEventListener(evt: string, fn: (...args: any[]) => void) {
this.addListener.call(this, evt, fn);
}
// Minimal mock of undici's WebSocket (EventTarget-based)
class WSMock extends EventTarget {
static CONNECTING = 0;
static OPEN = 1;
static CLOSING = 2;
static CLOSED = 3;
readyState = 1;
close() {}
send(_data: string) {}
}

describe('SlackWebSocket', () => {
const sandbox = sinon.createSandbox();
let SlackWebSocket: typeof import('./SlackWebSocket').SlackWebSocket;
beforeEach(() => {
SlackWebSocket = proxyquire.load('./SlackWebSocket', {
ws: {
undici: {
WebSocket: WSMock,
CloseEvent,
ErrorEvent,
MessageEvent,
ping: () => {},
},
}).SlackWebSocket;
});
Expand Down Expand Up @@ -58,17 +66,19 @@ describe('SlackWebSocket', () => {
});
describe('WebSocket event handling', () => {
it('should call disconnect() if websocket emits an error', async () => {
// an exposed event emitter pretending it's a websocket
const ws = new WSMock();
// mock out the `ws` library and have it return our event emitter mock
SlackWebSocket = proxyquire.load('./SlackWebSocket', {
ws: {
undici: {
WebSocket: class Fake {
constructor() {
// biome-ignore lint/correctness/noConstructorReturn: for test mocking purposes
return ws;
}
},
CloseEvent,
ErrorEvent,
MessageEvent,
ping: () => {},
},
}).SlackWebSocket;
const sws = new SlackWebSocket({
Expand All @@ -79,7 +89,7 @@ describe('SlackWebSocket', () => {
});
const discStub = sinon.stub(sws, 'disconnect');
sws.connect();
ws.emit('error', { error: new Error('boom') });
ws.dispatchEvent(new ErrorEvent('error', { error: new Error('boom'), message: 'boom' }));
sinon.assert.calledOnce(discStub);
});
});
Expand Down
Loading
Loading