ENF News Bot
Automated News Bot
- Joined
- Apr 15, 2022
- Messages
- 2,591
When using a Worker with the
This make it easier to reuse existing Node.js code in Workers or use npm packages that depend on these APIs.
The full
You can use it to verify and sign data:
Or, to encrypt and decrypt data:
See the
The following APIs from
This enables secure connections over TLS (Transport Layer Security) to external services.
See the
Continue reading...
nodejs_compat compatibility flag enabled, the following Node.js APIs are now available:This make it easier to reuse existing Node.js code in Workers or use npm packages that depend on these APIs.
node:crypto
https://developers.cloudflare.com/changelog/rss/#nodecryptoThe full
node:crypto ↗︎ API is now available in Workers.You can use it to verify and sign data:
Code:
import { sign, verify } from "node:crypto";
const signature = sign("sha256", "-data to sign-", env.PRIVATE_KEY);
const verified = verify("sha256", "-data to sign-", env.PUBLIC_KEY, signature);
Or, to encrypt and decrypt data:
Code:
import { publicEncrypt, privateDecrypt } from "node:crypto";
const encrypted = publicEncrypt(env.PUBLIC_KEY, "some data");
const plaintext = privateDecrypt(env.PRIVATE_KEY, encrypted);
See the
node:crypto documentation for more information.node:tls
https://developers.cloudflare.com/changelog/rss/#nodetlsThe following APIs from
node:tls are now available:This enables secure connections over TLS (Transport Layer Security) to external services.
Code:
import { connect } from "node:tls";
// ... in a request handler ...
const connectionOptions = { key: env.KEY, cert: env.CERT };
const socket = connect(url, connectionOptions, () => {
if (socket.authorized) {
console.log("Connection authorized");
}
});
socket.on("data", (data) => {
console.log(data);
});
socket.on("end", () => {
console.log("server ends connection");
});
See the
node:tls documentation for more information.Continue reading...