Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
twitch-toolkit
Advanced tools
A set of tools to integrate with Twitch API, Twitch Chat and Twitch WebHooks.
A set of tools to integrate with Twitch API, Twitch Chat and Twitch WebHooks.
To start to use this module, check the project documentation.
Using npm:
$ npm i --save twitch-toolkit
The library is composed by three independent modules:
The toolkit exports each module and you can access it like this:
const {API, Chat, WebHook} = require('twitch-toolkit');
Every module must be instanced with the required configs as described in the next sessions.
The API module must be instanced with the following config object:
Name | Type | Description |
---|---|---|
client_id | string | The client_id to be used to access the API. This is required. |
client_secret | string | The secret to be used to access the API that requires login. If this is not provided, the restricted methods will thrown an error. |
Example:
const { API } = require('twitch-toolkit');
const twitchAPI = new API({client_id: 'id-string', client_secret: 'secret-string'})
The API methods are described in the TwitchApi documentation page
The API module must be instanced with the config objects described in the constructor documentation
Example:
const { Chat } = require('twitch-toolkit');
const twitchChat = new Chat(options)
To connected to the channels with the specified user, you'll need to call the connect function:
twitch.connect()
After that, you'll be able to listen to channel and chat events. You can also disconnect from the chat, if you wish:
twitch.disconnect()
The methods and events are described in the TwitchChatEmitter documentation page
The Twitch PubSub implementation, as described in https://dev.twitch.tv/docs/pubsub/ .
The API module must be instanced with the following config object:
Name | Type | Description |
---|---|---|
logger | object | The logger object. |
authToken | string | The Twitch with OAuth token. |
reconnect | string | Reconnect to Twitch PubSub when disconnected from server. Default: false |
Example:
const { WebHook } = require('twitch-toolkit');
const twitchWebHook = new WebHook({
client_id: 'id-string',
callbackUrl: 'http://domain/path/to/cbUrl'
});
The Webhook/WebSub requires a public endpoint on the running server/application to receive the data from the hub. Without this, its impossible to make this work.
The methods and events are described in the PubSub documentation page
The Twitch Webhooks implementation, as described in https://dev.twitch.tv/docs/api/webhooks-guide/ .
The API module must be instanced with the following config object:
Name | Type | Description |
---|---|---|
client_id | string | The client ID of the user to be passed to the Hub (un)subscribe requests. This is required. |
callbackUrl | string | The callback URL that will receive the Hub requests. These requests should be forwarded to the handleRequest method to properly handle these data. This is required. |
logger | object | The logger object. |
Example:
const { WebHook } = require('twitch-toolkit');
const twitchWebHook = new WebHook({
client_id: 'id-string',
callbackUrl: 'http://domain/path/to/cbUrl'
});
The Webhook/WebSub requires a public endpoint on the running server/application to receive the data from the hub. Without this, its impossible to make this work.
The methods and events are described in the WebHook documentation page
The module uses Mocha with Chai for unit tests and Istanbul for test coverage reports.
To run the mocha tests:
$ npm run test
To run tests in debug mode (--inspect-brk)
$ npm run test:debug
To run the tests with the coverage report:
$ npm run test:coverage
To properly run the tests, the following Environment Variables must be set:
Var Name | Value |
---|---|
TWITCH_CLIENT_ID | The Client-ID to be used to make the API calls. |
TWITCH_CLIENT_SECRET | The Client Secret to be used to make the API calls. |
TWITCH_CLIENT_USERNAME | The Username related to the Client-ID |
TWITCH_CLIENT_PASSWORD | The OAUTH password. It can be generated here. |
TWITCH_PUBSUB_CHANNEL_ID | The ID for the channel used in the PubSub tests. |
TWITCH_PUBSUB_AUTH_TOKEN | The OAUTH token for the PubSub with the proper scopes. |
Licensed under the MIT License.
FAQs
A set of tools to integrate with Twitch API, Twitch Chat and Twitch WebHooks.
The npm package twitch-toolkit receives a total of 0 weekly downloads. As such, twitch-toolkit popularity was classified as not popular.
We found that twitch-toolkit demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.