
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
parrot-core
Advanced tools
parrot-core abstracts the matching, logging, and resolving functionality of Parrot away from each implementation. parrot-middleware and parrot-fetch use parrot-core and any new implementations could extend parrot-core in a similar way.
import Parrot from 'parrot-core';
class ParrotNew extends Parrot {
constructor(scenarios) {
super(scenarios);
// any constructor logic that is needed
}
normalizeRequest = request => {
// conform incoming requests to match the scenarios structure
};
resolver = request => response => {
// resolve the matched response to the implementation platform
};
}
export default ParrotNew;
parrot-core also defines several methods that can be used to interact with the scenarios that are passed in.
getActiveScenario()
Returns the name of the currently active scenario.
setActiveScenario(name)
Sets the currently active scenario.
name
(String): Scenario name.getScenarios()
Returns an array of scenario objects.
setScenarios(scenarios)
Sets scenarios
as the array of available scenarios.
scenarios
(Array or Object): Scenarios descriptor.getScenario(name)
Returns the scenario object with matching name
.
name
(String): Scenario name.setScenario(name, mocks)
Sets the mocks for scenario with matching name
.
name
(String): Scenario name.mocks
(Array): Array of mock objects.getMock(name, index)
Returns the mock at index
for scenario with matching name
.
name
(String): Scenario name.index
(Number): Mock index.setMock(name, index, mock)
Sets the mock at index
for scenario with matching name
.
name
(String): Scenario name.index
(Number): Mock index.mock
(Object): Mock object.getParams(path, route)
Extracts the route parameters from a given path
, using the specified route
.
This is useful when using the manual match
function.
path
(String): Requested URL path.route
(String): Express-style route with route parameters.const { getParams } = require('parrot-core');
const getBook = ({ url }, match) => {
const path = '/books/:bookId';
if (match({ path, method: 'GET' })) {
const { bookId } = getParams(url, path);
const requestedBook = books.find(book => book.bookId === bookId);
if (!requestedBook) {
return { status: 404 };
}
return { status: 200, body: requestedBook };
}
return null;
};
FAQs
Common Parrot functionality.
The npm package parrot-core receives a total of 769 weekly downloads. As such, parrot-core popularity was classified as not popular.
We found that parrot-core demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers 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
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.