feat: convert to typescript (#1172)
Converts this module to typescript.
- Ecosystem modules renamed from (e.g.) `libp2p-tcp` to `@libp2p/tcp`
- Ecosystem module now have named exports
- Configuration has been updated, now pass instances of modules instead of classes:
- Some configuration keys have been renamed to make them more descriptive. `transport` -> `transports`, `connEncryption` -> `connectionEncryption`. In general where we pass multiple things, the key is now plural, e.g. `streamMuxer` -> `streamMuxers`, `contentRouting` -> `contentRouters`, etc. Where we are configuring a singleton the config key is singular, e.g. `connProtector` -> `connectionProtector` etc.
- Properties of the `modules` config key have been moved to the root
- Properties of the `config` config key have been moved to the root
```js
// before
import Libp2p from 'libp2p'
import TCP from 'libp2p-tcp'
await Libp2p.create({
modules: {
transport: [
TCP
],
}
config: {
transport: {
[TCP.tag]: {
foo: 'bar'
}
},
relay: {
enabled: true,
hop: {
enabled: true,
active: true
}
}
}
})
```
```js
// after
import { createLibp2p } from 'libp2p'
import { TCP } from '@libp2p/tcp'
await createLibp2p({
transports: [
new TCP({ foo: 'bar' })
],
relay: {
enabled: true,
hop: {
enabled: true,
active: true
}
}
})
```
- Use of `enabled` flag has been reduced - previously you could pass a module but disable it with config. Now if you don't want a feature, just don't pass an implementation. Eg:
```js
// before
await Libp2p.create({
modules: {
transport: [
TCP
],
pubsub: Gossipsub
},
config: {
pubsub: {
enabled: false
}
}
})
```
```js
// after
await createLibp2p({
transports: [
new TCP()
]
})
```
- `.multiaddrs` renamed to `.getMultiaddrs()` because it's not a property accessor, work is done by that method to calculate announce addresses, observed addresses, etc
- `/p2p/${peerId}` is now appended to all addresses returned by `.getMultiaddrs()` so they can be used opaquely (every consumer has to append the peer ID to the address to actually use it otherwise). If you need low-level unadulterated addresses, call methods on the address manager.
BREAKING CHANGE: types are no longer hand crafted, this module is now ESM only
2022-03-28 14:30:27 +01:00
|
|
|
export enum messages {
|
|
|
|
NOT_STARTED_YET = 'The libp2p node is not started yet',
|
|
|
|
DHT_DISABLED = 'DHT is not available',
|
2022-04-21 15:46:06 +01:00
|
|
|
PUBSUB_DISABLED = 'PubSub is not available',
|
feat: convert to typescript (#1172)
Converts this module to typescript.
- Ecosystem modules renamed from (e.g.) `libp2p-tcp` to `@libp2p/tcp`
- Ecosystem module now have named exports
- Configuration has been updated, now pass instances of modules instead of classes:
- Some configuration keys have been renamed to make them more descriptive. `transport` -> `transports`, `connEncryption` -> `connectionEncryption`. In general where we pass multiple things, the key is now plural, e.g. `streamMuxer` -> `streamMuxers`, `contentRouting` -> `contentRouters`, etc. Where we are configuring a singleton the config key is singular, e.g. `connProtector` -> `connectionProtector` etc.
- Properties of the `modules` config key have been moved to the root
- Properties of the `config` config key have been moved to the root
```js
// before
import Libp2p from 'libp2p'
import TCP from 'libp2p-tcp'
await Libp2p.create({
modules: {
transport: [
TCP
],
}
config: {
transport: {
[TCP.tag]: {
foo: 'bar'
}
},
relay: {
enabled: true,
hop: {
enabled: true,
active: true
}
}
}
})
```
```js
// after
import { createLibp2p } from 'libp2p'
import { TCP } from '@libp2p/tcp'
await createLibp2p({
transports: [
new TCP({ foo: 'bar' })
],
relay: {
enabled: true,
hop: {
enabled: true,
active: true
}
}
})
```
- Use of `enabled` flag has been reduced - previously you could pass a module but disable it with config. Now if you don't want a feature, just don't pass an implementation. Eg:
```js
// before
await Libp2p.create({
modules: {
transport: [
TCP
],
pubsub: Gossipsub
},
config: {
pubsub: {
enabled: false
}
}
})
```
```js
// after
await createLibp2p({
transports: [
new TCP()
]
})
```
- `.multiaddrs` renamed to `.getMultiaddrs()` because it's not a property accessor, work is done by that method to calculate announce addresses, observed addresses, etc
- `/p2p/${peerId}` is now appended to all addresses returned by `.getMultiaddrs()` so they can be used opaquely (every consumer has to append the peer ID to the address to actually use it otherwise). If you need low-level unadulterated addresses, call methods on the address manager.
BREAKING CHANGE: types are no longer hand crafted, this module is now ESM only
2022-03-28 14:30:27 +01:00
|
|
|
CONN_ENCRYPTION_REQUIRED = 'At least one connection encryption module is required',
|
|
|
|
ERR_TRANSPORTS_REQUIRED = 'At least one transport module is required',
|
|
|
|
ERR_PROTECTOR_REQUIRED = 'Private network is enforced, but no protector was provided',
|
|
|
|
NOT_FOUND = 'Not found'
|
|
|
|
}
|
|
|
|
|
|
|
|
export enum codes {
|
|
|
|
DHT_DISABLED = 'ERR_DHT_DISABLED',
|
2022-04-21 15:46:06 +01:00
|
|
|
ERR_PUBSUB_DISABLED = 'ERR_PUBSUB_DISABLED',
|
feat: convert to typescript (#1172)
Converts this module to typescript.
- Ecosystem modules renamed from (e.g.) `libp2p-tcp` to `@libp2p/tcp`
- Ecosystem module now have named exports
- Configuration has been updated, now pass instances of modules instead of classes:
- Some configuration keys have been renamed to make them more descriptive. `transport` -> `transports`, `connEncryption` -> `connectionEncryption`. In general where we pass multiple things, the key is now plural, e.g. `streamMuxer` -> `streamMuxers`, `contentRouting` -> `contentRouters`, etc. Where we are configuring a singleton the config key is singular, e.g. `connProtector` -> `connectionProtector` etc.
- Properties of the `modules` config key have been moved to the root
- Properties of the `config` config key have been moved to the root
```js
// before
import Libp2p from 'libp2p'
import TCP from 'libp2p-tcp'
await Libp2p.create({
modules: {
transport: [
TCP
],
}
config: {
transport: {
[TCP.tag]: {
foo: 'bar'
}
},
relay: {
enabled: true,
hop: {
enabled: true,
active: true
}
}
}
})
```
```js
// after
import { createLibp2p } from 'libp2p'
import { TCP } from '@libp2p/tcp'
await createLibp2p({
transports: [
new TCP({ foo: 'bar' })
],
relay: {
enabled: true,
hop: {
enabled: true,
active: true
}
}
})
```
- Use of `enabled` flag has been reduced - previously you could pass a module but disable it with config. Now if you don't want a feature, just don't pass an implementation. Eg:
```js
// before
await Libp2p.create({
modules: {
transport: [
TCP
],
pubsub: Gossipsub
},
config: {
pubsub: {
enabled: false
}
}
})
```
```js
// after
await createLibp2p({
transports: [
new TCP()
]
})
```
- `.multiaddrs` renamed to `.getMultiaddrs()` because it's not a property accessor, work is done by that method to calculate announce addresses, observed addresses, etc
- `/p2p/${peerId}` is now appended to all addresses returned by `.getMultiaddrs()` so they can be used opaquely (every consumer has to append the peer ID to the address to actually use it otherwise). If you need low-level unadulterated addresses, call methods on the address manager.
BREAKING CHANGE: types are no longer hand crafted, this module is now ESM only
2022-03-28 14:30:27 +01:00
|
|
|
PUBSUB_NOT_STARTED = 'ERR_PUBSUB_NOT_STARTED',
|
|
|
|
DHT_NOT_STARTED = 'ERR_DHT_NOT_STARTED',
|
|
|
|
CONN_ENCRYPTION_REQUIRED = 'ERR_CONN_ENCRYPTION_REQUIRED',
|
|
|
|
ERR_TRANSPORTS_REQUIRED = 'ERR_TRANSPORTS_REQUIRED',
|
|
|
|
ERR_PROTECTOR_REQUIRED = 'ERR_PROTECTOR_REQUIRED',
|
|
|
|
ERR_PEER_DIAL_INTERCEPTED = 'ERR_PEER_DIAL_INTERCEPTED',
|
|
|
|
ERR_CONNECTION_INTERCEPTED = 'ERR_CONNECTION_INTERCEPTED',
|
|
|
|
ERR_INVALID_PROTOCOLS_FOR_STREAM = 'ERR_INVALID_PROTOCOLS_FOR_STREAM',
|
|
|
|
ERR_CONNECTION_ENDED = 'ERR_CONNECTION_ENDED',
|
|
|
|
ERR_CONNECTION_FAILED = 'ERR_CONNECTION_FAILED',
|
|
|
|
ERR_NODE_NOT_STARTED = 'ERR_NODE_NOT_STARTED',
|
|
|
|
ERR_ALREADY_ABORTED = 'ERR_ALREADY_ABORTED',
|
|
|
|
ERR_TOO_MANY_ADDRESSES = 'ERR_TOO_MANY_ADDRESSES',
|
|
|
|
ERR_NO_VALID_ADDRESSES = 'ERR_NO_VALID_ADDRESSES',
|
|
|
|
ERR_RELAYED_DIAL = 'ERR_RELAYED_DIAL',
|
|
|
|
ERR_DIALED_SELF = 'ERR_DIALED_SELF',
|
|
|
|
ERR_DISCOVERED_SELF = 'ERR_DISCOVERED_SELF',
|
|
|
|
ERR_DUPLICATE_TRANSPORT = 'ERR_DUPLICATE_TRANSPORT',
|
|
|
|
ERR_ENCRYPTION_FAILED = 'ERR_ENCRYPTION_FAILED',
|
|
|
|
ERR_HOP_REQUEST_FAILED = 'ERR_HOP_REQUEST_FAILED',
|
|
|
|
ERR_INVALID_KEY = 'ERR_INVALID_KEY',
|
|
|
|
ERR_INVALID_MESSAGE = 'ERR_INVALID_MESSAGE',
|
|
|
|
ERR_INVALID_PARAMETERS = 'ERR_INVALID_PARAMETERS',
|
|
|
|
ERR_INVALID_PEER = 'ERR_INVALID_PEER',
|
|
|
|
ERR_MUXER_UNAVAILABLE = 'ERR_MUXER_UNAVAILABLE',
|
|
|
|
ERR_NOT_FOUND = 'ERR_NOT_FOUND',
|
|
|
|
ERR_TIMEOUT = 'ERR_TIMEOUT',
|
|
|
|
ERR_TRANSPORT_UNAVAILABLE = 'ERR_TRANSPORT_UNAVAILABLE',
|
|
|
|
ERR_TRANSPORT_DIAL_FAILED = 'ERR_TRANSPORT_DIAL_FAILED',
|
|
|
|
ERR_UNSUPPORTED_PROTOCOL = 'ERR_UNSUPPORTED_PROTOCOL',
|
|
|
|
ERR_PROTOCOL_HANDLER_ALREADY_REGISTERED = 'ERR_PROTOCOL_HANDLER_ALREADY_REGISTERED',
|
|
|
|
ERR_INVALID_MULTIADDR = 'ERR_INVALID_MULTIADDR',
|
|
|
|
ERR_SIGNATURE_NOT_VALID = 'ERR_SIGNATURE_NOT_VALID',
|
|
|
|
ERR_FIND_SELF = 'ERR_FIND_SELF',
|
|
|
|
ERR_NO_ROUTERS_AVAILABLE = 'ERR_NO_ROUTERS_AVAILABLE',
|
|
|
|
ERR_CONNECTION_NOT_MULTIPLEXED = 'ERR_CONNECTION_NOT_MULTIPLEXED',
|
|
|
|
ERR_NO_DIAL_TOKENS = 'ERR_NO_DIAL_TOKENS',
|
|
|
|
ERR_KEYCHAIN_REQUIRED = 'ERR_KEYCHAIN_REQUIRED',
|
|
|
|
ERR_INVALID_CMS = 'ERR_INVALID_CMS',
|
|
|
|
ERR_MISSING_KEYS = 'ERR_MISSING_KEYS',
|
|
|
|
ERR_NO_KEY = 'ERR_NO_KEY',
|
|
|
|
ERR_INVALID_KEY_NAME = 'ERR_INVALID_KEY_NAME',
|
|
|
|
ERR_INVALID_KEY_TYPE = 'ERR_INVALID_KEY_TYPE',
|
|
|
|
ERR_KEY_ALREADY_EXISTS = 'ERR_KEY_ALREADY_EXISTS',
|
|
|
|
ERR_INVALID_KEY_SIZE = 'ERR_INVALID_KEY_SIZE',
|
|
|
|
ERR_KEY_NOT_FOUND = 'ERR_KEY_NOT_FOUND',
|
|
|
|
ERR_OLD_KEY_NAME_INVALID = 'ERR_OLD_KEY_NAME_INVALID',
|
|
|
|
ERR_NEW_KEY_NAME_INVALID = 'ERR_NEW_KEY_NAME_INVALID',
|
|
|
|
ERR_PASSWORD_REQUIRED = 'ERR_PASSWORD_REQUIRED',
|
|
|
|
ERR_PEM_REQUIRED = 'ERR_PEM_REQUIRED',
|
|
|
|
ERR_CANNOT_READ_KEY = 'ERR_CANNOT_READ_KEY',
|
|
|
|
ERR_MISSING_PRIVATE_KEY = 'ERR_MISSING_PRIVATE_KEY',
|
|
|
|
ERR_MISSING_PUBLIC_KEY = 'ERR_MISSING_PUBLIC_KEY',
|
|
|
|
ERR_INVALID_OLD_PASS_TYPE = 'ERR_INVALID_OLD_PASS_TYPE',
|
|
|
|
ERR_INVALID_NEW_PASS_TYPE = 'ERR_INVALID_NEW_PASS_TYPE',
|
|
|
|
ERR_INVALID_PASS_LENGTH = 'ERR_INVALID_PASS_LENGTH',
|
|
|
|
ERR_NOT_IMPLEMENTED = 'ERR_NOT_IMPLEMENTED',
|
|
|
|
ERR_WRONG_PING_ACK = 'ERR_WRONG_PING_ACK',
|
2022-05-18 15:53:58 +02:00
|
|
|
ERR_INVALID_RECORD = 'ERR_INVALID_RECORD',
|
|
|
|
ERR_ALREADY_SUCCEEDED = 'ERR_ALREADY_SUCCEEDED'
|
feat: convert to typescript (#1172)
Converts this module to typescript.
- Ecosystem modules renamed from (e.g.) `libp2p-tcp` to `@libp2p/tcp`
- Ecosystem module now have named exports
- Configuration has been updated, now pass instances of modules instead of classes:
- Some configuration keys have been renamed to make them more descriptive. `transport` -> `transports`, `connEncryption` -> `connectionEncryption`. In general where we pass multiple things, the key is now plural, e.g. `streamMuxer` -> `streamMuxers`, `contentRouting` -> `contentRouters`, etc. Where we are configuring a singleton the config key is singular, e.g. `connProtector` -> `connectionProtector` etc.
- Properties of the `modules` config key have been moved to the root
- Properties of the `config` config key have been moved to the root
```js
// before
import Libp2p from 'libp2p'
import TCP from 'libp2p-tcp'
await Libp2p.create({
modules: {
transport: [
TCP
],
}
config: {
transport: {
[TCP.tag]: {
foo: 'bar'
}
},
relay: {
enabled: true,
hop: {
enabled: true,
active: true
}
}
}
})
```
```js
// after
import { createLibp2p } from 'libp2p'
import { TCP } from '@libp2p/tcp'
await createLibp2p({
transports: [
new TCP({ foo: 'bar' })
],
relay: {
enabled: true,
hop: {
enabled: true,
active: true
}
}
})
```
- Use of `enabled` flag has been reduced - previously you could pass a module but disable it with config. Now if you don't want a feature, just don't pass an implementation. Eg:
```js
// before
await Libp2p.create({
modules: {
transport: [
TCP
],
pubsub: Gossipsub
},
config: {
pubsub: {
enabled: false
}
}
})
```
```js
// after
await createLibp2p({
transports: [
new TCP()
]
})
```
- `.multiaddrs` renamed to `.getMultiaddrs()` because it's not a property accessor, work is done by that method to calculate announce addresses, observed addresses, etc
- `/p2p/${peerId}` is now appended to all addresses returned by `.getMultiaddrs()` so they can be used opaquely (every consumer has to append the peer ID to the address to actually use it otherwise). If you need low-level unadulterated addresses, call methods on the address manager.
BREAKING CHANGE: types are no longer hand crafted, this module is now ESM only
2022-03-28 14:30:27 +01:00
|
|
|
}
|