libp2p 0.41.0-1b30f81 → 0.41.0-3e53c19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/README.md +5 -4
  2. package/dist/index.min.js +58 -0
  3. package/dist/src/address-manager/index.d.ts +8 -0
  4. package/dist/src/address-manager/index.d.ts.map +1 -1
  5. package/dist/src/address-manager/index.js.map +1 -1
  6. package/dist/src/circuit/index.d.ts +11 -1
  7. package/dist/src/circuit/index.d.ts.map +1 -1
  8. package/dist/src/circuit/index.js.map +1 -1
  9. package/dist/src/circuit/transport.d.ts +1 -1
  10. package/dist/src/circuit/transport.d.ts.map +1 -1
  11. package/dist/src/config.d.ts.map +1 -1
  12. package/dist/src/config.js +11 -2
  13. package/dist/src/config.js.map +1 -1
  14. package/dist/src/connection-manager/index.d.ts +8 -27
  15. package/dist/src/connection-manager/index.d.ts.map +1 -1
  16. package/dist/src/connection-manager/index.js +0 -4
  17. package/dist/src/connection-manager/index.js.map +1 -1
  18. package/dist/src/fetch/index.d.ts +14 -0
  19. package/dist/src/fetch/index.d.ts.map +1 -1
  20. package/dist/src/fetch/index.js +14 -0
  21. package/dist/src/fetch/index.js.map +1 -1
  22. package/dist/src/index.d.ts +123 -137
  23. package/dist/src/index.d.ts.map +1 -1
  24. package/dist/src/index.js +34 -0
  25. package/dist/src/index.js.map +1 -1
  26. package/dist/src/insecure/index.d.ts +23 -0
  27. package/dist/src/insecure/index.d.ts.map +1 -1
  28. package/dist/src/insecure/index.js +23 -0
  29. package/dist/src/insecure/index.js.map +1 -1
  30. package/dist/src/keychain/index.d.ts +2 -2
  31. package/dist/src/keychain/index.d.ts.map +1 -1
  32. package/dist/src/nat-manager.d.ts.map +1 -1
  33. package/dist/src/nat-manager.js +5 -1
  34. package/dist/src/nat-manager.js.map +1 -1
  35. package/dist/src/pnet/index.d.ts +23 -0
  36. package/dist/src/pnet/index.d.ts.map +1 -1
  37. package/dist/src/pnet/index.js +23 -0
  38. package/dist/src/pnet/index.js.map +1 -1
  39. package/package.json +8 -6
  40. package/src/address-manager/index.ts +8 -0
  41. package/src/circuit/index.ts +13 -1
  42. package/src/circuit/transport.ts +1 -1
  43. package/src/config.ts +11 -2
  44. package/src/connection-manager/index.ts +20 -47
  45. package/src/fetch/index.ts +14 -0
  46. package/src/index.ts +130 -149
  47. package/src/insecure/index.ts +24 -0
  48. package/src/keychain/index.ts +2 -2
  49. package/src/nat-manager.ts +6 -1
  50. package/src/pnet/index.ts +24 -0
  51. package/src/version.ts +1 -1
@@ -1,3 +1,27 @@
1
+ /**
2
+ * @packageDocumentation
3
+ *
4
+ * A connection encrypter that does no connection encryption.
5
+ *
6
+ * This should not be used in production should be used for research purposes only.
7
+ *
8
+ * @example
9
+ *
10
+ * ```typescript
11
+ * import { createLibp2p } from 'libp2p'
12
+ * import { plaintext } from 'libp2p/insecure'
13
+ *
14
+ * // Create a Uint8Array and write the swarm key to it
15
+ * const swarmKey = new Uint8Array(95)
16
+ * generateKey(swarmKey)
17
+ *
18
+ * const node = await createLibp2p({
19
+ * // ...other options
20
+ * connectionEncryption: [plaintext()]
21
+ * })
22
+ * ```
23
+ */
24
+
1
25
  import { logger } from '@libp2p/logger'
2
26
  import { handshake } from 'it-handshake'
3
27
  import * as lp from 'it-length-prefixed'
@@ -17,7 +17,7 @@ import type { Datastore } from 'interface-datastore'
17
17
 
18
18
  const log = logger('libp2p:keychain')
19
19
 
20
- export interface DekOptions {
20
+ export interface DEKConfig {
21
21
  hash: string
22
22
  salt: string
23
23
  iterationCount: number
@@ -26,7 +26,7 @@ export interface DekOptions {
26
26
 
27
27
  export interface KeyChainInit {
28
28
  pass?: string
29
- dek?: DekOptions
29
+ dek?: DEKConfig
30
30
  }
31
31
 
32
32
  /**
@@ -149,11 +149,16 @@ export class NatManager implements Startable {
149
149
 
150
150
  const client = await this._getClient()
151
151
  const publicIp = this.externalAddress ?? await client.externalIp()
152
+ const isPrivate = isPrivateIp(publicIp)
152
153
 
153
- if (isPrivateIp(publicIp)) {
154
+ if (isPrivate === true) {
154
155
  throw new Error(`${publicIp} is private - please set config.nat.externalIp to an externally routable IP or ensure you are not behind a double NAT`)
155
156
  }
156
157
 
158
+ if (isPrivate == null) {
159
+ throw new Error(`${publicIp} is not an IP address`)
160
+ }
161
+
157
162
  const publicPort = highPort()
158
163
 
159
164
  log(`opening uPnP connection from ${publicIp}:${publicPort} to ${host}:${port}`)
package/src/pnet/index.ts CHANGED
@@ -1,3 +1,27 @@
1
+ /**
2
+ * @packageDocumentation
3
+ *
4
+ * Connection protection management for libp2p leveraging PSK encryption via XSalsa20.
5
+ *
6
+ * @example
7
+ *
8
+ * ```typescript
9
+ * import { createLibp2p } from 'libp2p'
10
+ * import { preSharedKey, generateKey } from 'libp2p/pnet'
11
+ *
12
+ * // Create a Uint8Array and write the swarm key to it
13
+ * const swarmKey = new Uint8Array(95)
14
+ * generateKey(swarmKey)
15
+ *
16
+ * const node = await createLibp2p({
17
+ * // ...other options
18
+ * connectionProtector: preSharedKey({
19
+ * psk: swarmKey
20
+ * })
21
+ * })
22
+ * ```
23
+ */
24
+
1
25
  import { logger } from '@libp2p/logger'
2
26
  import { pipe } from 'it-pipe'
3
27
  import errCode from 'err-code'
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
- export const version = '0.41.0-1b30f81'
1
+ export const version = '0.41.0-3e53c19'
2
2
  export const name = 'libp2p'