Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update protons and peer collections #172

Merged
merged 5 commits into from
Aug 2, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"@libp2p/interface-keys": "^1.0.2",
"@libp2p/interface-peer-id": "^1.0.2",
"@libp2p/logger": "^2.0.0",
"@libp2p/peer-collections": "^1.0.0",
"@libp2p/peer-collections": "^2.0.0",
"@libp2p/peer-id": "^1.1.8",
"@stablelib/chacha20poly1305": "^1.0.1",
"@stablelib/hkdf": "^1.0.1",
Expand All @@ -81,8 +81,8 @@
"it-pair": "^2.0.2",
"it-pb-stream": "^1.0.2",
"it-pipe": "^2.0.3",
"protons-runtime": "^1.0.3",
"uint8arraylist": "^1.4.0",
"protons-runtime": "^2.0.1",
"uint8arraylist": "^2.0.0",
"uint8arrays": "^3.0.0"
},
"devDependencies": {
Expand All @@ -93,7 +93,7 @@
"events": "^3.3.0",
"microtime": "^3.0.0",
"mkdirp": "^1.0.4",
"protons": "^3.0.3",
"protons": "^4.0.0",
"sinon": "^14.0.0",
"util": "^0.12.4"
},
Expand Down
2 changes: 1 addition & 1 deletion src/handshake-ik.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export class IKHandshake implements IHandshake {
const err = e as Error
logger('Responder breaking up with IK handshake in stage 0.')

throw new FailedIKError(receivedMsg, `Error occurred while verifying initiator's signed payload: ${err.message}`)
throw new FailedIKError(receivedMsg.slice(), `Error occurred while verifying initiator's signed payload: ${err.message}`)
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/proto/payload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import { encodeMessage, decodeMessage, message, bytes } from 'protons-runtime'
import type { Codec } from 'protons-runtime'
import type { Uint8ArrayList } from 'uint8arraylist'

export namespace pb {
export interface NoiseHandshakePayload {
Expand All @@ -20,11 +21,11 @@ export namespace pb {
})
}

export const encode = (obj: NoiseHandshakePayload): Uint8Array => {
export const encode = (obj: NoiseHandshakePayload): Uint8ArrayList => {
return encodeMessage(obj, NoiseHandshakePayload.codec())
}

export const decode = (buf: Uint8Array): NoiseHandshakePayload => {
export const decode = (buf: Uint8Array | Uint8ArrayList): NoiseHandshakePayload => {
return decodeMessage(buf, NoiseHandshakePayload.codec())
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export function createHandshakePayload (
identityKey: libp2pPublicKey,
identitySig: signedPayload,
data: earlyData ?? new Uint8Array(0)
})
}).slice()
mpetrunic marked this conversation as resolved.
Show resolved Hide resolved
}

export async function signPayload (peerId: PeerId, payload: bytes): Promise<bytes> {
Expand Down
2 changes: 1 addition & 1 deletion test/noise.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ describe('Noise', () => {

try {
const wrappedOutbound = pbStream(outbound.conn)
wrappedOutbound.write(new Uint8ArrayList(Buffer.from('test')))
wrappedOutbound.write(new Uint8ArrayList(Buffer.from('test')).slice())

// Check that noise message is prefixed with 16-bit big-endian unsigned integer
const receivedEncryptedPayload = (await wrapped.read()).slice()
Expand Down