forked from ChainSafe/js-libp2p-noise
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactors code to use the component logger from libp2p to allow more flexible logging patterns. Nb. adds a `NoiseComponents` interface separate from `NoiseInit` that contains the `Metrics` instance - this is consistent with every other libp2p module. Refs: https://github.com/libp2p/js-libp2p/issue/2105 Refs: libp2p/js-libp2p#2198 Refs: https://github.com/libp2p/js-libp2p/issue/378
- Loading branch information
1 parent
e4796ed
commit bc7c158
Showing
17 changed files
with
126 additions
and
104 deletions.
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
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
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,21 @@ | ||
export class UnexpectedPeerError extends Error { | ||
public code: string | ||
|
||
constructor (message = 'Unexpected Peer') { | ||
super(message) | ||
this.code = UnexpectedPeerError.code | ||
} | ||
|
||
static readonly code = 'ERR_UNEXPECTED_PEER' | ||
} | ||
|
||
export class InvalidCryptoExchangeError extends Error { | ||
public code: string | ||
|
||
constructor (message = 'Invalid crypto exchange') { | ||
super(message) | ||
this.code = InvalidCryptoExchangeError.code | ||
} | ||
|
||
static readonly code = 'ERR_INVALID_CRYPTO_EXCHANGE' | ||
} |
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
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,10 +1,15 @@ | ||
import { Noise } from './noise.js' | ||
import type { NoiseInit } from './noise.js' | ||
import type { NoiseExtensions } from './proto/payload.js' | ||
import type { ConnectionEncrypter } from '@libp2p/interface/connection-encrypter' | ||
import type { ComponentLogger, ConnectionEncrypter, Metrics } from '@libp2p/interface' | ||
export type { ICryptoInterface } from './crypto.js' | ||
export { pureJsCrypto } from './crypto/js.js' | ||
|
||
export function noise (init: NoiseInit = {}): () => ConnectionEncrypter<NoiseExtensions> { | ||
return () => new Noise(init) | ||
export interface NoiseComponents { | ||
logger: ComponentLogger | ||
metrics?: Metrics | ||
} | ||
|
||
export function noise (init: NoiseInit = {}): (components: NoiseComponents) => ConnectionEncrypter<NoiseExtensions> { | ||
return (components: NoiseComponents) => new Noise(components, init) | ||
} |
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
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
Oops, something went wrong.