https://github.com/ipshipyard/js-libp2p-auto-tls
Automatically acquire a <peerId>.libp2p.direct TLS certificate
https://github.com/ipshipyard/js-libp2p-auto-tls
Last synced: 2 months ago
JSON representation
Automatically acquire a <peerId>.libp2p.direct TLS certificate
- Host: GitHub
- URL: https://github.com/ipshipyard/js-libp2p-auto-tls
- Owner: ipshipyard
- License: apache-2.0
- Created: 2025-02-07T14:05:16.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-10-02T15:17:12.000Z (7 months ago)
- Last Synced: 2025-10-02T15:44:29.627Z (7 months ago)
- Language: TypeScript
- Homepage:
- Size: 79.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE-APACHE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# @ipshipyard/libp2p-auto-tls
[](https://codecov.io/gh/ipshipyard/js-libp2p-auto-tls)
[](https://github.com/ipshipyard/js-libp2p-auto-tls/actions/workflows/js-test-and-release.yml?query=branch%3Amain)
> Automatically acquire a .libp2p.direct TLS certificate
# About
When a publicly dialable address is detected, use the p2p-forge service at
to acquire a valid Let's Encrypt-backed
TLS certificate, which the node can then use with the relevant transports.
The node must be configured with a listener for at least one of the following
transports:
- TCP or WS or WSS, (along with the Yamux multiplexer and TLS or Noise encryption)
- QUIC-v1
- WebTransport
It also requires the Identify protocol.
## Example - Use UPnP to hole punch and auto-upgrade to Secure WebSockets
```TypeScript
import { noise } from '@chainsafe/libp2p-noise'
import { yamux } from '@chainsafe/libp2p-yamux'
import { autoTLS } from '@ipshipyard/libp2p-auto-tls'
import { identify } from '@libp2p/identify'
import { keychain } from '@libp2p/keychain'
import { webSockets } from '@libp2p/websockets'
import { uPnPNAT } from '@libp2p/upnp-nat'
import { createLibp2p } from 'libp2p'
const node = await createLibp2p({
addresses: {
listen: [
'/ip4/0.0.0.0/tcp/0/ws'
]
},
transports: [
webSockets()
],
connectionEncrypters: [
noise()
],
streamMuxers: [
yamux()
],
services: {
autoTLS: autoTLS(),
identify: identify(),
keychain: keychain(),
upnp: uPnPNAT()
}
})
// ...time passes
console.info(node.getMultiaddrs())
// includes public WSS address:
// [ '/ip4/123.123.123.123/tcp/12345/wss ]
```
# Install
```console
$ npm i @ipshipyard/libp2p-auto-tls
```
# License
Licensed under either of
- Apache 2.0, ([LICENSE-APACHE](https://github.com/ipshipyard/js-libp2p-auto-tls/LICENSE-APACHE) / )
- MIT ([LICENSE-MIT](https://github.com/ipshipyard/js-libp2p-auto-tls/LICENSE-MIT) / )
# Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.