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

@cfanoulis/workers-slack

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cfanoulis/workers-slack

private fork for testing, please use the original (@sagi.io/workers-slack)

  • 0.0.53-prrtest
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

workers-slack

@sagi.io/workers-slack allows you to use Slack's Web API within Cloudflare Workers.

⭐ We use it at OpenSay to access Slack's REST API through Cloudflare Workers.

Here is a blog post that explains why I built it.

CircleCI MIT License version

Installation

$ npm i @sagi.io/workers-slack

Cloudflare Workers Usage

Initialize SlackREST:


// Without token:
const SlackREST = require('@sagi.io/workers-slack')
const SlackAPI = new SlackREST()

// With token:
const botAccessToken = process.env.SLACK_BOT_ACCESS_TOKEN;
const SlackREST = require('@sagi.io/workers-slack')
const SlackAPI = new SlackREST({ botAccessToken })

You can then use supported Slack methods. For instance, here's how to use the chat.postMessage method:


// SlackREST was initialized with a token
const formData = { channel: 'general', text: 'hello world'}

// SlackREST wasn't initialized with a token
const botAccessToken = process.env.SLACK_BOT_ACCESS_TOKEN;
const formData = { token: botAcccessToken, channel: 'general', text: 'hello world' }

const result = await SlackREST.chat.postMessage(formData)

Verifying requests from Slack

More information here.

The SlackREST.helpers.verifyRequestSignature method returns true when a signature from Slack is verified. Otherwise it throws an error.

const SlackREST = require('@sagi.io/workers-slack')
const SlackAPI = new SlackREST()

const signingSecret = process.env.SLACK_SIGNING_SECRET
const isVerifiedRequest = await SlackAPI.helpers.verifyRequestSignature(request, signingSecret)

Keywords

FAQs

Package last updated on 02 Dec 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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