-
Notifications
You must be signed in to change notification settings - Fork 445
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add auto-tls service #2798
Draft
achingbrain
wants to merge
5
commits into
main
Choose a base branch
from
feat/add-auto-tls
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+578
−1
Draft
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
19de472
feat: add auto-tls service
achingbrain 9df10d4
chore: make cert compatible with https
achingbrain 6c45d37
chore: simplify interface
achingbrain c114661
chore: update renew timestamp
achingbrain 8751d89
Merge branch 'main' into feat/add-auto-tls
achingbrain File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"packages/connection-encrypter-plaintext":"2.0.10","packages/connection-encrypter-tls":"2.0.10","packages/crypto":"5.0.6","packages/interface":"2.2.0","packages/interface-compliance-tests":"6.1.8","packages/interface-internal":"2.0.10","packages/kad-dht":"14.1.0","packages/keychain":"5.0.9","packages/libp2p":"2.2.1","packages/logger":"5.1.3","packages/metrics-devtools":"1.1.8","packages/metrics-prometheus":"4.2.4","packages/metrics-simple":"1.2.6","packages/multistream-select":"6.0.8","packages/peer-collections":"6.0.10","packages/peer-discovery-bootstrap":"11.0.10","packages/peer-discovery-mdns":"11.0.10","packages/peer-id":"5.0.7","packages/peer-record":"8.0.10","packages/peer-store":"11.0.10","packages/pnet":"2.0.10","packages/protocol-autonat":"2.0.10","packages/protocol-dcutr":"2.0.10","packages/protocol-echo":"2.1.1","packages/protocol-fetch":"2.0.10","packages/protocol-identify":"3.0.10","packages/protocol-perf":"4.0.10","packages/protocol-ping":"2.0.10","packages/pubsub":"10.0.10","packages/pubsub-floodsub":"10.1.8","packages/record":"4.0.4","packages/stream-multiplexer-mplex":"11.0.10","packages/transport-circuit-relay-v2":"3.1.0","packages/transport-memory":"0.0.0","packages/transport-tcp":"10.0.11","packages/transport-webrtc":"5.0.16","packages/transport-websockets":"9.0.11","packages/transport-webtransport":"5.0.16","packages/upnp-nat":"2.0.10","packages/utils":"6.1.3"} | ||
{"packages/auto-tls":"0.0.0","packages/connection-encrypter-plaintext":"2.0.10","packages/connection-encrypter-tls":"2.0.10","packages/crypto":"5.0.6","packages/interface":"2.2.0","packages/interface-compliance-tests":"6.1.8","packages/interface-internal":"2.0.10","packages/kad-dht":"14.1.0","packages/keychain":"5.0.9","packages/libp2p":"2.2.1","packages/logger":"5.1.3","packages/metrics-devtools":"1.1.8","packages/metrics-prometheus":"4.2.4","packages/metrics-simple":"1.2.6","packages/multistream-select":"6.0.8","packages/peer-collections":"6.0.10","packages/peer-discovery-bootstrap":"11.0.10","packages/peer-discovery-mdns":"11.0.10","packages/peer-id":"5.0.7","packages/peer-record":"8.0.10","packages/peer-store":"11.0.10","packages/pnet":"2.0.10","packages/protocol-autonat":"2.0.10","packages/protocol-dcutr":"2.0.10","packages/protocol-echo":"2.1.1","packages/protocol-fetch":"2.0.10","packages/protocol-identify":"3.0.10","packages/protocol-perf":"4.0.10","packages/protocol-ping":"2.0.10","packages/pubsub":"10.0.10","packages/pubsub-floodsub":"10.1.8","packages/record":"4.0.4","packages/stream-multiplexer-mplex":"11.0.10","packages/transport-circuit-relay-v2":"3.1.0","packages/transport-memory":"0.0.0","packages/transport-tcp":"10.0.11","packages/transport-webrtc":"5.0.16","packages/transport-websockets":"9.0.11","packages/transport-webtransport":"5.0.16","packages/upnp-nat":"2.0.10","packages/utils":"6.1.3"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
This project is dual licensed under MIT and Apache-2.0. | ||
|
||
MIT: https://www.opensource.org/licenses/mit | ||
Apache-2.0: https://www.apache.org/licenses/license-2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
The MIT License (MIT) | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
# @libp2p/auto-tls | ||
|
||
[![libp2p.io](https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square)](http://libp2p.io/) | ||
[![Discuss](https://img.shields.io/discourse/https/discuss.libp2p.io/posts.svg?style=flat-square)](https://discuss.libp2p.io) | ||
[![codecov](https://img.shields.io/codecov/c/github/libp2p/js-libp2p.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p) | ||
[![CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p/main.yml?branch=main\&style=flat-square)](https://github.com/libp2p/js-libp2p/actions/workflows/main.yml?query=branch%3Amain) | ||
|
||
> Automatically acquire a <peerId>.libp2p.direct TLS certificate | ||
|
||
# About | ||
|
||
<!-- | ||
|
||
!IMPORTANT! | ||
|
||
Everything in this README between "# About" and "# Install" is automatically | ||
generated and will be overwritten the next time the doc generator is run. | ||
|
||
To make changes to this section, please update the @packageDocumentation section | ||
of src/index.js or src/index.ts | ||
|
||
To experiment with formatting, please run "npm run docs" from the root of this | ||
repo and examine the changes made. | ||
|
||
--> | ||
|
||
When a publicly dialable address is detected, use the p2p-forge service at | ||
<https://registration.libp2p.direct> to acquire a valid Let's Encrypted-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 '@libp2p/auto-tls' | ||
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(), | ||
upnp: uPnPNAT() | ||
} | ||
}) | ||
|
||
// ...time passes | ||
|
||
console.info(node.getMultiaddrs()) | ||
// includes public WSS address: | ||
// [ '/ip4/123.123.123.123/tcp/12345/wss ] | ||
``` | ||
|
||
# Install | ||
|
||
```console | ||
$ npm i @libp2p/plaintext | ||
``` | ||
|
||
## Browser `<script>` tag | ||
|
||
Loading this module through a script tag will make it's exports available as `Libp2pPlaintext` in the global namespace. | ||
|
||
```html | ||
<script src="https://unpkg.com/@libp2p/plaintext/dist/index.min.js"></script> | ||
``` | ||
|
||
# API Docs | ||
|
||
- <https://libp2p.github.io/js-libp2p/modules/_libp2p_plaintext.html> | ||
|
||
# License | ||
|
||
Licensed under either of | ||
|
||
- Apache 2.0, ([LICENSE-APACHE](https://github.com/libp2p/js-libp2p/blob/main/packages/connection-encrypter-plaintext/LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>) | ||
- MIT ([LICENSE-MIT](https://github.com/libp2p/js-libp2p/blob/main/packages/connection-encrypter-plaintext/LICENSE-MIT) / <http://opensource.org/licenses/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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
{ | ||
"name": "@libp2p/auto-tls", | ||
"version": "0.0.0", | ||
"description": "Automatically acquire a <peerId>.libp2p.direct TLS certificate", | ||
"license": "Apache-2.0 OR MIT", | ||
"homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/auto-tls#readme", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/libp2p/js-libp2p.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/libp2p/js-libp2p/issues" | ||
}, | ||
"publishConfig": { | ||
"access": "public", | ||
"provenance": true | ||
}, | ||
"type": "module", | ||
"types": "./dist/src/index.d.ts", | ||
"files": [ | ||
"src", | ||
"dist", | ||
"!dist/test", | ||
"!**/*.tsbuildinfo" | ||
], | ||
"exports": { | ||
".": { | ||
"types": "./dist/src/index.d.ts", | ||
"import": "./dist/src/index.js" | ||
} | ||
}, | ||
"eslintConfig": { | ||
"extends": "ipfs", | ||
"parserOptions": { | ||
"project": true, | ||
"sourceType": "module" | ||
} | ||
}, | ||
"scripts": { | ||
"build": "aegir build --bundle false", | ||
"test": "aegir test -t node", | ||
"clean": "aegir clean", | ||
"lint": "aegir lint", | ||
"test:node": "aegir test -t node --cov", | ||
"dep-check": "aegir dep-check", | ||
"doc-check": "aegir doc-check" | ||
}, | ||
"dependencies": { | ||
"@libp2p/http-fetch": "^2.0.2", | ||
"@libp2p/interface": "^2.2.0", | ||
"@libp2p/interface-internal": "^2.0.10", | ||
"@libp2p/utils": "^6.1.3", | ||
"@multiformats/multiaddr": "^12.3.1", | ||
"@multiformats/multiaddr-matcher": "^1.4.0", | ||
"@peculiar/webcrypto": "^1.5.0", | ||
"@peculiar/x509": "^1.12.3", | ||
"acme-client": "^5.4.0", | ||
"multiformats": "^13.3.1" | ||
}, | ||
"devDependencies": { | ||
"aegir": "^44.0.1" | ||
}, | ||
"sideEffects": false | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to add identify as per instructions