Skip to content

Commit

Permalink
refactor!: extract DCUtR into separate module (#2220)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: imports from `libp2p/dcutr` now need to be from `@libp2p/dcutr`
  • Loading branch information
achingbrain committed Nov 10, 2023
1 parent 6b9a473 commit a4d7d07
Show file tree
Hide file tree
Showing 23 changed files with 286 additions and 230 deletions.
1 change: 1 addition & 0 deletions .release-please.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"packages/peer-record": {},
"packages/peer-store": {},
"packages/protocol-autonat": {},
"packages/protocol-dcutr": {},
"packages/protocol-identify": {},
"packages/protocol-perf": {},
"packages/protocol-ping": {},
Expand Down
31 changes: 31 additions & 0 deletions doc/migrations/v0.46-v1.0.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ A migration guide for refactoring your application code from libp2p `v0.46` to `
- [AutoNAT](#autonat)
- [Ping](#ping)
- [Identify](#identify)
- [DCUtR](#dcutr)
- [KeyChain](#keychain)
- [UPnPNat](#upnpnat)
- [Pnet](#pnet)
Expand Down Expand Up @@ -103,6 +104,36 @@ const node = await createLibp2p({
})
```

## DCUtR

The DCUtR service is now published in its own package.

**Before**

```ts
import { createLibp2p } from 'libp2p'
import { dcutrService } from 'libp2p/dcutr'

const node = await createLibp2p({
services: {
identify: dcutrService()
}
})
```

**After**

```ts
import { createLibp2p } from 'libp2p'
import { dcutr } from '@libp2p/dcutr'

const node = await createLibp2p({
services: {
dcutr: dcutr()
}
})
```

## KeyChain

The KeyChain object is no longer included on Libp2p and must be instantiated explicitly if desired.
Expand Down
6 changes: 3 additions & 3 deletions packages/interface/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@
"!dist/test",
"!**/*.tsbuildinfo"
],
"browser": {
"events": "./dist/src/events.browser.js"
},
"exports": {
".": {
"types": "./dist/src/index.d.ts",
Expand Down Expand Up @@ -178,5 +175,8 @@
"it-drain": "^3.0.3",
"sinon": "^17.0.0",
"sinon-ts": "^2.0.0"
},
"browser": {
"events": "./dist/src/events.browser.js"
}
}
1 change: 1 addition & 0 deletions packages/interface/src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,4 @@ export class InvalidCryptoTransmissionError extends Error {
export const ERR_TIMEOUT = 'ERR_TIMEOUT'
export const ERR_INVALID_PARAMETERS = 'ERR_INVALID_PARAMETERS'
export const ERR_NOT_FOUND = 'ERR_NOT_FOUND'
export const ERR_INVALID_MESSAGE = 'ERR_INVALID_MESSAGE'
4 changes: 0 additions & 4 deletions packages/libp2p/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@
"types": "./dist/src/circuit-relay/index.d.ts",
"import": "./dist/src/circuit-relay/index.js"
},
"./dcutr": {
"types": "./dist/src/dcutr/index.d.ts",
"import": "./dist/src/dcutr/index.js"
},
"./fetch": {
"types": "./dist/src/fetch/index.d.ts",
"import": "./dist/src/fetch/index.js"
Expand Down
177 changes: 0 additions & 177 deletions packages/libp2p/test/dcutr/dcutr.node.ts

This file was deleted.

3 changes: 1 addition & 2 deletions packages/logger/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/**
* @packageDocumentation
*
* A logger for libp2p based on the venerable [debug](https://www.npmjs.com/package/debug)
* module.
* A logger for libp2p based on the venerable [debug](https://www.npmjs.com/package/debug) module.
*
* @example
*
Expand Down
2 changes: 1 addition & 1 deletion packages/pnet/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@libp2p/pnet",
"version": "1.0.0",
"version": "0.0.0",
"description": "Implementation of Connection protection management via a shared secret",
"license": "Apache-2.0 OR MIT",
"homepage": "https://github.com/libp2p/js-libp2p/tree/master/packages/pnet#readme",
Expand Down
4 changes: 4 additions & 0 deletions packages/protocol-dcutr/LICENSE
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
5 changes: 5 additions & 0 deletions packages/protocol-dcutr/LICENSE-APACHE
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.
19 changes: 19 additions & 0 deletions packages/protocol-dcutr/LICENSE-MIT
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.
Loading

0 comments on commit a4d7d07

Please sign in to comment.