
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.
@iobroker/webserver
Advanced tools
This module provides a webserver, which automatically takes care of certificate handling using the ioBroker certificates.
Install via npm i @iobroker/webserver
.
Use the webserver in your ioBroker adapter as the following:
import { WebServer } from '@iobroker/webserver';
const webServer = new WebServer({ app, adapter, secure: true });
// initialize and you can use your server as known
const server = await webServer.init();
const { WebServer } = require('@iobroker/webserver');
const webServer = new WebServer({ app, adapter, secure: true });
// initialize and you can use your server as known
const server = await webServer.init();
And so you can use CertificateManager
that is used in the WebServer already:
import { CertificateManager } from '@iobroker/webserver';
// Not required for server
const certManager = new CertificateManager({ adapter });
// get all collections
const collections = await certManager.getAllCollections();
const { CertificateManager } = require('@iobroker/webserver');
// Not required for server
const certManager = new CertificateManager({ adapter });
// get all collections
const collections = await certManager.getAllCollections();
You can activate the OAuth2 support for the webserver. To do this, add the following code after the server is initialized:
// ... initialization of the webserver
this.webServer.app.use(cookieParser());
this.webServer.app.use(bodyParser.urlencoded({ extended: true }));
this.webServer.app.use(bodyParser.json());
this.webServer.app.use(bodyParser.text());
// Install oauth2 server (Only this line is required)
createOAuth2Server(this, { app: this.webServer.app, secure: this.config.secure, withSession: true });
// Old authentication method
this.webServer.app.use(
session({
secret: this.secret,
saveUninitialized: true,
resave: true,
cookie: { maxAge: (parseInt(this.config.ttl as string, 10) || 3600) * 1000, httpOnly: false }, // default TTL
// @ts-expect-error missing typing
store: this.store!,
}),
);
If you want to completely disable old authentication method, the code should looks like:
// ... initialization of the webserver
this.webServer.app.use(cookieParser());
this.webServer.app.use(bodyParser.urlencoded({ extended: true }));
this.webServer.app.use(bodyParser.json());
this.webServer.app.use(bodyParser.text());
// Install oauth2 server (Only this line is required)
createOAuth2Server(this, { app: this.webServer.app, secure: this.config.secure });
Login with OAuth2 is available under /oauth/token
URL:
POST /oauth/token HTTP/1.1
Host: IP:PORT
Content-Type: application/x-www-form-urlencoded
Data: grant_type=password&username=<user>&password=<password>&client_id=ioBroker&stayloggedin=<false/true>
stayloggedin=true
means that the token will be stored in the browser and will be used for the next requests and is optional.
The answer is like:
{
"access_token": "21f89e3eee32d3af08a71c1cc44ec72e0e3014a9",
"expires_in": 3600,
"refresh_token": "66d35faa5d53ca8242cfe57367210e76b7ffded7",
"refresh_token_expires_in": "600000",
"token_type": "Bearer"
}
Refresh token is available under /oauth/token
URL:
POST /oauth/token HTTP/1.1
Host: IP:PORT
Content-Type: application/x-www-form-urlencoded
Data: grant_type=refresh_token&refresh_token=<REFRESH_TOKEN>&client_id=ioBroker&stayloggedin=<false/true>
The answer is the same as for the login but with new tokens.
@iobroker/eslint-config
for lintinggetCertificatesAsync
Webserver
to WebServer
FAQs
## Description
The npm package @iobroker/webserver receives a total of 2,012 weekly downloads. As such, @iobroker/webserver popularity was classified as popular.
We found that @iobroker/webserver demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 6 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.