Skip to content

Commit a4d7d07

Browse files
committed
refactor!: extract DCUtR into separate module (#2220)
BREAKING CHANGE: imports from `libp2p/dcutr` now need to be from `@libp2p/dcutr`
1 parent 6b9a473 commit a4d7d07

File tree

23 files changed

+286
-230
lines changed

23 files changed

+286
-230
lines changed

.release-please.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"packages/peer-record": {},
2222
"packages/peer-store": {},
2323
"packages/protocol-autonat": {},
24+
"packages/protocol-dcutr": {},
2425
"packages/protocol-identify": {},
2526
"packages/protocol-perf": {},
2627
"packages/protocol-ping": {},

doc/migrations/v0.46-v1.0.0.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ A migration guide for refactoring your application code from libp2p `v0.46` to `
88
- [AutoNAT](#autonat)
99
- [Ping](#ping)
1010
- [Identify](#identify)
11+
- [DCUtR](#dcutr)
1112
- [KeyChain](#keychain)
1213
- [UPnPNat](#upnpnat)
1314
- [Pnet](#pnet)
@@ -103,6 +104,36 @@ const node = await createLibp2p({
103104
})
104105
```
105106

107+
## DCUtR
108+
109+
The DCUtR service is now published in its own package.
110+
111+
**Before**
112+
113+
```ts
114+
import { createLibp2p } from 'libp2p'
115+
import { dcutrService } from 'libp2p/dcutr'
116+
117+
const node = await createLibp2p({
118+
services: {
119+
identify: dcutrService()
120+
}
121+
})
122+
```
123+
124+
**After**
125+
126+
```ts
127+
import { createLibp2p } from 'libp2p'
128+
import { dcutr } from '@libp2p/dcutr'
129+
130+
const node = await createLibp2p({
131+
services: {
132+
dcutr: dcutr()
133+
}
134+
})
135+
```
136+
106137
## KeyChain
107138

108139
The KeyChain object is no longer included on Libp2p and must be instantiated explicitly if desired.

packages/interface/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@
3939
"!dist/test",
4040
"!**/*.tsbuildinfo"
4141
],
42-
"browser": {
43-
"events": "./dist/src/events.browser.js"
44-
},
4542
"exports": {
4643
".": {
4744
"types": "./dist/src/index.d.ts",
@@ -178,5 +175,8 @@
178175
"it-drain": "^3.0.3",
179176
"sinon": "^17.0.0",
180177
"sinon-ts": "^2.0.0"
178+
},
179+
"browser": {
180+
"events": "./dist/src/events.browser.js"
181181
}
182182
}

packages/interface/src/errors.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,4 @@ export class InvalidCryptoTransmissionError extends Error {
7171
export const ERR_TIMEOUT = 'ERR_TIMEOUT'
7272
export const ERR_INVALID_PARAMETERS = 'ERR_INVALID_PARAMETERS'
7373
export const ERR_NOT_FOUND = 'ERR_NOT_FOUND'
74+
export const ERR_INVALID_MESSAGE = 'ERR_INVALID_MESSAGE'

packages/libp2p/package.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,6 @@
5252
"types": "./dist/src/circuit-relay/index.d.ts",
5353
"import": "./dist/src/circuit-relay/index.js"
5454
},
55-
"./dcutr": {
56-
"types": "./dist/src/dcutr/index.d.ts",
57-
"import": "./dist/src/dcutr/index.js"
58-
},
5955
"./fetch": {
6056
"types": "./dist/src/fetch/index.d.ts",
6157
"import": "./dist/src/fetch/index.js"

packages/libp2p/test/dcutr/dcutr.node.ts

Lines changed: 0 additions & 177 deletions
This file was deleted.

packages/logger/src/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
/**
22
* @packageDocumentation
33
*
4-
* A logger for libp2p based on the venerable [debug](https://www.npmjs.com/package/debug)
5-
* module.
4+
* A logger for libp2p based on the venerable [debug](https://www.npmjs.com/package/debug) module.
65
*
76
* @example
87
*

packages/pnet/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@libp2p/pnet",
3-
"version": "1.0.0",
3+
"version": "0.0.0",
44
"description": "Implementation of Connection protection management via a shared secret",
55
"license": "Apache-2.0 OR MIT",
66
"homepage": "https://github.com/libp2p/js-libp2p/tree/master/packages/pnet#readme",

packages/protocol-dcutr/LICENSE

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
This project is dual licensed under MIT and Apache-2.0.
2+
3+
MIT: https://www.opensource.org/licenses/mit
4+
Apache-2.0: https://www.apache.org/licenses/license-2.0
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
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
2+
3+
http://www.apache.org/licenses/LICENSE-2.0
4+
5+
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.

0 commit comments

Comments
 (0)