
Research
lightning PyPI Package Compromised in Supply Chain Attack
Socket detected a malicious supply chain attack on PyPI package lightning versions 2.6.2 and 2.6.3, which execute credential-stealing malware on import.
opendtb-wrapper
Advanced tools
This a simple node.js module that does simple tasks - gets random questions from the Open Trivia Questions Database API - https://opentdb.com/.
To use this module, install it via NPM:
npm i opendtb-wrapper
const {Client, Defs} = require('opendtb-wrapper');
Client.get().then(console.log); // Get a random question
Client.get({amount: 5, category: Defs.CATEGORIES.ART, difficulty: 'easy', type: 'multiple'}).then(console.log) // Get 5 random questions of category "ART", with easy difficulty and with multiple answers (A, B, C, D)
const Trivia = new Client(); // Create a new instance of the client class - with caching disabled.
await Trivia.setToken(); // Make sure the token has generated before fetching questions. You do not need this if you aren't going to get questions right after creating the client.
Trivia.fetchQuestion() // get a random question. The question will be cached and it won't appear again, unless your token expires or you destroy your instance of client.
Creates a new instance of the client. The client is the main class of this package, all methods of getting questions and other information are accessed through there.
| Param | Type | Description |
|---|---|---|
| options.token | Boolean | If set to true, a token will be generated for this instance. Fetched questions won't appear twice. Default is true |
| options.cache | Boolean | If set to true, every question you fetch will be cached in a map. Default is true |
| options.noInactivity | Boolean | If false, the API will delete your token after 6 hours of inactivity. If this is set to true, your token will be renewed every 6 hours. |
Sets a token for the client. This method shouldn't be used unless you want to fetch a question RIGHT AFTER the Client class has been created.
Returns: Promise<This Client>
Fetches a single question from the database. Caches it if caching is on. All of the options are optional.
| Param | Type | Description |
|---|---|---|
| options.type | Defs.TYPES OR String | One of the Defs.TYPES. Can be boolean or multiple |
| options.difficulty | Defs.DIFFICULTIES OR String | One of the Defs.DIFFICULTIES. Can be easy, medium or hard |
| options.category | Defs.CATEGORIES | One of the Defs.CATEGORIES. |
Returns: Promise<BooleanQuestion|MultipleQuestion>
Fetches multiple questions. Caches all of them if caching is on.
| Param | Type | Description |
|---|---|---|
| options.amount | Number | How many questions should be fetched. Default is 2. Max is 50. |
| options.type | Defs.TYPES OR String | One of the Defs.TYPES. Can be boolean or multiple |
| options.difficulty | Defs.DIFFICULTIES OR String | One of the Defs.DIFFICULTIES. Can be easy, medium or hard |
| options.category | Defs.CATEGORIES | One of the Defs.CATEGORIES. |
Returns: Promise<BooleanQuestion|MultipleQuestion|(BooleanQuestion|MultipleQuestion)[]>
Finds a question based on the function provided. It gets the question from the cache, so if your caching is off, you cannot use this function. The function is similar to Array#find.
Example:
console.log(Client.find(q => q.content.includes("Mario"))) // The function will return a question that include the word "Mario" in it's content.
Returns: MultipleQuestion|BooleanQuestion
Resets your token. You do not need to worry about resetting / renewing tokens if you have the noInactiviy option on.
Returns: Promise<Boolean>
The token associated with the client.
Type: String
A map of all cached questions.
Type: Map<String, MultipleQuestion|BooleanQuestion>
Generates a token from the API.
Returns: Promise<String>
Gets question(s) from the database. Questions gotten from this function will NOT be cached and they may repeat since there is no token.
| Param | Type | Description |
|---|---|---|
| options.amount | Number | How many questions should be fetched. Default is 1. Max is 50. |
| options.type | Defs.TYPES OR String | One of the Defs.TYPES. Can be boolean or multiple |
| options.difficulty | Defs.DIFFICULTIES OR String | One of the Defs.DIFFICULTIES. Can be easy, medium or hard |
| options.category | Defs.CATEGORIES | One of the Defs.CATEGORIES. |
Returns: Promise<BooleanQuestion|MultipleQuestion|(BooleanQuestion|MultipleQuestion)[]>
Example:
Client.get({amount: 5, type: 'multiple', category: Defs.CATEGORIES.MOVIES}).then(console.log)
Client.get().then(console.log)
Get how many questions of the given category exist in the database.
| Param | Type | Description |
|---|---|---|
| category | Defs.CATEGORIES | The category |
Returns:
{
total: Number // Total amount of questions
easy: Number // Number of easy questions
medium: Number // Number of medium questions
hard: Number // Number of hard questions
}
This is a structure class. It represents a question of undefined type. This is the base class for both multiple questions and boolean questions.
The "question" of the question object.
Type: String
The type of question. Can be multiple or boolean.
Type: String
The difficulty of the question. Can be easy, medium or hard.
Type: String
The category the question is in.
Type: String
The correct answer of the question
Type: String
All the incorrect answers.
Type: String[]
The correct answer and all the incorrect answers together.
Type: String[]
Every time you get a question from the API, it's assigned a unique ID. IDs are only useful when you caching is enabled.
Type: String
This is a structure class. It represents a question with multiple answers. Let's call it MQ for short.
Shuffles the 4 options of the question (A, B, C or D). This function is automatically called when you get a MQ from the API.
Option A of the question.
Type: String
Option B of the question
Type: String
Option C of the question
Type: String
Option D of the question
Type: String
The correct option. Can be A, B, C or D.
Type: String
This is a structure class. It represents a True/False question. Let's call it BQ for short.
Overrides the default Question#correct property. If the content is true or not.
Type: Boolean
Defs.TYPES => The types of questions. boolean or multiple
Defs.CATEGORIES => All categories.
Defs.DIFFICULTIES => All difficulties. easy, medium and hard
If the provided value is a type, category or difficulty. Useful when checking user input.
Returns: Boolean
Example:
Defs.DIFFICULTIES.$has('very hard') // False
Defs.TYPES.$has('multiple') // true
Defs.CATEGORIES.$has(13) // true
This function is only available in the CATEGORIES object. Search a category by it's name.
Returns: Number
Example:
Defs.CATEGORIES.$search('music') // 12
Defs.CATEGORIES.$search('ANIME') // 31
FAQs
A simple NPM module that interacts with the Open Trivia Database API.
We found that opendtb-wrapper 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
Socket detected a malicious supply chain attack on PyPI package lightning versions 2.6.2 and 2.6.3, which execute credential-stealing malware on import.

Research
A brand-squatted TanStack npm package used postinstall scripts to steal .env files and exfiltrate developer secrets to an attacker-controlled endpoint.

Research
Compromised SAP CAP npm packages download and execute unverified binaries, creating urgent supply chain risk for affected developers and CI/CD environments.