Workers - Improved support for Node.js Crypto and TLS APIs in Workers
1y ago
Source
CloudflareWorkers - Improved support for Node.js Crypto and TLS APIs in Workerscloudflare.comWhen using a Worker with the nodejs_compat compatibility flag enabled, the following Node.js APIs are now available: node:crypto node:tls This make it easier to reuse existing Node.js code in Workers or use npm packages that depend on these APIs. node:crypto The full node:crypto API is now available in Workers. You can use it to verify and sign data: 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: 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 The following APIs from node:tls are now available: connect TLSSocket checkServerIdentity createSecureContext This enables secure connections over TLS (Transport Layer Security) to external services. 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.
You might also wanna read
Bun v1.1.45
bun.com·1y ago
Bun v1.1.32
bun.com·1y ago
IETF Draft Proposes Short-Lived Cryptographic Identities for AI Agents to Replace Long-Lived API Keys
A new IETF Internet-Draft titled "AI Agent Authentication and Authorization," authored by representatives from OpenAI, Okta, AWS, Ping, and
Bun v0.7.0
bun.com·3y ago
Bun v0.6.7
bun.com·3y ago
Using SSH Certificates for Secure Git Commit Signing and Code Authorship Verification
The article discusses the importance of code authorship verification in software development, highlighting the limitations of traditional au

Comments
Sign in to join the conversation.
No comments yet. Be the first.