@slack/bolt
Advanced tools
Comparing version 3.12.2 to 3.13.0
/// <reference types="node" /> | ||
import { IncomingMessage, ServerResponse } from 'http'; | ||
import { ServerResponse } from 'http'; | ||
import { ParamsIncomingMessage } from './ParamsIncomingMessage'; | ||
export interface CustomRoute { | ||
path: string; | ||
method: string | string[]; | ||
handler: (req: IncomingMessage, res: ServerResponse) => void; | ||
handler: (req: ParamsIncomingMessage, res: ServerResponse) => void; | ||
} | ||
export interface ReceiverRoutes { | ||
[url: string]: { | ||
[method: string]: (req: IncomingMessage, res: ServerResponse) => void; | ||
[method: string]: (req: ParamsIncomingMessage, res: ServerResponse) => void; | ||
}; | ||
@@ -12,0 +13,0 @@ } |
@@ -9,2 +9,3 @@ "use strict"; | ||
const url_1 = require("url"); | ||
const path_to_regexp_1 = require("path-to-regexp"); | ||
const verify_redirect_opts_1 = require("./verify-redirect-opts"); | ||
@@ -230,5 +231,18 @@ const errors_1 = require("../errors"); | ||
if (Object.keys(this.routes).length) { | ||
const match = this.routes[path] && this.routes[path][method] !== undefined; | ||
if (match) { | ||
return this.routes[path][method](req, res); | ||
// Check if the request matches any of the custom routes | ||
let pathMatch = false; | ||
let params = {}; | ||
Object.keys(this.routes).forEach((route) => { | ||
if (pathMatch) | ||
return; | ||
const matchRegex = (0, path_to_regexp_1.match)(route, { decode: decodeURIComponent }); | ||
const tempMatch = matchRegex(path); | ||
if (tempMatch) { | ||
pathMatch = route; | ||
params = tempMatch.params; | ||
} | ||
}); | ||
const urlMatch = pathMatch && this.routes[pathMatch][method] !== undefined; | ||
if (urlMatch && pathMatch) { | ||
return this.routes[pathMatch][method]({ ...req, params }, res); | ||
} | ||
@@ -235,0 +249,0 @@ } |
/// <reference types="node" /> | ||
import { SocketModeClient } from '@slack/socket-mode'; | ||
import { IncomingMessage, ServerResponse } from 'http'; | ||
import { ServerResponse } from 'http'; | ||
import { Logger, LogLevel } from '@slack/logger'; | ||
import { InstallProvider, CallbackOptions, InstallProviderOptions, InstallURLOptions, InstallPathOptions } from '@slack/oauth'; | ||
import { AppsConnectionsOpenResponse } from '@slack/web-api'; | ||
import { ParamsIncomingMessage } from './ParamsIncomingMessage'; | ||
import App from '../App'; | ||
@@ -29,3 +30,3 @@ import { Receiver } from '../types'; | ||
method: string | string[]; | ||
handler: (req: IncomingMessage, res: ServerResponse) => void; | ||
handler: (req: ParamsIncomingMessage, res: ServerResponse) => void; | ||
} | ||
@@ -32,0 +33,0 @@ interface InstallerOptions { |
@@ -9,2 +9,3 @@ "use strict"; | ||
const oauth_1 = require("@slack/oauth"); | ||
const path_to_regexp_1 = require("path-to-regexp"); | ||
const custom_routes_1 = require("./custom-routes"); | ||
@@ -101,5 +102,17 @@ const verify_redirect_opts_1 = require("./verify-redirect-opts"); | ||
const { pathname: path } = new url_1.URL(req.url, 'http://localhost'); | ||
const match = this.routes[path] && this.routes[path][method] !== undefined; | ||
if (match) { | ||
this.routes[path][method](req, res); | ||
let pathMatch = false; | ||
let params = {}; | ||
Object.keys(this.routes).forEach((route) => { | ||
if (pathMatch) | ||
return; | ||
const matchRegex = (0, path_to_regexp_1.match)(route, { decode: decodeURIComponent }); | ||
const tempMatch = matchRegex(path); | ||
if (tempMatch) { | ||
pathMatch = route; | ||
params = tempMatch.params; | ||
} | ||
}); | ||
const urlMatch = pathMatch && this.routes[pathMatch][method] !== undefined; | ||
if (urlMatch && pathMatch) { | ||
this.routes[pathMatch][method]({ ...req, params }, res); | ||
return; | ||
@@ -106,0 +119,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { Option } from '@slack/types'; | ||
import { Option, PlainTextElement } from '@slack/types'; | ||
import { StringIndexed, XOR } from '../helpers'; | ||
@@ -128,3 +128,3 @@ import { AckFn } from '../utilities'; | ||
*/ | ||
declare type OptionsAckFn<Source extends OptionsSource> = Source extends 'block_suggestion' ? AckFn<XOR<BlockOptions, OptionGroups<BlockOptions>>> : Source extends 'interactive_message' ? AckFn<XOR<MessageOptions, OptionGroups<MessageOptions>>> : AckFn<XOR<DialogOptions, OptionGroups<DialogOptions>>>; | ||
declare type OptionsAckFn<Source extends OptionsSource> = Source extends 'block_suggestion' ? AckFn<XOR<BlockOptions, OptionGroups<BlockOptions>>> : Source extends 'interactive_message' ? AckFn<XOR<MessageOptions, OptionGroups<MessageOptions>>> : AckFn<XOR<DialogOptions, DialogOptionGroups<DialogOptions>>>; | ||
export interface BlockOptions { | ||
@@ -134,6 +134,3 @@ options: Option[]; | ||
export interface MessageOptions { | ||
options: { | ||
text: string; | ||
value: string; | ||
}[]; | ||
options: Option[]; | ||
} | ||
@@ -148,2 +145,7 @@ export interface DialogOptions { | ||
option_groups: ({ | ||
label: PlainTextElement; | ||
} & Options)[]; | ||
} | ||
export interface DialogOptionGroups<Options> { | ||
option_groups: ({ | ||
label: string; | ||
@@ -150,0 +152,0 @@ } & Options)[]; |
@@ -120,2 +120,3 @@ import { Block, KnownBlock, PlainTextElement, View } from '@slack/types'; | ||
selected_time?: string | null; | ||
selected_date_time?: number | null; | ||
selected_conversation?: string | null; | ||
@@ -122,0 +123,0 @@ selected_channel?: string | null; |
{ | ||
"name": "@slack/bolt", | ||
"version": "3.12.2", | ||
"version": "3.13.0", | ||
"description": "A framework for building Slack apps, fast.", | ||
@@ -45,3 +45,3 @@ "author": "Slack Technologies, LLC", | ||
"@slack/logger": "^3.0.0", | ||
"@slack/oauth": "^2.5.1", | ||
"@slack/oauth": "^2.6.0", | ||
"@slack/socket-mode": "^1.3.0", | ||
@@ -51,7 +51,8 @@ "@slack/types": "^2.7.0", | ||
"@types/express": "^4.16.1", | ||
"@types/node": "18.11.8", | ||
"@types/node": "18.15.11", | ||
"@types/promise.allsettled": "^1.0.3", | ||
"@types/tsscmp": "^1.0.0", | ||
"axios": "^0.26.1", | ||
"axios": "^0.27.2", | ||
"express": "^4.16.4", | ||
"path-to-regexp": "^6.2.1", | ||
"please-upgrade-node": "^3.2.0", | ||
@@ -58,0 +59,0 @@ "promise.allsettled": "^1.0.2", |
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
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
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
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
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
507445
167
7185
16
6
+ Addedpath-to-regexp@^6.2.1
+ Added@types/node@18.15.11(transitive)
+ Addedaxios@0.27.2(transitive)
+ Addedpath-to-regexp@6.3.0(transitive)
- Removed@types/node@18.11.8(transitive)
- Removedaxios@0.26.1(transitive)
Updated@slack/oauth@^2.6.0
Updated@types/node@18.15.11
Updatedaxios@^0.27.2