
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.
npm install genii
There is just one function:
import { range } from "genii";
The range
function creates a lazy generator sequence:
import { range } from "genii";
for(let i of range(5)) {
console.log(i)
}
// 0, 1, 2, 3, 4
The range
iterator is augumented with some useful methods:
let numbers =
range(100)
.filter(i => i % 2 == 0)
.map(i => i * 10)
.offset(20)
.limit(5);
for(let i of numbers) {
console.log(i)
}
// 400
// 420
// 440
// 460
// 480
Use the array
method to collect the iteration result into an array:
range(100)
.filter(i => i % 2 == 0)
.map(i => i * 10)
.offset(20)
.limit(5)
.array();
// [ 400, 420, 440, 460, 480 ]
Iterating through an array with range
:
for(let value of range([1,2,3]).map(i => i * 10)) {
console.log(value);
}
// 10
// 20
// 30
Iterating through an object with range
:
for(let value of range({a: 1, b: 2, c: 3}).map(i => i * 10)) {
console.log(value);
}
// 10
// 20
// 30
The dict
method makes it easy to create dictionaries. To convert an array to a dictionary (using the array index as key):
range([0,1,2]).dict()
// { '0': 0, '1': 1, '2': 2 }
We can achieve the same result with a number range:
range(3).dict()
// { '0': 0, '1': 1, '2': 2 }
Instead of using the position as key, we can use the reindex
method to change the keys:
range(3).reindex(val => `key-${val}`).dict()
{ 'key-0': 0, 'key-1': 1, 'key-2': 2 }
We also reindex an object:
range({a: 1, b: 2, c: 3}).reindex(val => `key-${val}`).dict()
// { 'key-1': 1, 'key-2': 2, 'key-3': 3 }
Under the hood, the genii iterator aguments the ES6 iteration protocol with the index
property:
interface Next<K, V> {
done: boolean;
value?: V;
index?: K;
}
By doing this, we can treat objects and arrays as interchangeable.
index
as the key.value
.export function range<T>(dict: { [key: string]: T }): IndexGenerator<string, T>;
export function range<T>(arg: T[]): IndexGenerator<number, T>;
export function range(rangeEnd: number): IndexGenerator<number, number>;
export function range(rangeStart: number, rangeEnd: number): IndexGenerator<number, number>;
export function range(rangeStart: number, rangeEnd: number, step: number): IndexGenerator<number, number>;
interface IndexGenerator<K, V> {
// Next item.
next(): Next<K, V>;
// Filter the sequence.
filter(fn: FilterFunction<K, V>): IndexGenerator<K, V>;
// Transform the sequence.
map<Result>(fn: MapFunction<K, V, Result>): IndexGenerator<K, Result>;
// Transform the index of the sequence.
reindex<Result>(fn: IndexFunction<K, V, Result>): IndexGenerator<Result, V>;
// Restrict the length of the sequence.
limit(size: number): IndexGenerator<K, V>;
// Shift the sequence.
offset(offset: number): IndexGenerator<K, V>;
// Allow side-effect while iterating through the sequence.
tap(f: TapFunction<K, V>): IndexGenerator<K, V>;
// collect sequence values into array
array(): V[];
// collect sequence key/values into dictionary
dict(): { [key: string]: V }
[Symbol.iterator]: () => {
next: NextFunction<K, V>;
};
}
interface Next<K, V> {
done: boolean;
value?: V;
index?: K;
}
type FilterFunction<K, V> = (value: V, key: K) => boolean;
type MapFunction<K, V, Result> = (value: V, key: K) => Result;
type TapFunction<K, V> = (value: V, key: K) => any;
type IndexFunction<K, V, Result> = (value: V, index: K) => Result;
type NextFunction<K, V> = () => Next<K, V>;
FAQs
``` npm install genii ```
We found that genii 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
/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.