Skip to content

Commit

Permalink
chore: bump aegir from 38.1.8 to 39.0.5 (#328)
Browse files Browse the repository at this point in the history
* chore: bump aegir from 38.1.8 to 39.0.5

Bumps [aegir](https://github.com/ipfs/aegir) from 38.1.8 to 39.0.5.
- [Release notes](https://github.com/ipfs/aegir/releases)
- [Changelog](https://github.com/ipfs/aegir/blob/master/CHANGELOG.md)
- [Commits](ipfs/aegir@v38.1.8...v39.0.5)

---
updated-dependencies:
- dependency-name: aegir
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* fix types

Signed-off-by: Marin Petrunic <marin.petrunic@gmail.com>

* fix: lint

Signed-off-by: Marin Petrunic <marin.petrunic@gmail.com>

* fix: depcheck

Signed-off-by: Marin Petrunic <marin.petrunic@gmail.com>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: Marin Petrunic <marin.petrunic@gmail.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Marin Petrunic <marin.petrunic@gmail.com>
  • Loading branch information
dependabot[bot] and mpetrunic committed May 8, 2023
1 parent 188a117 commit b269527
Show file tree
Hide file tree
Showing 20 changed files with 75 additions and 75 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@
"@libp2p/peer-id-factory": "^2.0.0",
"@libp2p/tcp": "^7.0.0",
"@multiformats/multiaddr": "^12.1.0",
"aegir": "^38.1.7",
"@types/sinon": "^10.0.14",
"aegir": "^39.0.5",
"benchmark": "^2.1.4",
"execa": "^7.0.0",
"go-libp2p": "^1.0.3",
Expand All @@ -105,8 +106,7 @@
"mkdirp": "^3.0.0",
"p-defer": "^4.0.0",
"protons": "^7.0.0",
"sinon": "^15.0.0",
"util": "^0.12.4"
"sinon": "^15.0.0"
},
"browser": {
"./dist/src/alloc-unsafe.js": "./dist/src/alloc-unsafe-browser.js",
Expand Down
2 changes: 1 addition & 1 deletion src/@types/handshake-interface.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { PeerId } from '@libp2p/interface-peer-id'
import type { bytes } from './basic.js'
import type { NoiseSession } from './handshake.js'
import type { NoiseExtensions } from '../proto/payload.js'
import type { PeerId } from '@libp2p/interface-peer-id'

export interface IHandshake {
session: NoiseSession
Expand Down
4 changes: 2 additions & 2 deletions src/@types/libp2p.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { ConnectionEncrypter } from '@libp2p/interface-connection-encrypter'
import type { NoiseExtensions } from '../proto/payload.js'
import type { bytes32 } from './basic.js'
import type { NoiseExtensions } from '../proto/payload.js'
import type { ConnectionEncrypter } from '@libp2p/interface-connection-encrypter'

export interface KeyPair {
publicKey: bytes32
Expand Down
6 changes: 3 additions & 3 deletions src/crypto/js.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as x25519 from '@stablelib/x25519'
import { sha256 } from '@noble/hashes/sha256'
import { hkdf } from '@noble/hashes/hkdf'
import { sha256 } from '@noble/hashes/sha256'
import { ChaCha20Poly1305 } from '@stablelib/chacha20poly1305'
import type { bytes32, bytes } from '../@types/basic.js'
import * as x25519 from '@stablelib/x25519'
import type { bytes, bytes32 } from '../@types/basic.js'
import type { Hkdf } from '../@types/handshake.js'
import type { KeyPair } from '../@types/libp2p.js'
import type { ICryptoInterface } from '../crypto.js'
Expand Down
8 changes: 4 additions & 4 deletions src/crypto/streaming.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { TAG_LENGTH } from '@stablelib/chacha20poly1305'
import type { Transform } from 'it-stream-types'
import type { Uint8ArrayList } from 'uint8arraylist'
import type { IHandshake } from '../@types/handshake-interface.js'
import type { MetricsRegistry } from '../metrics.js'
import { NOISE_MSG_MAX_LENGTH_BYTES, NOISE_MSG_MAX_LENGTH_BYTES_WITHOUT_TAG } from '../constants.js'
import { uint16BEEncode } from '../encoder.js'
import type { IHandshake } from '../@types/handshake-interface.js'
import type { MetricsRegistry } from '../metrics.js'
import type { Transform } from 'it-stream-types'
import type { Uint8ArrayList } from 'uint8arraylist'

// Returns generator that encrypts payload from the user
export function encryptStream (handshake: IHandshake, metrics?: MetricsRegistry): Transform<AsyncIterable<Uint8Array>> {
Expand Down
2 changes: 1 addition & 1 deletion src/encoder.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { concat as uint8ArrayConcat } from 'uint8arrays/concat'
import type { Uint8ArrayList } from 'uint8arraylist'
import type { bytes } from './@types/basic.js'
import type { MessageBuffer } from './@types/handshake.js'
import type { LengthDecoderFunction } from 'it-length-prefixed'
import type { Uint8ArrayList } from 'uint8arraylist'

const allocUnsafe = (len: number): Uint8Array => {
if (globalThis.Buffer) {
Expand Down
14 changes: 7 additions & 7 deletions src/handshake-xx.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
import type { PeerId } from '@libp2p/interface-peer-id'
import { InvalidCryptoExchangeError, UnexpectedPeerError } from '@libp2p/interface-connection-encrypter/errors'
import type { ProtobufStream } from 'it-pb-stream'
import type { bytes, bytes32 } from './@types/basic.js'
import type { CipherState, NoiseSession } from './@types/handshake.js'
import type { KeyPair } from './@types/libp2p.js'
import type { IHandshake } from './@types/handshake-interface.js'
import type { ICryptoInterface } from './crypto.js'
import { decode0, decode1, decode2, encode0, encode1, encode2 } from './encoder.js'
import { XX } from './handshakes/xx.js'
import {
Expand All @@ -21,7 +14,14 @@ import {
getPeerIdFromPayload,
verifySignedPayload
} from './utils.js'
import type { bytes, bytes32 } from './@types/basic.js'
import type { IHandshake } from './@types/handshake-interface.js'
import type { CipherState, NoiseSession } from './@types/handshake.js'
import type { KeyPair } from './@types/libp2p.js'
import type { ICryptoInterface } from './crypto.js'
import type { NoiseExtensions } from './proto/payload.js'
import type { PeerId } from '@libp2p/interface-peer-id'
import type { ProtobufStream } from 'it-pb-stream'

export class XXHandshake implements IHandshake {
public isInitiator: boolean
Expand Down
8 changes: 4 additions & 4 deletions src/handshakes/abstract-handshake.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { equals as uint8ArrayEquals } from 'uint8arrays/equals'
import { concat as uint8ArrayConcat } from 'uint8arrays/concat'
import { fromString as uint8ArrayFromString } from 'uint8arrays'
import { concat as uint8ArrayConcat } from 'uint8arrays/concat'
import { equals as uint8ArrayEquals } from 'uint8arrays/equals'
import { logger } from '../logger.js'
import { Nonce } from '../nonce.js'
import type { bytes, bytes32 } from '../@types/basic.js'
import type { CipherState, MessageBuffer, SymmetricState } from '../@types/handshake.js'
import type { ICryptoInterface } from '../crypto.js'
import { logger } from '../logger.js'
import { Nonce } from '../nonce.js'

export interface DecryptedResult {
plaintext: bytes
Expand Down
6 changes: 3 additions & 3 deletions src/handshakes/xx.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { bytes32, bytes } from '../@types/basic.js'
import type { KeyPair } from '../@types/libp2p.js'
import { isValidPublicKey } from '../utils.js'
import { AbstractHandshake, type DecryptedResult } from './abstract-handshake.js'
import type { bytes32, bytes } from '../@types/basic.js'
import type { CipherState, HandshakeState, MessageBuffer, NoiseSession } from '../@types/handshake.js'
import { AbstractHandshake, DecryptedResult } from './abstract-handshake.js'
import type { KeyPair } from '../@types/libp2p.js'

export class XX extends AbstractHandshake {
private initializeInitiator (prologue: bytes32, s: KeyPair, rs: bytes32, psk: bytes32): HandshakeState {
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { ConnectionEncrypter } from '@libp2p/interface-connection-encrypter'
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'
export type { ICryptoInterface } from './crypto.js'
export { pureJsCrypto } from './crypto/js.js'

Expand Down
4 changes: 2 additions & 2 deletions src/logger.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Logger, logger } from '@libp2p/logger'
import { type Logger, logger } from '@libp2p/logger'
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
import { DUMP_SESSION_KEYS } from './constants.js'
import type { NoiseSession } from './@types/handshake.js'
import type { KeyPair } from './@types/libp2p.js'
import { DUMP_SESSION_KEYS } from './constants.js'

const log = logger('libp2p:noise')

Expand Down
22 changes: 11 additions & 11 deletions src/noise.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import type { PeerId } from '@libp2p/interface-peer-id'
import type { SecuredConnection } from '@libp2p/interface-connection-encrypter'
import { pbStream, ProtobufStream } from 'it-pb-stream'
import { decode } from 'it-length-prefixed'
import { duplexPair } from 'it-pair/duplex'
import { pbStream, type ProtobufStream } from 'it-pb-stream'
import { pipe } from 'it-pipe'
import { decode } from 'it-length-prefixed'
import type { Duplex, Source } from 'it-stream-types'
import type { bytes } from './@types/basic.js'
import type { IHandshake } from './@types/handshake-interface.js'
import type { INoiseConnection, KeyPair } from './@types/libp2p.js'
import { NOISE_MSG_MAX_LENGTH_BYTES } from './constants.js'
import type { ICryptoInterface } from './crypto.js'
import { pureJsCrypto } from './crypto/js.js'
import { decryptStream, encryptStream } from './crypto/streaming.js'
import { uint16BEDecode, uint16BEEncode } from './encoder.js'
import { XXHandshake } from './handshake-xx.js'
import { type MetricsRegistry, registerMetrics } from './metrics.js'
import { getPayload } from './utils.js'
import type { bytes } from './@types/basic.js'
import type { IHandshake } from './@types/handshake-interface.js'
import type { INoiseConnection, KeyPair } from './@types/libp2p.js'
import type { ICryptoInterface } from './crypto.js'
import type { NoiseExtensions } from './proto/payload.js'
import type { SecuredConnection } from '@libp2p/interface-connection-encrypter'
import type { Metrics } from '@libp2p/interface-metrics'
import { MetricsRegistry, registerMetrics } from './metrics.js'
import type { PeerId } from '@libp2p/interface-peer-id'
import type { Duplex, Source } from 'it-stream-types'

interface HandshakeParams {
connection: ProtobufStream
Expand Down Expand Up @@ -136,7 +136,7 @@ export class Noise implements INoiseConnection {
const payload = await getPayload(params.localPeer, this.staticKeys.publicKey, this.extensions)

// run XX handshake
return await this.performXXHandshake(params, payload)
return this.performXXHandshake(params, payload)
}

private async performXXHandshake (
Expand Down
8 changes: 4 additions & 4 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { unmarshalPublicKey, unmarshalPrivateKey } from '@libp2p/crypto/keys'
import type { PeerId } from '@libp2p/interface-peer-id'
import { peerIdFromKeys } from '@libp2p/peer-id'
import { concat as uint8ArrayConcat } from 'uint8arrays/concat'
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
import { type NoiseExtensions, NoiseHandshakePayload } from './proto/payload.js'
import type { bytes } from './@types/basic.js'
import { NoiseExtensions, NoiseHandshakePayload } from './proto/payload.js'
import type { PeerId } from '@libp2p/interface-peer-id'

export async function getPayload (
localPeer: PeerId,
Expand Down Expand Up @@ -43,11 +43,11 @@ export async function signPayload (peerId: PeerId, payload: bytes): Promise<byte

const privateKey = await unmarshalPrivateKey(peerId.privateKey)

return await privateKey.sign(payload)
return privateKey.sign(payload)
}

export async function getPeerIdFromPayload (payload: NoiseHandshakePayload): Promise<PeerId> {
return await peerIdFromKeys(payload.identityKey)
return peerIdFromKeys(payload.identityKey)
}

export function decodePayload (payload: bytes | Uint8Array): NoiseHandshakePayload {
Expand Down
6 changes: 3 additions & 3 deletions test/fixtures/peer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { PeerId } from '@libp2p/interface-peer-id'
import { createEd25519PeerId, createFromJSON } from '@libp2p/peer-id-factory'
import type { PeerId } from '@libp2p/interface-peer-id'

// ed25519 keys
const peers = [{
Expand All @@ -21,8 +21,8 @@ const peers = [{
}]

export async function createPeerIdsFromFixtures (length: number): Promise<PeerId[]> {
return await Promise.all(
Array.from({ length }).map(async (_, i) => await createFromJSON(peers[i]))
return Promise.all(
Array.from({ length }).map(async (_, i) => createFromJSON(peers[i]))
)
}

Expand Down
6 changes: 3 additions & 3 deletions test/handshakes/xx.spec.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Buffer } from 'buffer'
import { expect, assert } from 'aegir/chai'
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
import { equals as uint8ArrayEquals } from 'uint8arrays/equals'
import type { KeyPair } from '../../src/@types/libp2p.js'
import type { NoiseSession } from '../../src/@types/handshake.js'
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
import { pureJsCrypto } from '../../src/crypto/js.js'
import { XX } from '../../src/handshakes/xx.js'
import { createHandshakePayload, getHandshakePayload } from '../../src/utils.js'
import { generateEd25519Keys } from '../utils.js'
import type { NoiseSession } from '../../src/@types/handshake.js'
import type { KeyPair } from '../../src/@types/libp2p.js'

describe('XX Handshake', () => {
const prologue = Buffer.alloc(0)
Expand Down
4 changes: 2 additions & 2 deletions test/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import type { Metrics } from '@libp2p/interface-metrics'
import { expect } from 'aegir/chai'
import { duplexPair } from 'it-pair/duplex'
import { pbStream } from 'it-pb-stream'
import sinon from 'sinon'
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
import { noise } from '../src/index.js'
import { Noise } from '../src/noise.js'
import { createPeerIdsFromFixtures } from './fixtures/peer.js'
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
import type { Metrics } from '@libp2p/interface-metrics'

function createCounterSpy (): ReturnType<typeof sinon.spy> {
return sinon.spy({
Expand Down
26 changes: 13 additions & 13 deletions test/interop.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import { connectInteropTests } from '@libp2p/interop'
import type { SpawnOptions, Daemon, DaemonFactory } from '@libp2p/interop'
import { createServer } from '@libp2p/daemon-server'
import fs from 'fs'
import { yamux } from '@chainsafe/libp2p-yamux'
import { unmarshalPrivateKey } from '@libp2p/crypto/keys'
import { createClient } from '@libp2p/daemon-client'
import { createLibp2p, Libp2pOptions } from 'libp2p'
import { createServer } from '@libp2p/daemon-server'
import { connectInteropTests } from '@libp2p/interop'
import { logger } from '@libp2p/logger'
import { peerIdFromKeys } from '@libp2p/peer-id'
import { tcp } from '@libp2p/tcp'
import { multiaddr } from '@multiformats/multiaddr'
import { path as p2pd } from 'go-libp2p'
import { execa } from 'execa'
import { path as p2pd } from 'go-libp2p'
import { createLibp2p, type Libp2pOptions } from 'libp2p'
import pDefer from 'p-defer'
import { logger } from '@libp2p/logger'
import { yamux } from '@chainsafe/libp2p-yamux'
import fs from 'fs'
import { unmarshalPrivateKey } from '@libp2p/crypto/keys'
import type { PeerId } from '@libp2p/interface-peer-id'
import { peerIdFromKeys } from '@libp2p/peer-id'
import { noise } from '../src/index.js'
import type { PeerId } from '@libp2p/interface-peer-id'
import type { SpawnOptions, Daemon, DaemonFactory } from '@libp2p/interop'

async function createGoPeer (options: SpawnOptions): Promise<Daemon> {
const controlPort = Math.floor(Math.random() * (50000 - 10000 + 1)) + 10000
Expand Down Expand Up @@ -98,10 +98,10 @@ async function main (): Promise<void> {
const factory: DaemonFactory = {
async spawn (options: SpawnOptions) {
if (options.type === 'go') {
return await createGoPeer(options)
return createGoPeer(options)
}

return await createJsPeer(options)
return createJsPeer(options)
}
}

Expand Down
10 changes: 5 additions & 5 deletions test/noise.spec.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import { randomBytes } from 'iso-random-stream'
import type { PeerId } from '@libp2p/interface-peer-id'
import { Buffer } from 'buffer'
import { assert, expect } from 'aegir/chai'
import { randomBytes } from 'iso-random-stream'
import { duplexPair } from 'it-pair/duplex'
import { pbStream } from 'it-pb-stream'
import sinon from 'sinon'
import { equals as uint8ArrayEquals } from 'uint8arrays/equals'
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
import sinon from 'sinon'
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
import { NOISE_MSG_MAX_LENGTH_BYTES } from '../src/constants.js'
import { pureJsCrypto } from '../src/crypto/js.js'
import { decode0, decode2, encode1, uint16BEDecode, uint16BEEncode } from '../src/encoder.js'
import { XX } from '../src/handshakes/xx.js'
import { XXHandshake } from '../src/handshake-xx.js'
import { XX } from '../src/handshakes/xx.js'
import { Noise } from '../src/noise.js'
import { createHandshakePayload, getHandshakePayload, getPayload, signPayload } from '../src/utils.js'
import { createPeerIdsFromFixtures } from './fixtures/peer.js'
import { getKeyPairFromPeerId } from './utils.js'
import type { PeerId } from '@libp2p/interface-peer-id'

describe('Noise', () => {
let remotePeer: PeerId, localPeer: PeerId
Expand Down
4 changes: 2 additions & 2 deletions test/utils.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { keys } from '@libp2p/crypto'
import type { KeyPair } from '../src/@types/libp2p.js'
import type { PrivateKey } from '@libp2p/interface-keys'
import type { PeerId } from '@libp2p/interface-peer-id'
import type { KeyPair } from '../src/@types/libp2p.js'

export async function generateEd25519Keys (): Promise<PrivateKey> {
return await keys.generateKeyPair('Ed25519', 32)
return keys.generateKeyPair('Ed25519', 32)
}

export function getKeyPairFromPeerId (peerId: PeerId): KeyPair {
Expand Down
2 changes: 1 addition & 1 deletion test/xx-handshake.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { PeerId } from '@libp2p/interface-peer-id'
import { Buffer } from 'buffer'
import { assert, expect } from 'aegir/chai'
import { duplexPair } from 'it-pair/duplex'
Expand All @@ -8,6 +7,7 @@ import { pureJsCrypto } from '../src/crypto/js.js'
import { XXHandshake } from '../src/handshake-xx.js'
import { getPayload } from '../src/utils.js'
import { createPeerIdsFromFixtures } from './fixtures/peer.js'
import type { PeerId } from '@libp2p/interface-peer-id'

describe('XX Handshake', () => {
let peerA: PeerId, peerB: PeerId, fakePeer: PeerId
Expand Down

0 comments on commit b269527

Please sign in to comment.