Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
A Node.js wrapper for Twitch.tv's API.
This package adds a useful abstraction layer to make it easier for developers to interact with the API.
Please note that versions 2.0.0 and later are NOT backwards compatible with earlier versions. There were significant structural overhauls made to this project. Node-ttv is much easier to use now, so depending on how deeply integrated this package is in your project, migrating may not be too difficult.
In order to interact with Twitch's API, you must have a registered application with a client ID and secret. You can register a new application here.
Create a new project with either npm or yarn. Install the node-ttv package:
npm install node-ttv
or
yarn add node-ttv
const { Twitch } = require('node-ttv')
const myTwitchApplication = new Twitch(CLIENT_ID, SECRET);
Requests that do not require user authentication can be made with no further setup required. Endpoints are sorted by resource as specificed by Twitch.tv's API documentation. Refer to their documentation for information on endpoint behavior.
All endpoint functions return a Promise<string>
which is a serialized JSON object. Make sure you treat the return value as a Promise<>
, using .then()
or await
.
myTwitchApplication.helix.chat.getGlobalEmotes().then(console.log)
Making requests on behalf of a user requires their authentication. Node-ttv can generate OAuth 2.0 links to send your users so they can authenticate your app with provided scopes. Read more about how authentication works here.
Your implementation is responsible for handling and storing user access tokens, as well as serving authentication links to users and retrieving access tokens from the redirect.
At this point in time there are no plans to implement support for OIDC tokens. As a result, the Extensions
resource is not supported by node-ttv.
const { Twitch, OAuth, Scopes } = require('node-ttv')
const myTwitchApplication = new Twitch(CLIENT_ID, SECRET);
// Implicit code flow
let sendThisToUser = OAuth.implicitUserAccessToken(CLIENT_ID, REDIRECT_URL, [Scopes.CHANNEL_READ_REDEMPTIONS]);
let orThis = myTwitchApplication.oauth.implicitUserAccessToken(REDIRECT_URL, [Scopes.CHANNEL_READ_REDEMPTIONS]);
// Authorization code flow
let sendThisToUser = OAuth.authorizationUserAccessToken(CLIENT_ID, REDIRECT_URL, [Scopes.CHANNEL_READ_REDEMPTIONS]);
let orThis = myTwitchApplication.oauth.authorizationUserAccessToken(REDIRECT_URL, [Scopes.CHANNEL_READ_REDEMPTIONS]);
In this example, USER_ACCESS_TOKEN has been generated with Scopes.CHANNEL_EDIT_COMMERCIAL
and '123456789'
is their broadcaster_id
.
myTwitchApplication.ads.startCommercial(USER_ACCESS_TOKEN, '123456789', 30);
Node-ttv is licensed under the MIT permissive license. You may use this package in your projects freely, and no warranty is provided. Read the provided LICENSE file for the complete license text.
FAQs
A Node.js wrapper for Twitch.tv's helix API.
We found that node-ttv 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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.