Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
[![npm version][npm-version-src]][npm-version-href] [![npm downloads][npm-downloads-src]][npm-downloads-href] [![Github Actions][github-actions-src]][github-actions-href] [![Codecov][codecov-src]][codecov-href]
Utilities to generate JavaScript code.
# npm
npm install knitwork
# yarn
yarn install knitwork
# pnpm
pnpm install knitwork
Generating ESM syntax:
import { genImport, genExport } from 'knitwork'
// import foo from "pkg"
console.log(genImport('pkg', 'foo'))
// import { foo } from "pkg"
console.log(genImport('pkg', ['foo']))
// import { a, b } from "pkg"
console.log(genImport('pkg', ['a', 'b']))
// import foo as bar from "pkg";
console.log(genImport('pkg', { name: 'foo', as: 'bar' }))
// import { foo as bar } from "pkg";
console.log(genImport('pkg', [{ name: 'foo', as: 'bar' }]))
// export foo from "pkg"
console.log(genExport('pkg', 'foo'))
// export { a, b } from "pkg"
console.log(genExport('pkg', ['a', 'b']))
// export * as bar from "pkg"
console.log(genExport('pkg', { name: '*', as: 'bar' }))
Generating TS:
import { genInterface, genAugmentation, genInlineTypeImport, genTypeImport, genTypeExport } from 'knitwork'
// interface FooInterface extends A, B {
// name: boolean
// optional?: string
// }
console.log(genInterface('FooInterface', { name: 'boolean', 'optional?': 'string' }, { extends: ['A', 'B'] }))
// declare module "my-module" {
// interface MyInterface {}
// }
console.log(genAugmentation('my-module', { MyInterface: {} }))
// typeof import("my-module").genString'
console.log(genInlineTypeImport('my-module', 'genString'))
// typeof import("my-module").default'
console.log(genInlineTypeImport('my-module'))
// import type { test as value } from "my-module";
console.log(genTypeImport('my-module', [{ name: 'test', as: 'value' }]))
// export type { test } from "my-module";
console.log(genTypeExport('my-module', ['test']))
Serializing JS objects:
import { genObjectFromRaw, genObjectFromRawEntries, genArrayFromRaw } from 'knitwork'
// { test: () => import("pkg") }
console.log(genObjectFromRaw({ test: '() => import("pkg")' }))
// { 0: [ test, () => import("pkg") ] }
console.log(genObjectFromRaw([ ['test', '() => import("pkg")'] ]))
const entries = Object.entries({
a: 1, b: null, c: '"c"', nest: { hello: '"world"', fn: () => 1 }
})
// { a: 1, b: null, c: "c", nest: { hello: "world", fn: () => 1 } }
console.log(genObjectFromRawEntries(entries))
// [ 1, 2, () => import("pkg") ]
console.log(genArrayFromRaw(['1', '2', '() => import("pkg")']))
corepack enable
(use npm i -g corepack
for Node.js < 16.10)yarn install
yarn dev
Made with 💛
Published under MIT License.
FAQs
Utilities to generate JavaScript code.
The npm package knitwork receives a total of 413,852 weekly downloads. As such, knitwork popularity was classified as popular.
We found that knitwork 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.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.